Class CoordinationServiceFactory
- java.lang.Object
-
- io.hekate.coordinate.CoordinationServiceFactory
-
- All Implemented Interfaces:
ServiceFactory<CoordinationService>
public class CoordinationServiceFactory extends Object implements ServiceFactory<CoordinationService>
Factory forCoordinationService
.This class represents a configurable factory for
CoordinationService
. Instances of this class can beregistered
within theHekateBootstrap
in order to customize options of theCoordinationService
.For more details about the
CoordinationService
and its capabilities please see the documentation ofCoordinationService
interface.- See Also:
CoordinationService
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_IDLE_SOCKET_TIMEOUT
Default value in milliseconds (=60000L) forsetIdleSocketTimeout(long)
.static int
DEFAULT_RETRY_INTERVAL
Default value in milliseconds (=50) forsetRetryInterval(long)
.
-
Constructor Summary
Constructors Constructor Description CoordinationServiceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CoordinationService
createService()
Constructs a new service instance based on the configuration options of this factory.List<CoordinationConfigProvider>
getConfigProviders()
Returns the list of coordination process configuration providers (seesetConfigProviders(List)
).long
getIdleSocketTimeout()
Returns the idle socket timeout in milliseconds (seesetIdleSocketTimeout(long)
).int
getNioThreads()
Returns the size of a thread pool for handling NIO-based socket connections.List<CoordinationProcessConfig>
getProcesses()
Returns the list of coordination process configurations that should be automatically registered during the coordination service startup (seesetProcesses(List)
).long
getRetryInterval()
Returns the time interval in milliseconds between retry attempts in case of network communication failures (seesetRetryInterval(long)
).void
setConfigProviders(List<CoordinationConfigProvider> configProviders)
Sets the list of coordination process configuration providers.void
setIdleSocketTimeout(long idleSocketTimeout)
Sets idle socket timeout in milliseconds.void
setNioThreads(int nioThreads)
Sets the size of a thread pool for handling NIO-based socket connections.void
setProcesses(List<CoordinationProcessConfig> processes)
Sets the list of coordination process configurations that should be automatically registered during the coordination service startup.void
setRetryInterval(long retryInterval)
Sets the time interval in milliseconds between retry attempts in case of network communication failures.CoordinationServiceFactory
withConfigProvider(CoordinationConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.CoordinationServiceFactory
withIdleSocketTimeout(long idleTimeout)
Fluent-style version ofsetIdleSocketTimeout(long)
.CoordinationServiceFactory
withNioThreads(int nioThreads)
Fluent-style version ofsetNioThreads(int)
.CoordinationServiceFactory
withProcess(CoordinationProcessConfig process)
Fluent-style version ofsetProcesses(List)
.CoordinationProcessConfig
withProcess(String name)
Fluent-style shortcut to register a newCoordinationProcessConfig
with the specifiedname
.CoordinationServiceFactory
withRetryInterval(long retryInterval)
Fluent-style version ofsetRetryInterval(long)
.
-
-
-
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_IDLE_SOCKET_TIMEOUT
public static final long DEFAULT_IDLE_SOCKET_TIMEOUT
Default value in milliseconds (=60000L) forsetIdleSocketTimeout(long)
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNioThreads
public int getNioThreads()
Returns the size of a thread pool for handling NIO-based socket connections.- Returns:
- Size of a thread pool for handling NIO-based socket connections.
-
setNioThreads
public void setNioThreads(int nioThreads)
Sets the size of a thread pool for handling NIO-based socket connections.If this parameter is less than or equals to zero (default value) then this channel will use the core thread pool of
NetworkService
(seeNetworkServiceFactory.setNioThreads(int)
).- Parameters:
nioThreads
- Size of a thread pool for handling NIO-based socket connections.
-
withNioThreads
public CoordinationServiceFactory withNioThreads(int nioThreads)
Fluent-style version ofsetNioThreads(int)
.- Parameters:
nioThreads
- Size of a thread pool for handling NIO-based socket connections.- 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 CoordinationServiceFactory withRetryInterval(long retryInterval)
Fluent-style version ofsetRetryInterval(long)
.- Parameters:
retryInterval
- Time interval in milliseconds.- Returns:
- This instance.
-
getProcesses
public List<CoordinationProcessConfig> getProcesses()
Returns the list of coordination process configurations that should be automatically registered during the coordination service startup (seesetProcesses(List)
).- Returns:
- Coordination processes configuration.
-
setProcesses
public void setProcesses(List<CoordinationProcessConfig> processes)
Sets the list of coordination process configurations that should be automatically registered during the coordination service startup.- Parameters:
processes
- Coordination processes configuration..
-
withProcess
public CoordinationServiceFactory withProcess(CoordinationProcessConfig process)
Fluent-style version ofsetProcesses(List)
.- Parameters:
process
- Coordination process configuration.- Returns:
- This instance.
-
withProcess
public CoordinationProcessConfig withProcess(String name)
Fluent-style shortcut to register a newCoordinationProcessConfig
with the specifiedname
.- Parameters:
name
- Process name (seeCoordinationProcessConfig.setName(String)
).- Returns:
- New coordination process configuration.
-
getConfigProviders
public List<CoordinationConfigProvider> getConfigProviders()
Returns the list of coordination process configuration providers (seesetConfigProviders(List)
).- Returns:
- Coordination process configuration providers.
-
setConfigProviders
public void setConfigProviders(List<CoordinationConfigProvider> configProviders)
Sets the list of coordination process configuration providers.- Parameters:
configProviders
- Coordination process configuration providers.- See Also:
CoordinationConfigProvider
-
withConfigProvider
public CoordinationServiceFactory withConfigProvider(CoordinationConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.- Parameters:
configProvider
- Coordination process configuration provider.- Returns:
- This instance.
-
getIdleSocketTimeout
public long getIdleSocketTimeout()
Returns the idle socket timeout in milliseconds (seesetIdleSocketTimeout(long)
).- Returns:
- Idle socket timeout in milliseconds.
-
setIdleSocketTimeout
public void setIdleSocketTimeout(long idleSocketTimeout)
Sets idle socket timeout in milliseconds.If there were no communication with some remote node for the duration of this time interval then all sockets connections with such node will be closed in order to save system resource. Connections will be automatically reestablish on the next attempt to send a message to that node.
If value of this parameter is less than or equals to zero then connections will not be closed while remote node stays alive.
Default value of this parameter is 60000L.
- Parameters:
idleSocketTimeout
- Timeout in milliseconds.
-
withIdleSocketTimeout
public CoordinationServiceFactory withIdleSocketTimeout(long idleTimeout)
Fluent-style version ofsetIdleSocketTimeout(long)
.- Parameters:
idleTimeout
- Timeout in milliseconds.- Returns:
- This instance.
-
createService
public CoordinationService createService()
Description copied from interface:ServiceFactory
Constructs a new service instance based on the configuration options of this factory.- Specified by:
createService
in interfaceServiceFactory<CoordinationService>
- Returns:
- New service instance.
-
-