Class DbDistributionState
java.lang.Object
io.camunda.zeebe.engine.state.distribution.DbDistributionState
- All Implemented Interfaces:
DistributionState,MutableDistributionState
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.camunda.zeebe.engine.state.immutable.DistributionState
DistributionState.ContinuationCommandVisitor, DistributionState.PendingDistributionVisitor -
Constructor Summary
ConstructorsConstructorDescriptionDbDistributionState(ZeebeDb<ZbColumnFamilies> zeebeDb, TransactionContext transactionContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommandDistribution(long distributionKey, CommandDistributionRecord commandDistributionRecord) Adds a distribution to the statevoidaddContinuationCommand(long continuationKey, CommandDistributionRecord record) voidaddPendingDistribution(long distributionKey, int partition) Adds a pending distribution to the statevoidaddRetriableDistribution(long distributionKey, int partition) Adds a retriable distribution to the statevoidenqueueCommandDistribution(String queue, long distributionKey, int partition) Adds a distribution to the given queue for the given partition,voidforEachContinuationCommand(String queue, DistributionState.ContinuationCommandVisitor consumer) Visits each continuation command registered for the given queue.voidVisits each persisted retriable distribution, providing both the key of that distribution and theCommandDistributionRecord.getCommandDistributionRecord(long distributionKey, int partition) Returns theCommandDistributionRecordfor the given distribution key.getContinuationRecord(String queue, long key) Returns the continuation command for the given key and queue or null if no such command exists.getNextQueuedDistributionKey(String queue, int partition) Returns the distribution key at the head of the queue for the given partition.getQueueIdForDistribution(long distributionKey) Returns the queue for the given distribution or an empty optional if this distribution was not queued.booleanhasPendingDistribution(long distributionKey) Returns whether there are any pending distributions for a given key.booleanhasPendingDistribution(long distributionKey, int partition) Returns whether a specific distribution for a specific partition is pending.booleanhasQueuedDistributions(String queue) Returns whether there are any queued distributions for the given queue.booleanhasRetriableDistribution(long distributionKey) Returns whether there are any retriable distributions for a given key.booleanhasRetriableDistribution(long distributionKey, int partition) Returns whether a specific distribution for a specific partition is retriable.voidremoveCommandDistribution(long distributionKey) Removed a distribution from the statevoidremoveContinuationCommand(long continuationKey, String queue) voidremovePendingDistribution(long distributionKey, int partition) Removes a pending distribution from the statevoidremoveQueuedDistribution(String queue, int partition, long distributionKey) Removes the queued distribution from the queuevoidremoveRetriableDistribution(long distributionKey, int partition) Removes a retriable distribution from the state
-
Constructor Details
-
DbDistributionState
public DbDistributionState(ZeebeDb<ZbColumnFamilies> zeebeDb, TransactionContext transactionContext)
-
-
Method Details
-
addCommandDistribution
public void addCommandDistribution(long distributionKey, CommandDistributionRecord commandDistributionRecord) Description copied from interface:MutableDistributionStateAdds a distribution to the state- Specified by:
addCommandDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the distributioncommandDistributionRecord- the distribution record that needs to be stored
-
removeCommandDistribution
public void removeCommandDistribution(long distributionKey) Description copied from interface:MutableDistributionStateRemoved a distribution from the state- Specified by:
removeCommandDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the distribution that will be removed
-
addRetriableDistribution
public void addRetriableDistribution(long distributionKey, int partition) Description copied from interface:MutableDistributionStateAdds a retriable distribution to the state- Specified by:
addRetriableDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the distributionpartition- the partition for which the distribution is retriable
-
removeRetriableDistribution
public void removeRetriableDistribution(long distributionKey, int partition) Description copied from interface:MutableDistributionStateRemoves a retriable distribution from the state- Specified by:
removeRetriableDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the retriable distribution that will be removedpartition- the partition of the retriable distribution that will be removed
-
addPendingDistribution
public void addPendingDistribution(long distributionKey, int partition) Description copied from interface:MutableDistributionStateAdds a pending distribution to the state- Specified by:
addPendingDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the distributionpartition- the partition for which the distribution is pending
-
removePendingDistribution
public void removePendingDistribution(long distributionKey, int partition) Description copied from interface:MutableDistributionStateRemoves a pending distribution from the state- Specified by:
removePendingDistributionin interfaceMutableDistributionState- Parameters:
distributionKey- the key of the pending distribution that will be removedpartition- the partition of the pending distribution that will be removed
-
enqueueCommandDistribution
Description copied from interface:MutableDistributionStateAdds a distribution to the given queue for the given partition,- Specified by:
enqueueCommandDistributionin interfaceMutableDistributionState- Parameters:
queue- the queue to which the distribution should be addeddistributionKey- the key of the distributionpartition- the partition for which the distribution is queued
-
removeQueuedDistribution
Description copied from interface:MutableDistributionStateRemoves the queued distribution from the queue- Specified by:
removeQueuedDistributionin interfaceMutableDistributionState
-
addContinuationCommand
- Specified by:
addContinuationCommandin interfaceMutableDistributionState
-
removeContinuationCommand
- Specified by:
removeContinuationCommandin interfaceMutableDistributionState
-
hasRetriableDistribution
public boolean hasRetriableDistribution(long distributionKey) Description copied from interface:DistributionStateReturns whether there are any retriable distributions for a given key.- Specified by:
hasRetriableDistributionin interfaceDistributionState- Parameters:
distributionKey- the key of the distribution- Returns:
- true if there are retriable distributions for the given key, otherwise false
-
hasPendingDistribution
public boolean hasPendingDistribution(long distributionKey) Description copied from interface:DistributionStateReturns whether there are any pending distributions for a given key.- Specified by:
hasPendingDistributionin interfaceDistributionState- Parameters:
distributionKey- the key of the distribution- Returns:
- true if there are pending distributions for the given key, otherwise false
-
hasRetriableDistribution
public boolean hasRetriableDistribution(long distributionKey, int partition) Description copied from interface:DistributionStateReturns whether a specific distribution for a specific partition is retriable.- Specified by:
hasRetriableDistributionin interfaceDistributionState- Parameters:
distributionKey- the key of the distribution that may be retriablepartition- the id of the partition for which the distribution might be retriable- Returns:
trueif the specific retriable distribution exists, otherwisefalse.
-
hasPendingDistribution
public boolean hasPendingDistribution(long distributionKey, int partition) Description copied from interface:DistributionStateReturns whether a specific distribution for a specific partition is pending.- Specified by:
hasPendingDistributionin interfaceDistributionState- Parameters:
distributionKey- the key of the distribution that may be pendingpartition- the id of the partition for which the distribution might be pending- Returns:
trueif the specific pending distribution exists, otherwisefalse.
-
getCommandDistributionRecord
Description copied from interface:DistributionStateReturns theCommandDistributionRecordfor the given distribution key. This method takes a partition id. This is only used to set the partition property in theCommandDistributionRecord. Doing so allows us to return a whole record, without the need to remember setting the partition everytime this method is called.- Specified by:
getCommandDistributionRecordin interfaceDistributionState- Parameters:
distributionKey- the key of the distributionpartition- the partition to distribute to- Returns:
- an new instance of the
CommandDistributionRecord
-
foreachRetriableDistribution
Description copied from interface:DistributionStateVisits each persisted retriable distribution, providing both the key of that distribution and theCommandDistributionRecord.Note that a new instance of the record is provided for each visit, so the visitor does not have to make a copy when long term access is needed.
- Specified by:
foreachRetriableDistributionin interfaceDistributionState- Parameters:
visitor- Each retriable distribution is visited by this visitor
-
getNextQueuedDistributionKey
Description copied from interface:DistributionStateReturns the distribution key at the head of the queue for the given partition.- Specified by:
getNextQueuedDistributionKeyin interfaceDistributionState- Parameters:
queue- the queue to look uppartition- the partition id within the queue- Returns:
- the distribution key at the head of the queues or an empty optional if there is no queued distribution for that queue and partition.
-
getQueueIdForDistribution
Description copied from interface:DistributionStateReturns the queue for the given distribution or an empty optional if this distribution was not queued.- Specified by:
getQueueIdForDistributionin interfaceDistributionState
-
hasQueuedDistributions
Description copied from interface:DistributionStateReturns whether there are any queued distributions for the given queue.- Specified by:
hasQueuedDistributionsin interfaceDistributionState- Parameters:
queue- the queue to look up- Returns:
- true if there are queued distributions for the given queue, otherwise false
-
forEachContinuationCommand
public void forEachContinuationCommand(String queue, DistributionState.ContinuationCommandVisitor consumer) Description copied from interface:DistributionStateVisits each continuation command registered for the given queue.- Specified by:
forEachContinuationCommandin interfaceDistributionState
-
getContinuationRecord
Description copied from interface:DistributionStateReturns the continuation command for the given key and queue or null if no such command exists.- Specified by:
getContinuationRecordin interfaceDistributionState
-