Class KeyAccountingUnit<K>

  • Type Parameters:
    K - the type of key

    public class KeyAccountingUnit<K>
    extends Object
    Key accounting unit holds the current in-flight key and tracks the corresponding ongoing records, which is used to preserve the ordering of independent chained StateFuture.
    • Constructor Detail

      • KeyAccountingUnit

        public KeyAccountingUnit​(int initCapacity)
    • Method Detail

      • occupy

        public boolean occupy​(Object record,
                              K key)
        Occupy a key for processing, the subsequent records with the same key would be blocked until the previous key release.
        Returns:
        true if no one is occupying this key, and this record succeeds to take it.
      • release

        public void release​(Object record,
                            K key)
        Release a key, which is invoked when a RecordContext is released.
      • occupiedCount

        @VisibleForTesting
        public int occupiedCount()