Interface WeakCounter


  • public interface WeakCounter
    A weak consistent counter interface.

    This interface represents a weak counter in the way that the write operations does not return a consistent results. In this way, all the writes return a CompletableFuture.

    Note: the reset operation is not atomic.

    Since:
    9.0
    Author:
    Pedro Ruivo
    • Method Detail

      • getName

        java.lang.String getName()
        Returns:
        The counter name.
      • getValue

        long getValue()
        It returns the counter's value.

        This value may be not the mot up-to-data value.

        Returns:
        The counter's value.
      • increment

        default java.util.concurrent.CompletableFuture<java.lang.Void> increment()
        Increments the counter.
      • decrement

        default java.util.concurrent.CompletableFuture<java.lang.Void> decrement()
        Decrements the counter.
      • add

        java.util.concurrent.CompletableFuture<java.lang.Void> add​(long delta)
        Adds the given value to the new value.
        Parameters:
        delta - the value to add.
      • reset

        java.util.concurrent.CompletableFuture<java.lang.Void> reset()
        Resets the counter to its initial value.
      • remove

        java.util.concurrent.CompletableFuture<java.lang.Void> remove()
        It removes this counter from the cluster.

        Note that it doesn't remove the counter from the CounterManager. If you want to remove the counter from the CounterManager use CounterManager.remove(String).

        Returns:
        The CompletableFuture that is completed when the counter is removed from the cluster.