Class SpaceComponentManager
- All Implemented Interfaces:
ISpaceModeListener,Remote,EventListener
The manager handles all space mode transitions and changes the components state according to the space state.
Space states:
-------------------------------------------------------------
- NONE - the initial
state of the space before election.
- PRIMARY - the state of the space after is was
selected as primary.
- BACKUP - the state of the space after it was selected as
backup.
Space components types:
--------------------------------------------------------------
backup components - components that can run on backup spaces.
primary only - components
that can run only on primary spaces.
The following state transitions are handled:
--------------------------------------------------
NONE-->PRIMARY - space becomes primary
after the first election. All components are started.
NONE-->BACKUP - space becomes backup
after the first election. Only the backup components are started.
BACKUP-->PRIMARY - space becomes primary after previously being backup. Only the primary-only components are started, since backup components are already up.
PRIMARY-->BACKUP - in case of a "split-brain" where two spaces are primary at the same time, one of them returns to backup. In this case all the space components are restarted.
- Since:
- 6.0
- Version:
- 1.0
- Author:
- anna
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after space becomes backup.voidafterSpaceModeChange(SpaceMode newMode) Called right after the space mode changes.voidCalled before space becomes backup.voidbeforeSpaceModeChange(SpaceMode newMode) Called right before the space mode changes.
Implementors usually use it to allow specific service initializations.voidclear()getSpace()voidinit()Initialize the component manager with space components.voidInitialize all space componentsvoidRestart space components.voidsetComponentsHandlers(LinkedList<ISpaceComponentsHandler> componentsHandlers) voidvoidsetSpaceMode(SpaceMode spaceMode) voidStart all space components
-
Constructor Details
-
SpaceComponentManager
Constructor.
-
-
Method Details
-
init
Initialize the component manager with space components. Initialize any component that can be run during recovery. Only components that can run on backup are initialized, Primary-only components are initialized later, since they can't run during recovery. -
beforeSpaceModeChange
Description copied from interface:ISpaceModeListenerCalled right before the space mode changes.
Implementors usually use it to allow specific service initializations.- Specified by:
beforeSpaceModeChangein interfaceISpaceModeListener- Parameters:
newMode- the new mode change before it's published.
-
afterSpaceModeChange
Description copied from interface:ISpaceModeListenerCalled right after the space mode changes.
Implementors usually use it to invoke any needed services.- Specified by:
afterSpaceModeChangein interfaceISpaceModeListener- Parameters:
newMode- the new mode change after it was published.
-
afterMovingToBackup
public void afterMovingToBackup()Called after space becomes backup. Any space component that can run on backup is started. (active-when-backup=true) -
beforeMovingToBackup
Called before space becomes backup. Any space component that can run on backup is initialized. (active-when-backup=true) -
initComponents
Initialize all space components -
startComponents
public void startComponents()Start all space components -
restartSpaceComponents
Restart space components. Space state doesn't change -
getComponentsHandlers
- Returns:
- Returns the componentsHandlers.
-
setComponentsHandlers
- Parameters:
componentsHandlers- The componentsHandlers to set.
-
getSpace
- Returns:
- Returns the space.
-
setSpace
- Parameters:
space- The space to set.
-
getSpaceMode
- Returns:
- Returns the spaceMode.
-
setSpaceMode
- Parameters:
spaceMode- The spaceMode to set.
-
clear
public void clear()
-