Class LockServiceFactory
- java.lang.Object
-
- io.hekate.lock.LockServiceFactory
-
- All Implemented Interfaces:
ServiceFactory<LockService>
public class LockServiceFactory extends Object implements ServiceFactory<LockService>
Factory forLockService
.This class represents a configurable factory for
LockService
. Instances of this class can beregistered
within theHekateBootstrap
in order to customize options of theLockService
.For more details about the
LockService
and its capabilities please see the documentation ofLockService
interface.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_RETRY_INTERVAL
Default value in milliseconds (=50) forsetRetryInterval(long)
.static int
DEFAULT_WORKER_THREADS
Default value (=1) forsetWorkerThreads(int)
.
-
Constructor Summary
Constructors Constructor Description LockServiceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LockService
createService()
Constructs a new service instance based on the configuration options of this factory.List<LockConfigProvider>
getConfigProviders()
Returns the list of lock region configuration providers (seesetConfigProviders(List)
).int
getNioThreads()
Returns the size of a thread pool for handling NIO-based network communications (seesetNioThreads(int)
).List<LockRegionConfig>
getRegions()
Returns the list of lock region configurations (seesetRegions(List)
).long
getRetryInterval()
Returns the time interval in milliseconds between retry attempts in case of network communication failures (seesetRetryInterval(long)
).int
getWorkerThreads()
Returns the size of a thread pool that will perform locks management operations (seesetWorkerThreads(int)
).void
setConfigProviders(List<LockConfigProvider> configProviders)
Sets the list of lock region configuration providers.void
setNioThreads(int nioThreads)
Sets the size of a thread pool for handling NIO-based network communications.void
setRegions(List<LockRegionConfig> regions)
Sets the list of lock region configurations that should be registered to theLockService
.void
setRetryInterval(long retryInterval)
Sets the time interval in milliseconds between retry attempts in case of network communication failures.void
setWorkerThreads(int workerThreads)
Sets the side of a thread pool that will perform lock management operations.String
toString()
LockServiceFactory
withConfigProvider(LockConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.LockServiceFactory
withNioThreads(int nioThreads)
Fluent-style version ofsetNioThreads(int)
.LockServiceFactory
withRegion(LockRegionConfig region)
Fluent-style version ofsetRegions(List)
.LockServiceFactory
withRetryInterval(long retryInterval)
Fluent-style version ofsetRetryInterval(long)
.LockServiceFactory
withWorkerThreads(int workerThreads)
Fluent-style version ofsetWorkerThreads(int)
.
-
-
-
Field Detail
-
DEFAULT_RETRY_INTERVAL
public static final int DEFAULT_RETRY_INTERVAL
Default value in milliseconds (=50) forsetRetryInterval(long)
.- See Also:
- Constant Field Values
-
DEFAULT_WORKER_THREADS
public static final int DEFAULT_WORKER_THREADS
Default value (=1) forsetWorkerThreads(int)
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getRegions
public List<LockRegionConfig> getRegions()
Returns the list of lock region configurations (seesetRegions(List)
).- Returns:
- Lock region configurations.
-
setRegions
public void setRegions(List<LockRegionConfig> regions)
Sets the list of lock region configurations that should be registered to theLockService
.- Parameters:
regions
- Lock regions configuration.
-
withRegion
public LockServiceFactory withRegion(LockRegionConfig region)
Fluent-style version ofsetRegions(List)
.- Parameters:
region
- Lock region configuration that should be registered to theLockService
.- Returns:
- This instance.
-
getConfigProviders
public List<LockConfigProvider> getConfigProviders()
Returns the list of lock region configuration providers (seesetConfigProviders(List)
).- Returns:
- Lock region configuration providers.
-
setConfigProviders
public void setConfigProviders(List<LockConfigProvider> configProviders)
Sets the list of lock region configuration providers.- Parameters:
configProviders
- Lock region configuration providers.- See Also:
LockConfigProvider
-
withConfigProvider
public LockServiceFactory withConfigProvider(LockConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.- Parameters:
configProvider
- Lock region configuration provider.- Returns:
- This instance.
-
getRetryInterval
public long getRetryInterval()
Returns the time interval in milliseconds between retry attempts in case of network communication failures (seesetRetryInterval(long)
).- Returns:
- Time interval in milliseconds.
-
setRetryInterval
public void setRetryInterval(long retryInterval)
Sets the time interval in milliseconds between retry attempts in case of network communication failures.Value of this parameter must be above zero. Default value is 50.
- Parameters:
retryInterval
- Time interval in milliseconds.
-
withRetryInterval
public LockServiceFactory withRetryInterval(long retryInterval)
Fluent-style version ofsetRetryInterval(long)
.- Parameters:
retryInterval
- Time interval in milliseconds.- Returns:
- This instance.
-
getWorkerThreads
public int getWorkerThreads()
Returns the size of a thread pool that will perform locks management operations (seesetWorkerThreads(int)
).- Returns:
- Worker thread pool size.
-
setWorkerThreads
public void setWorkerThreads(int workerThreads)
Sets the side of a thread pool that will perform lock management operations.Thread pool of this size is used by the
LockService
to perform in-memory lock operations.Value of this parameter must be equals or greater than 1. Default value is 1.
- Parameters:
workerThreads
- Worker thread pool size.
-
withWorkerThreads
public LockServiceFactory withWorkerThreads(int workerThreads)
Fluent-style version ofsetWorkerThreads(int)
.- Parameters:
workerThreads
- Worker thread pool size.- Returns:
- This instance.
-
getNioThreads
public int getNioThreads()
Returns the size of a thread pool for handling NIO-based network communications (seesetNioThreads(int)
).- Returns:
- NIO thread pool size.
-
setNioThreads
public void setNioThreads(int nioThreads)
Sets the size of a thread pool for handling NIO-based network communications.If value of this parameter is above zero then a dedicated thread pool will be used for handling NIO-based network communications. If this parameter is less than or equals to zero (default value) then the core thread pool of a
NetworkService
will be used (seeNetworkServiceFactory.setNioThreads(int)
).- Parameters:
nioThreads
- NIO thread pool size.
-
withNioThreads
public LockServiceFactory withNioThreads(int nioThreads)
Fluent-style version ofsetNioThreads(int)
.- Parameters:
nioThreads
- NIO thread pool size.- Returns:
- This instance.
-
createService
public LockService createService()
Description copied from interface:ServiceFactory
Constructs a new service instance based on the configuration options of this factory.- Specified by:
createService
in interfaceServiceFactory<LockService>
- Returns:
- New service instance.
-
-