@Beta public class HighAvailabilityManagerImpl extends java.lang.Object implements HighAvailabilityManager
Multiple brooklyn nodes can be started to form a single management plane, where one node is
designated master and the others are "warm standbys". On termination or failure of the master,
the standbys deterministically decide which standby should become master (see MasterChooser
).
That standby promotes itself.
The management nodes communicate their health/status via the ManagementPlaneSyncRecordPersister
.
For example, if using ManagementPlaneSyncRecordPersisterToObjectStore
with a shared blobstore or
filesystem/NFS mount, then each management-node periodically writes its state.
This acts as a heartbeat, being read by the other management-nodes.
Promotion to master involves:
RebindManager.rebind(ClassLoader, brooklyn.entity.rebind.RebindExceptionHandler, ManagementNodeState)
to read all persisted entity state, and thus reconstitute the entities.
Future improvements in this area will include brooklyn-managing-brooklyn to decide + promote the standby.
Modifier and Type | Class and Description |
---|---|
static interface |
HighAvailabilityManagerImpl.PromotionListener |
Constructor and Description |
---|
HighAvailabilityManagerImpl(ManagementContextInternal managementContext) |
Modifier and Type | Method and Description |
---|---|
void |
changeMode(HighAvailabilityMode startMode)
changes the mode that this HA server is running in
|
void |
changeMode(HighAvailabilityMode startMode,
boolean preventElectionOnExplicitStandbyMode,
boolean failOnExplicitStandbyModeIfNoMaster) |
void |
disabled()
Indicates that HA is disabled: this node will act as the only management node in this management plane,
and will not persist HA meta-information (meaning other nodes cannot join).
|
ManagementPlaneSyncRecord |
getManagementPlaneSyncState()
Returns a snapshot of the management-plane's current / most-recently-known status.
|
ManagementNodeState |
getNodeState() |
ManagementPlaneSyncRecordPersister |
getPersister() |
long |
getPriority() |
ManagementNodeState |
getTransitionTargetNodeState()
returns the node state this node is trying to be in
|
boolean |
isRunning()
Whether HA mode is operational
|
void |
publishAndCheck(boolean initializing)
invoked manually when initializing, and periodically thereafter
|
HighAvailabilityManagerImpl |
setHeartbeatTimeout(Duration val) |
HighAvailabilityManagerImpl |
setLocalTicker(com.google.common.base.Ticker val)
A ticker that reads in milliseconds, for populating local timestamps.
|
HighAvailabilityManagerImpl |
setMasterChooser(MasterChooser val) |
HighAvailabilityManagerImpl |
setPersister(ManagementPlaneSyncRecordPersister persister) |
HighAvailabilityManagerImpl |
setPollPeriod(Duration val) |
void |
setPriority(long priority)
sets the priority, and publishes it synchronously so it is canonical
|
HighAvailabilityManagerImpl |
setPromotionListener(HighAvailabilityManagerImpl.PromotionListener val) |
HighAvailabilityManagerImpl |
setRemoteTicker(com.google.common.base.Ticker val)
A ticker that reads in milliseconds, for overriding remote timestamps.
|
void |
start(HighAvailabilityMode startMode)
Starts the monitoring of other nodes (and thus potential promotion of this node from standby to master).
|
void |
stop()
Stops this node, then publishes own status (via
ManagementPlaneSyncRecordPersister of ManagementNodeState.TERMINATED . |
java.lang.String |
toString() |
public HighAvailabilityManagerImpl(ManagementContextInternal managementContext)
public HighAvailabilityManagerImpl setPersister(ManagementPlaneSyncRecordPersister persister)
setPersister
in interface HighAvailabilityManager
public ManagementPlaneSyncRecordPersister getPersister()
getPersister
in interface HighAvailabilityManager
public HighAvailabilityManagerImpl setPollPeriod(Duration val)
public HighAvailabilityManagerImpl setMasterChooser(MasterChooser val)
public HighAvailabilityManagerImpl setHeartbeatTimeout(Duration val)
public HighAvailabilityManagerImpl setLocalTicker(com.google.common.base.Ticker val)
public HighAvailabilityManagerImpl setRemoteTicker(com.google.common.base.Ticker val)
If this is supplied, one must also set ManagementPlaneSyncRecordPersisterToObjectStore.allowRemoteTimestampInMemento()
.
public HighAvailabilityManagerImpl setPromotionListener(HighAvailabilityManagerImpl.PromotionListener val)
public boolean isRunning()
HighAvailabilityManager
isRunning
in interface HighAvailabilityManager
public void disabled()
HighAvailabilityManager
Subsequently can expect HighAvailabilityManager.getNodeState()
to be ManagementNodeState.MASTER
and HighAvailabilityManager.getManagementPlaneSyncState()
to show just this one node --
as if it were running HA with just one node --
but HighAvailabilityManager.isRunning()
will return false.
Currently this method is intended to be called early in the lifecycle,
instead of HighAvailabilityManager.start(HighAvailabilityMode)
. It may be an error if
this is called after this HA Manager is started.
disabled
in interface HighAvailabilityManager
public void start(HighAvailabilityMode startMode)
HighAvailabilityManager
When this method returns, the status of this node will be set,
either ManagementNodeState.MASTER
if appropriate
or ManagementNodeState.STANDBY
/ ManagementNodeState.HOT_STANDBY
.
start
in interface HighAvailabilityManager
startMode
- mode to start withpublic void changeMode(HighAvailabilityMode startMode)
HighAvailabilityManager
note it will be an error to HighAvailabilityManager.changeMode(HighAvailabilityMode)
to ManagementNodeState.MASTER
when there is already a master; to promote a node explicitly set its priority higher than
the others and invoke HighAvailabilityManager.changeMode(HighAvailabilityMode)
to a standby mode on the existing master
changeMode
in interface HighAvailabilityManager
@Beta public void changeMode(HighAvailabilityMode startMode, boolean preventElectionOnExplicitStandbyMode, boolean failOnExplicitStandbyModeIfNoMaster)
public void setPriority(long priority)
HighAvailabilityManager
setPriority
in interface HighAvailabilityManager
public long getPriority()
getPriority
in interface HighAvailabilityManager
public void stop()
HighAvailabilityManager
ManagementPlaneSyncRecordPersister
of ManagementNodeState.TERMINATED
.stop
in interface HighAvailabilityManager
public ManagementNodeState getTransitionTargetNodeState()
public ManagementNodeState getNodeState()
getNodeState
in interface HighAvailabilityManager
public ManagementPlaneSyncRecord getManagementPlaneSyncState()
HighAvailabilityManager
This is mainly the nodes and their ManagementNodeSyncRecord
instances,
as known (for this node) or last read (other nodes).
getManagementPlaneSyncState
in interface HighAvailabilityManager
public void publishAndCheck(boolean initializing)
public java.lang.String toString()
toString
in class java.lang.Object