Interface DistributionState
- All Known Subinterfaces:
MutableDistributionState
- All Known Implementing Classes:
DbDistributionState
public interface DistributionState
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceThis visitor can visit pending distributions ofCommandDistributionRecord. -
Method Summary
Modifier and TypeMethodDescriptionvoidforEachContinuationCommand(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.
-
Method Details
-
hasRetriableDistribution
boolean hasRetriableDistribution(long distributionKey) Returns whether there are any retriable distributions for a given key.- Parameters:
distributionKey- the key of the distribution- Returns:
- true if there are retriable distributions for the given key, otherwise false
-
hasPendingDistribution
boolean hasPendingDistribution(long distributionKey) Returns whether there are any pending distributions for a given key.- Parameters:
distributionKey- the key of the distribution- Returns:
- true if there are pending distributions for the given key, otherwise false
-
hasRetriableDistribution
boolean hasRetriableDistribution(long distributionKey, int partition) Returns whether a specific distribution for a specific partition is retriable.- 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
boolean hasPendingDistribution(long distributionKey, int partition) Returns whether a specific distribution for a specific partition is pending.- 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
Returns 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.- Parameters:
distributionKey- the key of the distributionpartition- the partition to distribute to- Returns:
- an new instance of the
CommandDistributionRecord
-
foreachRetriableDistribution
Visits 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.
- Parameters:
visitor- Each retriable distribution is visited by this visitor
-
getNextQueuedDistributionKey
Returns the distribution key at the head of the queue for the given partition.- 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
Returns the queue for the given distribution or an empty optional if this distribution was not queued. -
hasQueuedDistributions
Returns whether there are any queued distributions for the given queue.- Parameters:
queue- the queue to look up- Returns:
- true if there are queued distributions for the given queue, otherwise false
-
forEachContinuationCommand
void forEachContinuationCommand(String queue, DistributionState.ContinuationCommandVisitor consumer) Visits each continuation command registered for the given queue. -
getContinuationRecord
Returns the continuation command for the given key and queue or null if no such command exists.
-