@Beta
public interface HighAvailabilityManager
ManagementPlaneSyncRecordPersister
) to detect
if the current master has failed or stopped. If so, then deterministically chooses a new master.
If that master is self, then promotes.
Users are not expected to implement this class, or to call methods on it directly.
Expected lifecycle of methods calls on this is:
Modifier and Type | Method and Description |
---|---|
void |
changeMode(HighAvailabilityMode mode)
changes the mode that this HA server is running in
|
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 |
getLastManagementPlaneSyncRecord()
Returns a snapshot of the management-plane's current / most-recently-known status,
as last read from
loadManagementPlaneSyncRecord(boolean) , or null if none read. |
long |
getLastStateChange()
The time in milliseconds when the state was last changed.
|
ManagementPlaneSyncRecord |
getManagementPlaneSyncState()
Deprecated.
since 0.7.0 use
getLastManagementPlaneSyncRecord() or loadManagementPlaneSyncRecord(boolean)
to be explicit about the source. |
java.util.Map<java.lang.String,java.lang.Object> |
getMetrics()
Returns a collection of metrics
|
ManagementNodeState |
getNodeState() |
ManagementPlaneSyncRecordPersister |
getPersister() |
long |
getPriority() |
boolean |
isRunning()
Whether HA mode is operational
|
ManagementPlaneSyncRecord |
loadManagementPlaneSyncRecord(boolean useLocalKnowledgeForThisNode) |
void |
publishClearNonMaster()
deletes non-master node records; active nodes (including this) will republish,
so this provides a simple way to clean out the cache of dead brooklyn nodes
|
HighAvailabilityManager |
setPersister(ManagementPlaneSyncRecordPersister persister) |
void |
setPriority(long priority)
sets the priority, and publishes it synchronously so it is canonical
|
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 . |
ManagementNodeState getNodeState()
long getLastStateChange()
HighAvailabilityManager setPersister(ManagementPlaneSyncRecordPersister persister)
persister
- @Beta void disabled()
Subsequently can expect getNodeState()
to be ManagementNodeState.MASTER
and loadManagementPlaneSyncRecord(boolean)
to show just this one node --
as if it were running HA with just one node --
but isRunning()
will return false.
Currently this method is intended to be called early in the lifecycle,
instead of start(HighAvailabilityMode)
. It may be an error if
this is called after this HA Manager is started.
boolean isRunning()
void start(HighAvailabilityMode startMode)
When this method returns, the status of this node will be set,
either ManagementNodeState.MASTER
if appropriate
or ManagementNodeState.STANDBY
/ ManagementNodeState.HOT_STANDBY
/ ManagementNodeState.HOT_BACKUP
.
startMode
- mode to start withjava.lang.IllegalStateException
- if current state of the management-plane doesn't match that desired by startMode
void stop()
ManagementPlaneSyncRecordPersister
of ManagementNodeState.TERMINATED
.void changeMode(HighAvailabilityMode mode)
note it will be an error to 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 changeMode(HighAvailabilityMode)
to a standby mode on the existing master
void setPriority(long priority)
long getPriority()
@Beta void publishClearNonMaster()
ManagementPlaneSyncRecord getLastManagementPlaneSyncRecord()
loadManagementPlaneSyncRecord(boolean)
, or null if none read.ManagementPlaneSyncRecord getManagementPlaneSyncState()
getLastManagementPlaneSyncRecord()
or loadManagementPlaneSyncRecord(boolean)
to be explicit about the source.ManagementPlaneSyncRecord loadManagementPlaneSyncRecord(boolean useLocalKnowledgeForThisNode)
useLocalKnowledgeForThisNode
- - if true, the record for this mgmt node will be replaced with the
actual current status known in this JVM (may be more recent than what is persisted);
for most purposes there is little difference but in some cases the local node being updated
may be explicitly wanted or not wantedManagementPlaneSyncRecordPersister getPersister()
java.util.Map<java.lang.String,java.lang.Object> getMetrics()