Class ClusterNode
- All Implemented Interfaces:
ADEPT2Service,LogService,ServiceThreadHandling,ClusterService,ClusterCommPoller,ClusterDbPoller
To allow for nodes to switch roles between client and server, each node needs a server as well as a client configuration. Both are provided in the constructor of a cluster node.
Use this class instead of AristaFlowPlatform for
bootstrapping in a cluster environment.
This class handles all cluster stuff automatically, that is, if the server is not available any
more or there are any problems reaching the server, the cluster node restarts. In case of
problems it also may restart or even terminate in case of unrecoverable problems. However, this
requires to run asynchronously, so bootstrap(), restart(long) and
terminate() return early. You will have to check the status via
ClusterNodeState.getStatus() or ClusterNodeState.awaitStatus(long, Status...) to
make sure that the cluster is in the appropriate state.
Nevertheless, make sure that you terminate() the cluster node (and
await Status.TERMINATED) to
properly terminate the platform! Otherwise your JVM may not exit properly or not exit at all.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final de.aristaflow.adept2.core.registry.cluster.ServerDataDeprecated.Data related to the current server like URIs and the amount of lost connections.protected final LockDeprecated.The lock required to control this cluster node.protected ClusterNodeInformationDeprecated.Data related to the current server as retrieved from the database.protected final HeartBeatControlDeprecated.The control for the heartbeats of this cluster node.protected final de.aristaflow.adept2.core.registry.cluster.NodeControlDeprecated.The thread controlling this node, that is it handles the complete node lifecycle including restarting and thus changing roles.protected final ClusterNodeStateDeprecated.The state of this cluster node encapsulated in a separate object.protected RegistryDeprecated.The registry used to access the communication service of the cluster server.protected final ServiceStateTrackerDeprecated.The service state tracker coupled to the lifecycle of this cluster node instead of the internal platform.Fields inherited from class de.aristaflow.adept2.core.registry.InitialisedInjectedService
adept2Service, loggerClass, NOT_INITIALISED_EXCEPTIONFields inherited from class de.aristaflow.adept2.core.registry.InjectedADEPT2Service
EMPTY_STRING_ARRAY, logger, runtimeRequiredServices, startupRequiredServices -
Constructor Summary
ConstructorsConstructorDescriptionClusterNode(ConfigurationPropertyProvider serverProvider, ConfigurationPropertyProvider clientProvider, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configuration providers.ClusterNode(Configuration serverConf, ConfigurationPropertyProvider serverProvider, Configuration clientConf, ConfigurationPropertyProvider clientProvider, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configurations and the designated configuration providers.ClusterNode(Configuration serverConf, Configuration clientConf, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configurations. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Bootstraps this cluster node asynchronously.doubtfulStatus(SessionToken session, String requestingNode, long lastRequesterUpdate, long lastServerUpdate, long serverRunningSince) Deprecated.Gets information on the cluster node implementing this cluster service and signals this cluster node, that its status is doubtful.Deprecated.Retrieves the set of all known Cluster Nodes (dead or alive).getClientService(long timeout) Deprecated.Gets the client service providing convenient access to the services provided by the platform and needed by client components.getNodeInformation(SessionToken session) Deprecated.Gets information on the cluster node implementing this cluster service.getRegistry(long timeout) Deprecated.Gets the wrapper for accessing the platform via theRegistry-interface waiting for the designated amount of time if the platform is currently not available.getRootConfiguration(long timeout) Deprecated.Gets the root configuration used for this cluster node as clone waiting for the designated amount of time if the platform is currently not available.URI[]Deprecated.Gets the URIs of the cluster service of the server for inter node communication.Deprecated.Gets the service state tracker coupled to the lifecycle of this cluster node instead of the internal platform.getState()Deprecated.Gets the node state of this cluster node.voidDeprecated.Checks the licence for failover clusterand starts the heartbeat using the communication.voidinitPlatform(Configuration conf, Registry reg) Deprecated.Creates a wrappedAbstractAuthenticatedService.voidpollServerComm(long timeout, boolean serverDoubtful) Deprecated.Polls the server of this cluster via communication.booleanpollServerDb(long timeout, ClusterInteractionRequest request) Deprecated.Polls the server of this cluster and sends an alive signal to the cluster DB service.restart(long timeout) Deprecated.Sends a restart request to this cluster node and waits the designated time for the restart.voidDeprecated.Signals a restart of this cluster node.voidshutdown(boolean emergency) Deprecated.Signals this service that it is being shut down.voidstart()Deprecated.Start the service state tracker after starting this injected service.voidDeprecated.Sends a terminate request to this cluster node.Methods inherited from class de.aristaflow.adept2.core.registry.AuthenticatedInjectedService
createChildSession, createSession, getAgent, getServiceInstanceName, getSessionFactory, getTopLevelAgent, getUserCredentials, sessionHasAllCapabilities, sessionHasOneCapabilityMethods inherited from class de.aristaflow.adept2.core.registry.InitialisedInjectedService
_sessionActive, _sessionFinished, changeLogContext, changeLogContext, changeLogContext, csvLoggingEnabled, getClassSpecificJulLogger, getLogger, getRelease, isActive, isInitialised, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionFinished, signalShutdown, signalStart, unprivilegeThreadMethods inherited from class de.aristaflow.adept2.core.registry.InjectedADEPT2Service
getLocalUris, getRuntimeRequiredServices, getStartupRequiredServices, getURIs, ping, preShutdownMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdown
-
Field Details
-
dbServer
Deprecated.Data related to the current server as retrieved from the database. This will benulluntil a server is retrieved from the database. Afterwards this information refers to the last server retrieved from the database. This data may be stale. -
commServer
protected final de.aristaflow.adept2.core.registry.cluster.ServerData commServerDeprecated.Data related to the current server like URIs and the amount of lost connections. -
nodeState
Deprecated.The state of this cluster node encapsulated in a separate object. -
heartBeatControl
Deprecated.The control for the heartbeats of this cluster node. -
nodeControl
protected final de.aristaflow.adept2.core.registry.cluster.NodeControl nodeControlDeprecated.The thread controlling this node, that is it handles the complete node lifecycle including restarting and thus changing roles. -
controlLock
Deprecated.The lock required to control this cluster node. This includes starting, terminating and restarting but also polling. Polling relies on the current cluster node status and update times so this must not happen concurrently while another thread performs another control operation. -
serviceStateTracker
Deprecated.The service state tracker coupled to the lifecycle of this cluster node instead of the internal platform. This allows for service state tracking independent from the current state of the internal platform. -
registry
Deprecated.The registry used to access the communication service of the cluster server.
-
-
Constructor Details
-
ClusterNode
public ClusterNode(Configuration serverConf, Configuration clientConf, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configurations.- Parameters:
serverConf- The configuration to be provided when booted as server. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or evennull. If this isnull, only configurations from the configuration directories will be used but this requires a validrootConfFileName.clientConf- The configuration to be provided when booted as client. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or evennull. If this isnull, only configurations from the configuration directories will be used but this requires a validrootConfFileName.
The URI of the global registry will be set to the one of the server of this cluster.servAvailPoolSize- The amount of threads used for the service availability tracking.servAvailPollRate- The rate in milliseconds at which to poll the availability of services.logger- The logger which to use for information that is happening asynchronously that is critical or worth knowing. This has to be configured separately since it is used outside of the platform lifecycle.- See Also:
-
ClusterNode
public ClusterNode(ConfigurationPropertyProvider serverProvider, ConfigurationPropertyProvider clientProvider, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configuration providers.- Parameters:
serverProvider- The configuration provider to be used when booted as server. This can benulland it can be the same as theclientProvider.clientProvider- The configuration provider to be used when booted as client. This can benulland it can be the same as theserverProvider.servAvailPoolSize- The amount of threads used for the service availability tracking.servAvailPollRate- The rate in milliseconds at which to poll the availability of services.logger- The logger which to use for information that is happening asynchronously that is critical or worth knowing. This has to be configured separately since it is used outside of the platform lifecycle.- See Also:
-
ClusterNode
public ClusterNode(Configuration serverConf, ConfigurationPropertyProvider serverProvider, Configuration clientConf, ConfigurationPropertyProvider clientProvider, int servAvailPoolSize, long servAvailPollRate, Logger logger) Deprecated.Creates a newClusterNodehaving the designated configurations and the designated configuration providers.- Parameters:
serverConf- The configuration to be provided when booted as server. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or evennull. If this isnull, only configurations from the configuration directories will be used but this requires a validrootConfFileName.serverProvider- The configuration provider to be used when booted as server. This can benulland it can be the same as theclientProvider.clientConf- The configuration to be provided when booted as client. This may either be a complete root configuration (without additional configuration directories), a delta configuration complementing or overriding the configurations from the configuration directories or evennull. If this isnull, only configurations from the configuration directories will be used but this requires a validrootConfFileName.
The URI of the global registry will be set to the one of the server of this cluster.clientProvider- The configuration provider to be used when booted as client. This can benulland it can be the same as theserverProvider.servAvailPoolSize- The amount of threads used for the service availability tracking.servAvailPollRate- The rate in milliseconds at which to poll the availability of services.logger- The logger which to use for information that is happening asynchronously that is critical or worth knowing. This has to be configured separately since it is used outside of the platform lifecycle.- See Also:
-
-
Method Details
-
bootstrap
public void bootstrap()Deprecated.Bootstraps this cluster node asynchronously. You might want to await a specific status or the client service or the registry.Only one platform may be running at a time. You need to terminate a platform before you can bootstrap another one. Note that terminating is done asynchronously so you need to wait for this cluster node to be terminated.
- Throws:
IllegalThreadStateException- If this cluster node has already been bootstrapped, anIllegalThreadStateExceptionwill be thrown.
-
getServiceStateTracker
Deprecated.Gets the service state tracker coupled to the lifecycle of this cluster node instead of the internal platform. This allows for service state tracking independent from the current state of the internal platform.- Returns:
- The service state tracker coupled to the lifecycle of this cluster node instead of the internal platform.
-
getClientService
public ClientService getClientService(long timeout) throws AbortServiceException, InterruptedException Deprecated.Gets the client service providing convenient access to the services provided by the platform and needed by client components. The client service will be retrieved with waiting for the platform for the designated amount of time if it is currently not available.- Parameters:
timeout- The time in milliseconds to wait for the platform if it is not available.- Returns:
- The client service for usage by client components.
- Throws:
InterruptedException- If the current thread is interrupted while waiting for the platform to become available, anInterruptedExceptionwill be thrown.ServiceNotKnownException- If there are problems retrieving the client service, aServiceNotKnownExceptionwill be thrown.AbortServiceException- If the platform has not been bootstrapped or terminated or a non-recoverable problem has occurred, anAbortServiceExceptionwill be thrown.
-
getRegistry
Deprecated.Gets the wrapper for accessing the platform via theRegistry-interface waiting for the designated amount of time if the platform is currently not available. The registry is used by (server) services to access the registry. Clients should always use an appropriateclient service. Only use this registry for very special purposes.- Parameters:
timeout- The time in milliseconds to wait for the platform if it is not available.- Returns:
- The registry providing generic access to the platform or
nullif the timeout elapsed before the platform becomes available. - Throws:
InterruptedException- If the current thread is interrupted while waiting for the platform to become available, anInterruptedExceptionwill be thrown.ServiceNotKnownException- If there are problems loading the model factory registry, aServiceNotKnownExceptionwill be thrown.AbortServiceException- If the platform has not been bootstrapped or terminated or a non-recoverable problem has occurred, anAbortServiceExceptionwill be thrown.
-
getRootConfiguration
public Configuration getRootConfiguration(long timeout) throws AbortServiceException, InterruptedException Deprecated.Gets the root configuration used for this cluster node as clone waiting for the designated amount of time if the platform is currently not available. Note that the root configuration need not contain all configuration values. Configurations from referenced configuration files will not be part of it.
Note that the root configuration does not contain the default values added by the configuration description of a service. Additionally, it is not validated yet, that is, some required values may be missing leading to problems when starting the corresponding service.- Parameters:
timeout- The time in milliseconds to wait for the platform if it is not available.- Returns:
- A clone of the root configuration after bootstrapping and
nullafter terminating. - Throws:
InterruptedException- If the current thread is interrupted while waiting for the platform to become available, anInterruptedExceptionwill be thrown.ServiceNotKnownException- If there are problems loading the model factory registry, aServiceNotKnownExceptionwill be thrown.AbortServiceException- If the platform has not been bootstrapped or terminated or a non-recoverable problem has occurred, anAbortServiceExceptionwill be thrown.
-
restart
Deprecated.Sends a restart request to this cluster node and waits the designated time for the restart.- Parameters:
timeout- The time in milliseconds to wait for the cluster node to be restarted or terminated. reach one of the designated statuses. Use 0 to not wait at all or a negative value to wait without time limit.- Returns:
- The status this node reached after restarting (
Status.RUNNING_SERVER,Status.CONNECTED_CLIENTorStatus.TERMINATED) ornullin case the time elapsed before the status is reached. - Throws:
InterruptedException- If the current thread is interrupted while waiting for the restart, anInterruptedExceptionwill be thrown.AbortServiceException- If there are non-recoverable problems with the cluster especially when bootstrapping, anAbortServiceExceptionwill be thrown.
-
terminate
public void terminate()Deprecated.Sends a terminate request to this cluster node. This will terminate the platform by shutting down the bootstrap registry and signalling this to the cluster asynchronously. You have to call this method before exiting the JVM. Otherwise the services will not be terminated correctly and may have inconsistent persisted data. This especially applies to the cluster DB service.
If there are problems when terminating, they will be logged.
You should wait for this cluster node to beStatus.TERMINATEDbefore really shutting down or exiting the JVM.Terminating the platform several times will be ignored. The same applies to terminating before loading.
-
getAllClusterNodes
Deprecated.Retrieves the set of all known Cluster Nodes (dead or alive).- Returns:
- The set of all known Cluster Nodes (dead or alive) or
nullin case no cluster DB is available.
-
pollServerDb
public boolean pollServerDb(long timeout, ClusterInteractionRequest request) throws InterruptedException, TimeoutException, SQLException Deprecated.Description copied from interface:ClusterDbPollerPolls the server of this cluster and sends an alive signal to the cluster DB service. If the server is no longer available or it changed, a restart should be executed. This is indicated by the return value.If the control of the cluster node cannot be acquired in the designated time, this method will do nothing.
- Specified by:
pollServerDbin interfaceClusterDbPoller- Parameters:
timeout- The time in milliseconds to wait for the cluster control lock.request- Whether to simply poll or to restart the server. A restart request contains the cluster name, the node name as well as the time since when the server has been running. If this isnull, the current server will just be polled.- Returns:
- Whether the cluster node needs to restart since another server has been elected or is about to be elected.
- Throws:
InterruptedException- If the calling thread is interrupted while waiting for the node control or has been interrupted before, anInterruptedExceptionwill be thrown.TimeoutException- If the table for updating the status cannot be locked in time, aTimeoutExceptionwill be thrown.SQLException- If there are problems updating the status in the cluster table, anSQLExceptionwill be thrown.
-
restartInternal
public void restartInternal()Deprecated.Description copied from interface:ClusterDbPollerSignals a restart of this cluster node. This may be for instance due to the cluster requiring a new server (ClusterDbPoller.pollServerDb(long, ClusterInteractionRequest)) or polling fails too often.- Specified by:
restartInternalin interfaceClusterDbPoller
-
getServerCommService
Deprecated.Description copied from interface:ClusterCommPollerGets the URIs of the cluster service of the server for inter node communication.- Specified by:
getServerCommServicein interfaceClusterCommPoller- Returns:
- The URIs of the cluster service of the server for inter node
communication or
nullif no global registry URIs are set.
-
pollServerComm
Deprecated.Description copied from interface:ClusterCommPollerPolls the server of this cluster via communication. If the server cannot be reached via communication, the corresponding lost count will be increased. Afterwards the cluster heartbeat using the database will be notified. It will also be notified if the state of the server changes.If the control of the cluster node cannot be acquired in the designated time, this method will do nothing.
- Specified by:
pollServerCommin interfaceClusterCommPoller- Parameters:
timeout- The time in milliseconds to wait for the cluster control lock.serverDoubtful- Whether the server is doubtful and should be notified appropriately.- Throws:
InterruptedException- If the calling thread is interrupted while waiting for the node control or has been interrupted before, anInterruptedExceptionwill be thrown.
-
getState
Deprecated.Gets the node state of this cluster node. This reflects the current state of the cluster node all the time.- Returns:
- The node state of this cluster node.
-
initPlatform
Deprecated.Description copied from class:AuthenticatedInjectedServiceCreates a wrappedAbstractAuthenticatedService.- Overrides:
initPlatformin classAuthenticatedInjectedService- Parameters:
conf- The configuration provided by the platform.reg- The registry allowing to access the platform.- Throws:
AbortServiceException- If there are problems initialising this service, anAbortServiceExceptionwill be thrown.
-
init
Deprecated.Checks the licence for failover clusterand starts the heartbeat using the communication.- Specified by:
initin interfaceADEPT2Service- Overrides:
initin classInitialisedInjectedService- Parameters:
localExportedUris- The URIs with which this service is exported locally or a local URI or an empty array for internal services.globalExportedUris- The URIs with which this service is published globally ornullin case the service is not published.- Throws:
AbortServiceException- If this service cannot be initialised due to a severe problem, anAbortServiceExceptionwill be thrown.ADEPT2Service.shutdown(boolean)will not be called when aborting; the service has to shut down itself/clean up before throwing the exception.- See Also:
-
start
Deprecated.Start the service state tracker after starting this injected service. This service is used to track the platform state and should be started when starting the service state tracker.- Specified by:
startin interfaceADEPT2Service- Overrides:
startin classInitialisedInjectedService- Throws:
AbortServiceException- If this service cannot be started due to a severe problem, anAbortServiceExceptionwill be thrown.ADEPT2Service.shutdown(boolean)will not be called when aborting; the service has to shut down itself/clean up before throwing the exception.- See Also:
-
shutdown
public void shutdown(boolean emergency) Deprecated.Description copied from interface:ADEPT2ServiceSignals this service that it is being shut down. While this method is called, the service is no longer (remotely) available. It should terminate and close all activities and connections. Since the service is in an inconsistent state while shutting down, access should be restricted to the threads relevant for shutting down. All other requests should be blocked (seeServiceThreadHandling.
All startup required services are available in shutdown, runtime services may already be shut down.
In case of an emergency shutdown, even startup required services may not be available. Additionally, shutting down should be rather fast, so cleanup should concentrate on the really important things and use brief timeouts when waiting.- Specified by:
shutdownin interfaceADEPT2Service- Overrides:
shutdownin classInitialisedInjectedService- Parameters:
emergency- Whether the shutdown will be an emergency shutdown.- See Also:
-
getNodeInformation
Deprecated.Description copied from interface:ClusterServiceGets information on the cluster node implementing this cluster service.- Specified by:
getNodeInformationin interfaceClusterService- Parameters:
session- The session which is used to check for access rights on this method.- Returns:
- The simple information for this cluster node, that is name, address, status, last update time and running since. Status and last update time may differ from the values in the database, e. g. a node has changed its status but cannot access the database.
-
doubtfulStatus
public SimpleClusterNodeInformation doubtfulStatus(SessionToken session, String requestingNode, long lastRequesterUpdate, long lastServerUpdate, long serverRunningSince) Deprecated.Description copied from interface:ClusterServiceGets information on the cluster node implementing this cluster service and signals this cluster node, that its status is doubtful. This urges this cluster node to update the database shortly. In case of problems accessing the database, it may even signal its termination.- Specified by:
doubtfulStatusin interfaceClusterService- Parameters:
session- The session which is used to check for access rights on this method.requestingNode- The name of the node notifying the doubtful status.lastRequesterUpdate- The last time the requester has updated its status (which is the same as checking for the server status.lastServerUpdate- The last time the server has updated its status in the database according to the requester. If this is older than the last update time of the server, the requester has not the latest status, thus the notified doubtful status is not valid (any more).serverRunningSince- The time the server has switched to running in the database according to the requester. If this is older than the current running since time, the requester has not the latest status, thus the notified doubtful status is not valid (any more).- Returns:
- The simple information for this cluster node, that is name, address, status, last update time and running since. Status and last update time may differ from the values in the database, e. g. a node has changed its status but cannot access the database.
-