Class DbDistributionState

java.lang.Object
io.camunda.zeebe.engine.state.distribution.DbDistributionState
All Implemented Interfaces:
DistributionState, MutableDistributionState

public class DbDistributionState extends Object implements MutableDistributionState
  • Constructor Details

  • Method Details

    • addCommandDistribution

      public void addCommandDistribution(long distributionKey, CommandDistributionRecord commandDistributionRecord)
      Description copied from interface: MutableDistributionState
      Adds a distribution to the state
      Specified by:
      addCommandDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the distribution
      commandDistributionRecord - the distribution record that needs to be stored
    • removeCommandDistribution

      public void removeCommandDistribution(long distributionKey)
      Description copied from interface: MutableDistributionState
      Removed a distribution from the state
      Specified by:
      removeCommandDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the distribution that will be removed
    • addRetriableDistribution

      public void addRetriableDistribution(long distributionKey, int partition)
      Description copied from interface: MutableDistributionState
      Adds a retriable distribution to the state
      Specified by:
      addRetriableDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the distribution
      partition - the partition for which the distribution is retriable
    • removeRetriableDistribution

      public void removeRetriableDistribution(long distributionKey, int partition)
      Description copied from interface: MutableDistributionState
      Removes a retriable distribution from the state
      Specified by:
      removeRetriableDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the retriable distribution that will be removed
      partition - the partition of the retriable distribution that will be removed
    • addPendingDistribution

      public void addPendingDistribution(long distributionKey, int partition)
      Description copied from interface: MutableDistributionState
      Adds a pending distribution to the state
      Specified by:
      addPendingDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the distribution
      partition - the partition for which the distribution is pending
    • removePendingDistribution

      public void removePendingDistribution(long distributionKey, int partition)
      Description copied from interface: MutableDistributionState
      Removes a pending distribution from the state
      Specified by:
      removePendingDistribution in interface MutableDistributionState
      Parameters:
      distributionKey - the key of the pending distribution that will be removed
      partition - the partition of the pending distribution that will be removed
    • enqueueCommandDistribution

      public void enqueueCommandDistribution(String queue, long distributionKey, int partition)
      Description copied from interface: MutableDistributionState
      Adds a distribution to the given queue for the given partition,
      Specified by:
      enqueueCommandDistribution in interface MutableDistributionState
      Parameters:
      queue - the queue to which the distribution should be added
      distributionKey - the key of the distribution
      partition - the partition for which the distribution is queued
    • removeQueuedDistribution

      public void removeQueuedDistribution(String queue, int partition, long distributionKey)
      Description copied from interface: MutableDistributionState
      Removes the queued distribution from the queue
      Specified by:
      removeQueuedDistribution in interface MutableDistributionState
    • addContinuationCommand

      public void addContinuationCommand(long continuationKey, CommandDistributionRecord record)
      Specified by:
      addContinuationCommand in interface MutableDistributionState
    • removeContinuationCommand

      public void removeContinuationCommand(long continuationKey, String queue)
      Specified by:
      removeContinuationCommand in interface MutableDistributionState
    • hasRetriableDistribution

      public boolean hasRetriableDistribution(long distributionKey)
      Description copied from interface: DistributionState
      Returns whether there are any retriable distributions for a given key.
      Specified by:
      hasRetriableDistribution in interface DistributionState
      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: DistributionState
      Returns whether there are any pending distributions for a given key.
      Specified by:
      hasPendingDistribution in interface DistributionState
      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: DistributionState
      Returns whether a specific distribution for a specific partition is retriable.
      Specified by:
      hasRetriableDistribution in interface DistributionState
      Parameters:
      distributionKey - the key of the distribution that may be retriable
      partition - the id of the partition for which the distribution might be retriable
      Returns:
      true if the specific retriable distribution exists, otherwise false.
    • hasPendingDistribution

      public boolean hasPendingDistribution(long distributionKey, int partition)
      Description copied from interface: DistributionState
      Returns whether a specific distribution for a specific partition is pending.
      Specified by:
      hasPendingDistribution in interface DistributionState
      Parameters:
      distributionKey - the key of the distribution that may be pending
      partition - the id of the partition for which the distribution might be pending
      Returns:
      true if the specific pending distribution exists, otherwise false.
    • getCommandDistributionRecord

      public CommandDistributionRecord getCommandDistributionRecord(long distributionKey, int partition)
      Description copied from interface: DistributionState
      Returns the CommandDistributionRecord for the given distribution key. This method takes a partition id. This is only used to set the partition property in the CommandDistributionRecord. Doing so allows us to return a whole record, without the need to remember setting the partition everytime this method is called.
      Specified by:
      getCommandDistributionRecord in interface DistributionState
      Parameters:
      distributionKey - the key of the distribution
      partition - the partition to distribute to
      Returns:
      an new instance of the CommandDistributionRecord
    • foreachRetriableDistribution

      public void foreachRetriableDistribution(DistributionState.PendingDistributionVisitor visitor)
      Description copied from interface: DistributionState
      Visits each persisted retriable distribution, providing both the key of that distribution and the CommandDistributionRecord.

      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:
      foreachRetriableDistribution in interface DistributionState
      Parameters:
      visitor - Each retriable distribution is visited by this visitor
    • getNextQueuedDistributionKey

      public Optional<Long> getNextQueuedDistributionKey(String queue, int partition)
      Description copied from interface: DistributionState
      Returns the distribution key at the head of the queue for the given partition.
      Specified by:
      getNextQueuedDistributionKey in interface DistributionState
      Parameters:
      queue - the queue to look up
      partition - 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

      public Optional<String> getQueueIdForDistribution(long distributionKey)
      Description copied from interface: DistributionState
      Returns the queue for the given distribution or an empty optional if this distribution was not queued.
      Specified by:
      getQueueIdForDistribution in interface DistributionState
    • hasQueuedDistributions

      public boolean hasQueuedDistributions(String queue)
      Description copied from interface: DistributionState
      Returns whether there are any queued distributions for the given queue.
      Specified by:
      hasQueuedDistributions in interface DistributionState
      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: DistributionState
      Visits each continuation command registered for the given queue.
      Specified by:
      forEachContinuationCommand in interface DistributionState
    • getContinuationRecord

      public CommandDistributionRecord getContinuationRecord(String queue, long key)
      Description copied from interface: DistributionState
      Returns the continuation command for the given key and queue or null if no such command exists.
      Specified by:
      getContinuationRecord in interface DistributionState