Package org.cyclos.impl.utils.cluster
Class AbstractClusterHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractGlobalServerComponent
-
- org.cyclos.impl.BaseGlobalHandlerImpl
-
- org.cyclos.impl.utils.cluster.AbstractClusterHandlerImpl
-
- All Implemented Interfaces:
CustomBean,ClusterHandler
- Direct Known Subclasses:
HazelcastClusterHandlerImpl,NoClusterHandlerImpl
public abstract class AbstractClusterHandlerImpl extends BaseGlobalHandlerImpl implements ClusterHandler
Base implementation forClusterHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractClusterHandlerImpl.FinishedExecutionsHandlerImpl-
Nested classes/interfaces inherited from interface org.cyclos.impl.utils.cluster.ClusterHandler
ClusterHandler.FinishedExecutionsHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationContextapplicationContextprotected BackgroundTaskHandlerImplementorbackgroundTaskHandlerprotected BeanHandlerbeanHandlerprotected CyclosPropertiescyclosPropertiesprotected DatabaseManagerdatabaseManagerprotected DbLockHandlerdbLockHandlerstatic StringIGNORE_DB_LOCK_PROPERTYprotected booleanignoreDbLockprotected InvokerHandlerinvokerHandlerprotected LockHandlerlockHandlerprotected NativeQueryHandlernativeQueryHandlerprotected PollingTaskHandlerImplementorpollingTaskHandlerprotected RawEntityManagerHandlerrawEntityManagerHandlerprotected SystemMonitorServiceLocalsystemMonitorService-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractClusterHandlerImpl()
-
Method Summary
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.utils.cluster.ClusterHandler
finishBackgroundTaskExecution, getBackgroundTaskExecutions, getFinishedBackgroundTaskExecutions, getHostId, getMemberRunningTask, getMembersData, getRunningPollingTasks, isAlive, isCluster
-
-
-
-
Field Detail
-
IGNORE_DB_LOCK_PROPERTY
public static final String IGNORE_DB_LOCK_PROPERTY
- See Also:
- Constant Field Values
-
ignoreDbLock
protected boolean ignoreDbLock
-
pollingTaskHandler
protected PollingTaskHandlerImplementor pollingTaskHandler
-
applicationContext
@Autowired protected ApplicationContext applicationContext
-
beanHandler
@Autowired protected BeanHandler beanHandler
-
cyclosProperties
@Autowired protected CyclosProperties cyclosProperties
-
backgroundTaskHandler
@Autowired @Lazy protected BackgroundTaskHandlerImplementor backgroundTaskHandler
-
invokerHandler
@Autowired protected InvokerHandler invokerHandler
-
lockHandler
@Autowired protected LockHandler lockHandler
-
rawEntityManagerHandler
@Autowired @Lazy protected RawEntityManagerHandler rawEntityManagerHandler
-
nativeQueryHandler
@Autowired protected NativeQueryHandler nativeQueryHandler
-
dbLockHandler
protected DbLockHandler dbLockHandler
-
databaseManager
@Autowired protected DatabaseManager databaseManager
-
systemMonitorService
@Lazy @Autowired protected SystemMonitorServiceLocal systemMonitorService
-
-
Method Detail
-
awakePollingTasks
public void awakePollingTasks(Set<PollingTask> pollingTasksToAwake)
Description copied from interface:ClusterHandlerAwakes the givenPollingTasks- Specified by:
awakePollingTasksin interfaceClusterHandler
-
getBackgroundTasksQueueSize
public int getBackgroundTasksQueueSize()
Description copied from interface:ClusterHandlerReturns the current size of the background tasks queue- Specified by:
getBackgroundTasksQueueSizein interfaceClusterHandler
-
getCacheHandler
public final CacheHandlerImplementor getCacheHandler()
Description copied from interface:ClusterHandlerReturns theCacheHandlermanaged by this cluster- Specified by:
getCacheHandlerin interfaceClusterHandler
-
getLocalStorage
public <K,V> LocalStorage<K,V> getLocalStorage(LocalStorageType<K,V> type)
Description copied from interface:ClusterHandlerReturns the local storage for the given type- Specified by:
getLocalStoragein interfaceClusterHandler
-
getPollingTaskHandler
public final PollingTaskHandlerImplementor getPollingTaskHandler()
Description copied from interface:ClusterHandlerReturns thePollingTaskHandlermanaged by this cluster- Specified by:
getPollingTaskHandlerin interfaceClusterHandler
-
getPushNotificationHandler
public final PushNotificationHandler getPushNotificationHandler()
Description copied from interface:ClusterHandlerReturns thePushNotificationHandlerwhich can be used to publish / subscribe to push notification events- Specified by:
getPushNotificationHandlerin interfaceClusterHandler
-
getRemainingBackgroundTaskCapacity
public int getRemainingBackgroundTaskCapacity()
Description copied from interface:ClusterHandlerReturns number ofBackgroundTaskExecutionthe cluster can accept.- Specified by:
getRemainingBackgroundTaskCapacityin interfaceClusterHandler
-
getReplicatedStorage
public <K extends Serializable,V extends Serializable> ReplicatedStorage<K,V> getReplicatedStorage(ReplicatedStorageType type)
Description copied from interface:ClusterHandlerReturns a simple storage with a given name- Specified by:
getReplicatedStoragein interfaceClusterHandler
-
getSharedStorage
public final <K extends Serializable,V extends Serializable> SharedStorage<K,V> getSharedStorage(SharedStorageType<K,V> type)
Description copied from interface:ClusterHandlerReturns a shared storage with a given name- Specified by:
getSharedStoragein interfaceClusterHandler
-
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
-
lockDatabase
public boolean lockDatabase()
Description copied from interface:ClusterHandlerChecks that there is no other Cyclos instance using the database and afterwards, locks the database. Returns whether the database was actually locked.- Specified by:
lockDatabasein interfaceClusterHandler
-
runBackgroundTasks
public final void runBackgroundTasks(List<BackgroundTaskExecutionContext> tasks)
Description copied from interface:ClusterHandlerExecutes the background tasks with the given ids. TheCyclosProperties.getMaxBackgroundTasks()is respected.- Specified by:
runBackgroundTasksin interfaceClusterHandler
-
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
-
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
-
createLocalStorage
protected <K,V> LocalStorage<K,V> createLocalStorage(LocalStorageType<K,V> type)
-
createReplicatedStorage
protected <K,V> ReplicatedStorage<K,V> createReplicatedStorage(ReplicatedStorageType type)
-
createSharedStorage
protected <K extends Serializable,V extends Serializable> SharedStorage<K,V> createSharedStorage(SharedStorageType<K,V> type)
Actually creates a new shared storage. The resulting value will be cached for the given name.
-
doRemoveFinishedBackgroundTaskExecutions
protected abstract void doRemoveFinishedBackgroundTaskExecutions(List<Long> ids)
-
getBackgroundTaskQueue
protected abstract BlockingQueue<BackgroundTaskExecutionContext> getBackgroundTaskQueue()
-
getBackgroundTaskThreads
protected abstract int getBackgroundTaskThreads()
-
initialize
protected void initialize()
-
instantiateCacheHandler
protected abstract CacheHandlerImplementor instantiateCacheHandler()
-
instantiatePollingTaskHandler
protected abstract PollingTaskHandlerImplementor instantiatePollingTaskHandler()
-
instantiatePushNotificationHandler
protected abstract PushNotificationHandler instantiatePushNotificationHandler()
-
runBackgroundTask
protected void runBackgroundTask(BackgroundTaskExecutionContext task)
-
shouldEnsureDatabaseIsNotLocked
protected abstract boolean shouldEnsureDatabaseIsNotLocked()
-
shouldUnlockDatabase
protected abstract boolean shouldUnlockDatabase()
-
shutdown
protected void shutdown()
-
-