Class ActivationSequenceStateMachine
- java.lang.Object
-
- org.apache.activemq.artemis.core.server.impl.quorum.ActivationSequenceStateMachine
-
public final class ActivationSequenceStateMachine extends Object
This class contains the activation sequence logic of the pluggable quorum vote: it should be used byReplicationBackupActivationandReplicationPrimaryActivationto coordinate for replication.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanawaitNextCommittedActivationSequence(org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, String coordinatedLockAndNodeId, long activationSequence, long timeoutMills, org.slf4j.Logger logger)It wait untiltimeoutMillis mshas passed or the coordinated activation sequence has progressed enoughstatic voidensureSequentialAccessToNodeData(String serverDescription, NodeManager nodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, org.slf4j.Logger logger)This is going to increment the coordinated activation sequence and the local activation sequence (usingNodeManager.writeNodeActivationSequence(long)) while holding the live lock, failing with some exception otherwise.static org.apache.activemq.artemis.quorum.DistributedLocktryActivate(NodeManager nodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, org.slf4j.Logger logger)It loops if the data of the broker is still valuable, but cannot become live.
-
-
-
Method Detail
-
tryActivate
public static org.apache.activemq.artemis.quorum.DistributedLock tryActivate(NodeManager nodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, org.slf4j.Logger logger) throws InterruptedException, ExecutionException, TimeoutException, org.apache.activemq.artemis.quorum.UnavailableStateException
It loops if the data of the broker is still valuable, but cannot become live. It loops (temporarily) if data is in sync or can auto-repair, but cannot yet acquire the live lock.It stops loop and return:
null: if data is stale (and there are no rights to become live)!=null: if data is in sync/repaired and theDistributedLockis correctly acquired
After successfully returning from this method ie not null return value, a broker should use
ensureSequentialAccessToNodeData(java.lang.String, org.apache.activemq.artemis.core.server.NodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager, org.slf4j.Logger)to complete the activation and guarantee the initial not-replicated ownership of data.- Throws:
InterruptedExceptionExecutionExceptionTimeoutExceptionorg.apache.activemq.artemis.quorum.UnavailableStateException
-
awaitNextCommittedActivationSequence
public static boolean awaitNextCommittedActivationSequence(org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, String coordinatedLockAndNodeId, long activationSequence, long timeoutMills, org.slf4j.Logger logger) throws ExecutionException, InterruptedException, TimeoutException, org.apache.activemq.artemis.quorum.UnavailableStateExceptionIt wait untiltimeoutMillis mshas passed or the coordinated activation sequence has progressed enough- Throws:
ExecutionExceptionInterruptedExceptionTimeoutExceptionorg.apache.activemq.artemis.quorum.UnavailableStateException
-
ensureSequentialAccessToNodeData
public static void ensureSequentialAccessToNodeData(String serverDescription, NodeManager nodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager distributedManager, org.slf4j.Logger logger) throws ActiveMQException, InterruptedException, org.apache.activemq.artemis.quorum.UnavailableStateException, ExecutionException, TimeoutException
This is going to increment the coordinated activation sequence and the local activation sequence (usingNodeManager.writeNodeActivationSequence(long)) while holding the live lock, failing with some exception otherwise.
This must be used while holding a live lock to ensure not-exclusive ownership of data ie can be both used while loosing connectivity with a replica or after successfully
tryActivate(org.apache.activemq.artemis.core.server.NodeManager, org.apache.activemq.artemis.quorum.DistributedPrimitiveManager, org.slf4j.Logger).- Throws:
ActiveMQExceptionInterruptedExceptionorg.apache.activemq.artemis.quorum.UnavailableStateExceptionExecutionExceptionTimeoutException
-
-