Class SharedData

java.lang.Object
io.vertx.mutiny.core.shareddata.SharedData
All Implemented Interfaces:
MutinyDelegate

public class SharedData extends Object implements MutinyDelegate
Shared data allows you to share data safely between different parts of your application in a safe way.

Shared data provides:

  • synchronous shared maps (local)
  • asynchronous maps (local or cluster-wide)
  • asynchronous locks (local or cluster-wide)
  • asynchronous counters (local or cluster-wide)

WARNING: In clustered mode, asynchronous maps/locks/counters rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous maps/locks/counters operations can be much higher in clustered than in local mode.

Please see the documentation for more information.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • SharedData

      public SharedData(io.vertx.core.shareddata.SharedData delegate)
    • SharedData

      public SharedData(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.shareddata.SharedData getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getClusterWideMap

      @CheckReturnValue public <K, V> io.smallrye.mutiny.Uni<AsyncMap<K,V>> getClusterWideMap(String name)
      Get the cluster wide map with the specified name. The map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the map
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getClusterWideMapAndAwait

      public <K, V> AsyncMap<K,V> getClusterWideMapAndAwait(String name)
      Blocking variant of getClusterWideMap(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the map
      Returns:
      the AsyncMap<K,V> instance produced by the operation.
    • getClusterWideMapAndForget

      public <K, V> void getClusterWideMapAndForget(String name)
      Variant of getClusterWideMap(String) that ignores the result of the operation.

      This method subscribes on the result of getClusterWideMap(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getClusterWideMap(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the map
    • getAsyncMap

      @CheckReturnValue public <K, V> io.smallrye.mutiny.Uni<AsyncMap<K,V>> getAsyncMap(String name)
      Get the AsyncMap with the specified name. When clustered, the map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.

      WARNING: In clustered mode, asynchronous shared maps rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous shared maps operations can be much higher in clustered than in local mode.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the map
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getAsyncMapAndAwait

      public <K, V> AsyncMap<K,V> getAsyncMapAndAwait(String name)
      Blocking variant of getAsyncMap(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the map
      Returns:
      the AsyncMap<K,V> instance produced by the operation.
    • getAsyncMapAndForget

      public <K, V> void getAsyncMapAndForget(String name)
      Variant of getAsyncMap(String) that ignores the result of the operation.

      This method subscribes on the result of getAsyncMap(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getAsyncMap(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the map
    • getLocalAsyncMap

      @CheckReturnValue public <K, V> io.smallrye.mutiny.Uni<AsyncMap<K,V>> getLocalAsyncMap(String name)
      Get the AsyncMap with the specified name.

      When clustered, the map is NOT accessible to all nodes in the cluster. Only the instance which created the map can put and retrieve data from this map.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the map
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLocalAsyncMapAndAwait

      public <K, V> AsyncMap<K,V> getLocalAsyncMapAndAwait(String name)
      Blocking variant of getLocalAsyncMap(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the map
      Returns:
      the AsyncMap<K,V> instance produced by the operation.
    • getLocalAsyncMapAndForget

      public <K, V> void getLocalAsyncMapAndForget(String name)
      Variant of getLocalAsyncMap(String) that ignores the result of the operation.

      This method subscribes on the result of getLocalAsyncMap(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLocalAsyncMap(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the map
    • getLock

      @CheckReturnValue public io.smallrye.mutiny.Uni<Lock> getLock(String name)
      Get an asynchronous lock with the specified name. The lock will be passed to the handler when it is available.

      In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the lock
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLockAndAwait

      public Lock getLockAndAwait(String name)
      Blocking variant of getLock(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the lock
      Returns:
      the Lock instance produced by the operation.
    • getLockAndForget

      public void getLockAndForget(String name)
      Variant of getLock(String) that ignores the result of the operation.

      This method subscribes on the result of getLock(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLock(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the lock
    • getLockWithTimeout

      @CheckReturnValue public io.smallrye.mutiny.Uni<Lock> getLockWithTimeout(String name, long timeout)
      Like getLock(java.lang.String) but specifying a timeout. If the lock is not obtained within the timeout a failure will be sent to the handler.

      In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLockWithTimeoutAndAwait

      public Lock getLockWithTimeoutAndAwait(String name, long timeout)
      Blocking variant of getLockWithTimeout(String,long).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
      Returns:
      the Lock instance produced by the operation.
    • getLockWithTimeoutAndForget

      public void getLockWithTimeoutAndForget(String name, long timeout)
      Variant of getLockWithTimeout(String,long) that ignores the result of the operation.

      This method subscribes on the result of getLockWithTimeout(String,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLockWithTimeout(String,long) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
    • getLocalLock

      @CheckReturnValue public io.smallrye.mutiny.Uni<Lock> getLocalLock(String name)
      Get an asynchronous local lock with the specified name. The lock will be passed to the handler when it is available.

      In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the lock
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLocalLockAndAwait

      public Lock getLocalLockAndAwait(String name)
      Blocking variant of getLocalLock(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the lock
      Returns:
      the Lock instance produced by the operation.
    • getLocalLockAndForget

      public void getLocalLockAndForget(String name)
      Variant of getLocalLock(String) that ignores the result of the operation.

      This method subscribes on the result of getLocalLock(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLocalLock(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the lock
    • getLocalLockWithTimeout

      @CheckReturnValue public io.smallrye.mutiny.Uni<Lock> getLocalLockWithTimeout(String name, long timeout)
      Like getLocalLock(java.lang.String) but specifying a timeout. If the lock is not obtained within the timeout a failure will be sent to the handler.

      In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLocalLockWithTimeoutAndAwait

      public Lock getLocalLockWithTimeoutAndAwait(String name, long timeout)
      Blocking variant of getLocalLockWithTimeout(String,long).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
      Returns:
      the Lock instance produced by the operation.
    • getLocalLockWithTimeoutAndForget

      public void getLocalLockWithTimeoutAndForget(String name, long timeout)
      Variant of getLocalLockWithTimeout(String,long) that ignores the result of the operation.

      This method subscribes on the result of getLocalLockWithTimeout(String,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLocalLockWithTimeout(String,long) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the lock
      timeout - the timeout in ms
    • getCounter

      @CheckReturnValue public io.smallrye.mutiny.Uni<Counter> getCounter(String name)
      Get an asynchronous counter. The counter will be passed to the handler.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the counter.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getCounterAndAwait

      public Counter getCounterAndAwait(String name)
      Blocking variant of getCounter(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the counter.
      Returns:
      the Counter instance produced by the operation.
    • getCounterAndForget

      public void getCounterAndForget(String name)
      Variant of getCounter(String) that ignores the result of the operation.

      This method subscribes on the result of getCounter(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getCounter(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the counter.
    • getLocalCounter

      @CheckReturnValue public io.smallrye.mutiny.Uni<Counter> getLocalCounter(String name)
      Get an asynchronous local counter. The counter will be passed to the handler.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      name - the name of the counter.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getLocalCounterAndAwait

      public Counter getLocalCounterAndAwait(String name)
      Blocking variant of getLocalCounter(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      name - the name of the counter.
      Returns:
      the Counter instance produced by the operation.
    • getLocalCounterAndForget

      public void getLocalCounterAndForget(String name)
      Variant of getLocalCounter(String) that ignores the result of the operation.

      This method subscribes on the result of getLocalCounter(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getLocalCounter(String) but you don't need to compose it with other operations.

      Parameters:
      name - the name of the counter.
    • getLocalMap

      public <K, V> LocalMap<K,V> getLocalMap(String name)
      Parameters:
      name - the name of the map
      Returns:
      the map
    • newInstance

      public static SharedData newInstance(io.vertx.core.shareddata.SharedData arg)