Package org.cyclos.impl.utils.cluster
Class HazelcastClusterHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractGlobalServerComponent
-
- org.cyclos.impl.BaseGlobalHandlerImpl
-
- org.cyclos.impl.utils.cluster.AbstractClusterHandlerImpl
-
- org.cyclos.impl.utils.cluster.HazelcastClusterHandlerImpl
-
- All Implemented Interfaces:
CustomBean,ClusterHandler
public class HazelcastClusterHandlerImpl extends AbstractClusterHandlerImpl
AClusterHandlerusingHazelcast
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cyclos.impl.utils.cluster.AbstractClusterHandlerImpl
AbstractClusterHandlerImpl.FinishedExecutionsHandlerImpl
-
Nested classes/interfaces inherited from interface org.cyclos.impl.utils.cluster.ClusterHandler
ClusterHandler.FinishedExecutionsHandler
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.utils.cluster.AbstractClusterHandlerImpl
applicationContext, backgroundTaskHandler, beanHandler, cyclosProperties, databaseManager, dbLockHandler, IGNORE_DB_LOCK_PROPERTY, ignoreDbLock, invokerHandler, lockHandler, nativeQueryHandler, pollingTaskHandler, rawEntityManagerHandler, systemMonitorService
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description HazelcastClusterHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <K,V>
ReplicatedStorage<K,V>createReplicatedStorage(ReplicatedStorageType type)protected <K extends Serializable,V extends Serializable>
SharedStorage<K,V>createSharedStorage(SharedStorageType<K,V> type)Actually creates a new shared storage.voiddestroy()protected voiddoRemoveFinishedBackgroundTaskExecutions(List<Long> ids)voidfinishBackgroundTaskExecution(BackgroundTaskExecutionContext task)Masks as finished the given task executionMap<String,Integer>getBackgroundTaskExecutions()Returns a map from background task name to the number of executions it has.protected BlockingQueue<BackgroundTaskExecutionContext>getBackgroundTaskQueue()protected intgetBackgroundTaskThreads()ClusterHandler.FinishedExecutionsHandlergetFinishedBackgroundTaskExecutions()Returns a handler with the already finished executions at the moment of the invocation.StringgetHostId()Returns the current host identifierMemberRunningTaskDescriptorgetMemberRunningTask(String taskName)Returns information with the member running the given polling task or null if the task is not being executed.List<ServerData>getMembersData()Returns information about each cluster member.
In caseClusterHandler.isCluster()returns false then the list will contain a single element with the information of the local host.Map<String,MemberRunningTaskDescriptor>getRunningPollingTasks()Returns a map from polling task name to a descriptor with information about the member that is executing it.voidinitialize()protected CacheHandlerImplementorinstantiateCacheHandler()protected PollingTaskHandlerImplementorinstantiatePollingTaskHandler()protected PushNotificationHandlerinstantiatePushNotificationHandler()booleanisAlive()Returns whether the cluster (or local instance) is still alivebooleanisCausedByShutdown(Throwable e)Returns whether the given exception was caused by a server shutdown.booleanisCluster()Returns whether we're actually running in a cluster or as a single node installationprotected voidrunBackgroundTask(BackgroundTaskExecutionContext task)booleanrunInitialization(ApplicationInitializationListener listener)Attempts to execute the givenApplicationInitializationListener.onApplicationInitialization().booleanrunUpgradeInitialization(ApplicationUpgradeInitializationListener listener)Attempts to execute the givenApplicationUpgradeInitializationListener.onApplicationUpgradeInitialization().protected booleanshouldEnsureDatabaseIsNotLocked()protected booleanshouldUnlockDatabase()voidshutdown()-
Methods inherited from class org.cyclos.impl.utils.cluster.AbstractClusterHandlerImpl
awakePollingTasks, createLocalStorage, getBackgroundTasksQueueSize, getCacheHandler, getLocalStorage, getPollingTaskHandler, getPushNotificationHandler, getRemainingBackgroundTaskCapacity, getReplicatedStorage, getSharedStorage, lockDatabase, runBackgroundTasks
-
Methods inherited from class org.cyclos.impl.AbstractGlobalServerComponent
getBaseEntityManagerHandler, getEntityManager
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
destroy
@PreDestroy public void destroy()
-
finishBackgroundTaskExecution
public void finishBackgroundTaskExecution(BackgroundTaskExecutionContext task)
Description copied from interface:ClusterHandlerMasks as finished the given task execution
-
getBackgroundTaskExecutions
public Map<String,Integer> getBackgroundTaskExecutions()
Description copied from interface:ClusterHandlerReturns a map from background task name to the number of executions it has. A task no contained in the map means it's not running at the moment of the invocation.
-
getFinishedBackgroundTaskExecutions
public ClusterHandler.FinishedExecutionsHandler getFinishedBackgroundTaskExecutions()
Description copied from interface:ClusterHandlerReturns a handler with the already finished executions at the moment of the invocation.
-
getHostId
public String getHostId()
Description copied from interface:ClusterHandlerReturns the current host identifier
-
getMemberRunningTask
public MemberRunningTaskDescriptor getMemberRunningTask(String taskName)
Description copied from interface:ClusterHandlerReturns information with the member running the given polling task or null if the task is not being executed.
-
getMembersData
public List<ServerData> getMembersData()
Description copied from interface:ClusterHandlerReturns information about each cluster member.
In caseClusterHandler.isCluster()returns false then the list will contain a single element with the information of the local host.
-
getRunningPollingTasks
public Map<String,MemberRunningTaskDescriptor> getRunningPollingTasks()
Description copied from interface:ClusterHandlerReturns a map from polling task name to a descriptor with information about the member that is executing it. A task no contained in the map means it's not running at the moment of the invocation.
-
initialize
@PostConstruct public void initialize()
- Overrides:
initializein classAbstractClusterHandlerImpl
-
isAlive
public boolean isAlive()
Description copied from interface:ClusterHandlerReturns whether the cluster (or local instance) is still alive
-
isCausedByShutdown
public boolean isCausedByShutdown(Throwable e)
Description copied from interface:ClusterHandlerReturns whether the given exception was caused by a server shutdown. For example,InterruptedExceptions are considered to be caused by a shutdown.- Specified by:
isCausedByShutdownin interfaceClusterHandler- Overrides:
isCausedByShutdownin classAbstractClusterHandlerImpl
-
isCluster
public boolean isCluster()
Description copied from interface:ClusterHandlerReturns whether we're actually running in a cluster or as a single node installation
-
runInitialization
public boolean runInitialization(ApplicationInitializationListener listener)
Description copied from interface:ClusterHandlerAttempts to execute the givenApplicationInitializationListener.onApplicationInitialization(). In some cases (for example, the initialization was already executed), it might do nothing, and just return false- Specified by:
runInitializationin interfaceClusterHandler- Overrides:
runInitializationin classAbstractClusterHandlerImpl
-
runUpgradeInitialization
public boolean runUpgradeInitialization(ApplicationUpgradeInitializationListener listener)
Description copied from interface:ClusterHandlerAttempts to execute the givenApplicationUpgradeInitializationListener.onApplicationUpgradeInitialization(). In some cases (for example, the initialization was already executed), it might do nothing, and just return false- Specified by:
runUpgradeInitializationin interfaceClusterHandler- Overrides:
runUpgradeInitializationin classAbstractClusterHandlerImpl
-
shutdown
@PreDestroy public void shutdown()
- Overrides:
shutdownin classAbstractClusterHandlerImpl
-
createReplicatedStorage
protected <K,V> ReplicatedStorage<K,V> createReplicatedStorage(ReplicatedStorageType type)
- Overrides:
createReplicatedStoragein classAbstractClusterHandlerImpl
-
createSharedStorage
protected <K extends Serializable,V extends Serializable> SharedStorage<K,V> createSharedStorage(SharedStorageType<K,V> type)
Description copied from class:AbstractClusterHandlerImplActually creates a new shared storage. The resulting value will be cached for the given name.- Overrides:
createSharedStoragein classAbstractClusterHandlerImpl
-
doRemoveFinishedBackgroundTaskExecutions
protected void doRemoveFinishedBackgroundTaskExecutions(List<Long> ids)
- Specified by:
doRemoveFinishedBackgroundTaskExecutionsin classAbstractClusterHandlerImpl
-
getBackgroundTaskQueue
protected BlockingQueue<BackgroundTaskExecutionContext> getBackgroundTaskQueue()
- Specified by:
getBackgroundTaskQueuein classAbstractClusterHandlerImpl
-
getBackgroundTaskThreads
protected int getBackgroundTaskThreads()
- Specified by:
getBackgroundTaskThreadsin classAbstractClusterHandlerImpl
-
instantiateCacheHandler
protected CacheHandlerImplementor instantiateCacheHandler()
- Specified by:
instantiateCacheHandlerin classAbstractClusterHandlerImpl
-
instantiatePollingTaskHandler
protected PollingTaskHandlerImplementor instantiatePollingTaskHandler()
- Specified by:
instantiatePollingTaskHandlerin classAbstractClusterHandlerImpl
-
instantiatePushNotificationHandler
protected PushNotificationHandler instantiatePushNotificationHandler()
- Specified by:
instantiatePushNotificationHandlerin classAbstractClusterHandlerImpl
-
runBackgroundTask
protected void runBackgroundTask(BackgroundTaskExecutionContext task)
- Overrides:
runBackgroundTaskin classAbstractClusterHandlerImpl
-
shouldEnsureDatabaseIsNotLocked
protected boolean shouldEnsureDatabaseIsNotLocked()
- Specified by:
shouldEnsureDatabaseIsNotLockedin classAbstractClusterHandlerImpl
-
shouldUnlockDatabase
protected boolean shouldUnlockDatabase()
- Specified by:
shouldUnlockDatabasein classAbstractClusterHandlerImpl
-
-