Class CounterContext.ContextState

  • Enclosing class:
    CounterContext

    public static class CounterContext.ContextState
    extends java.lang.Object
    Helper class to work on contexts (works by iterating over them). A context being abstractly a list of tuple (counterid, clock, count), a ContextState encapsulate a context and a position to one of the tuple. It also allow to create new context iteratively. Note: this is intrinsically a private class intended for use by the methods of CounterContext only. It is however public because it is convenient to create handcrafted context for unit tests.
    • Field Detail

      • context

        public final java.nio.ByteBuffer context
      • headerLength

        public final int headerLength
    • Method Detail

      • allocate

        public static CounterContext.ContextState allocate​(int globalCount,
                                                           int localCount,
                                                           int remoteCount)
        Allocate a new context big enough for globalCount + localCount + remoteCount elements and return the initial corresponding ContextState.
      • isGlobal

        public boolean isGlobal()
      • isLocal

        public boolean isLocal()
      • isRemote

        public boolean isRemote()
      • hasRemaining

        public boolean hasRemaining()
      • moveToNext

        public void moveToNext()
      • reset

        public void reset()
      • getElementIndex

        public int getElementIndex()
      • getCounterId

        public CounterId getCounterId()
      • getClock

        public long getClock()
      • getCount

        public long getCount()
      • writeGlobal

        public void writeGlobal​(CounterId id,
                                long clock,
                                long count)
      • writeLocal

        public void writeLocal​(CounterId id,
                               long clock,
                               long count)
      • writeRemote

        public void writeRemote​(CounterId id,
                                long clock,
                                long count)