Class DeferredMutations

java.lang.Object
org.openspaces.core.multicluster.internal.routing.DeferredMutations
All Implemented Interfaces:
AutoCloseable

public final class DeferredMutations extends Object implements AutoCloseable
Work the proxy owes a cluster: mutations that could not be applied yet and will be retried until they land.

Two situations produce them, and they want very different patience:

  • a cluster was briefly unreachable - a few attempts over a few seconds, then give up and report it. Waiting longer just hides the problem;
  • a cluster is quiesced - it is alive and deliberately refusing writes for a maintenance window, which may last minutes. Giving up after three attempts would guarantee the divergence that the retry exists to prevent.
So the policy is chosen from the failure each attempt produces, not fixed when the work is queued: a FailureClassifier.Verdict.QUIESCED verdict switches to the long budget, and an FailureClassifier.Verdict.APPLICATION_ERROR stops immediately, because it will be rejected identically forever.

Bounded, and loudly so

Virtual threads make retrying cheap in threads but not in memory: every pending mutation is a retained object, and a cluster that stays down for an hour would otherwise turn into a heap exhaustion. Past the capacity, work is dropped with a warning and a counter - a cluster missing data is bad, and an unreadable heap dump is worse.
  • Constructor Details

  • Method Details

    • submit

      public boolean submit(String clusterName, String operationName, DeferredMutations.Retryable task, int capacity, RetryPolicy policy)
      Queues one mutation for retry against one cluster.
      Parameters:
      clusterName - the cluster that owes this mutation
      operationName - the operation, for logs
      task - re-applies the mutation; may throw whatever the space throws
      capacity - maximum pending mutations across all clusters
      policy - the starting retry budget, escalated automatically if the cluster is quiesced
      Returns:
      false if the queue was full and the work was dropped
    • pending

      public int pending()
      Mutations still waiting to be applied somewhere.
    • dropped

      public long dropped()
      Mutations discarded because the queue was full - non-zero means a cluster is missing data.
    • flush

      public boolean flush(Duration timeout) throws InterruptedException
      Waits for the queue to drain.
      Returns:
      true if everything landed within the timeout
      Throws:
      InterruptedException
    • close

      public void close()
      Gives queued work a short window to land, then stops. Waiting forever would hang a shutdown; going immediately would discard data silently - so it waits, then says what was left.
      Specified by:
      close in interface AutoCloseable