Class LeaderSelectorHandler
java.lang.Object
com.gigaspaces.cluster.activeelection.LeaderSelectorHandler
- All Implemented Interfaces:
LeaderSelector
- Direct Known Subclasses:
LusBasedSelectorHandler
Provides runtime primary/backup selection in cluster topologies.
- Since:
- 6.0
- Version:
- 1.0
- Author:
- Igor Goldenberg
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Throwableprotected ConsolidatedLoggerprotected PrimarySpaceModeListenersprotected SpaceImplprotected Stringprotected SpaceMode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListenerAndNotify(ISpaceModeListener listener) Add listener for space availability and notify the listener with the current space modeprotected voidafterSpaceModeChange(SpaceMode newMode) Notify the listeners about the eventprotected voidbeforeSpaceModeChange(SpaceMode newMode) Notify the listeners about the eventbooleancompareAndRegister(SpaceMode spaceMode, ISpaceModeListener listener) Checks if space mode equals given mode.protected voiddispatchBeforeEventToRemoteListeners(Queue<ISpaceModeListener> remoteListeners, SpaceMode newMode) voidvoidbooleanprotected voidChange space mode to backupprotected voidChange space mode to primaryprotected voidChange space state to UNHEALTHY, so it is redeployedvoidremoveListener(ISpaceModeListener listener) Remove listener for space availabilityvoidsetLastError(Throwable lastError) voidsetSpaceMode(SpaceMode spaceMode) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.gigaspaces.cluster.activeelection.LeaderSelector
getPrimaryMemberName, select, terminate
-
Field Details
-
_logger
-
_spaceMember
-
_space
-
_primarySpaceModeListeners
-
_spaceMode
-
_lastError
-
-
Constructor Details
-
LeaderSelectorHandler
public LeaderSelectorHandler()
-
-
Method Details
-
initialize
- Throws:
Exception
-
isPrimary
public boolean isPrimary()- Specified by:
isPrimaryin interfaceLeaderSelector- Returns:
trueif the Space is primary, otherwise the space in backup mode.
-
beforeSpaceModeChange
Notify the listeners about the event -
afterSpaceModeChange
Notify the listeners about the event -
dispatchBeforeEventToRemoteListeners
protected void dispatchBeforeEventToRemoteListeners(Queue<ISpaceModeListener> remoteListeners, SpaceMode newMode) -
moveToPrimary
protected void moveToPrimary()Change space mode to primary -
moveToBackup
protected void moveToBackup()Change space mode to backup -
moveToUnusable
protected void moveToUnusable()Change space state to UNHEALTHY, so it is redeployed -
addListenerAndNotify
Add listener for space availability and notify the listener with the current space mode- Throws:
RemoteException
-
removeListener
Remove listener for space availability -
setSpaceMode
-
getSpaceMode
-
compareAndRegister
Checks if space mode equals given mode. If true - registers the given listener to election events. Otherwise returns false. -
getLastError
- Specified by:
getLastErrorin interfaceLeaderSelector
-
setLastError
- Specified by:
setLastErrorin interfaceLeaderSelector
-
forceMoveToPrimary
- Throws:
RemoteException
-