Class SharedData


  • public class SharedData
    extends Object
    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.

    • Constructor Detail

      • SharedData

        public SharedData​(io.vertx.core.shareddata.SharedData delegate)
    • Method Detail

      • getDelegate

        public io.vertx.core.shareddata.SharedData getDelegate()
      • hashCode

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

        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 instance produced by the operation
      • getAsyncMap

        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 instance produced by the operation
      • getLocalAsyncMap

        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 instance produced by the operation
      • getLock

        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
      • getLockWithTimeout

        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
      • getLocalLock

        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
      • getLocalLockWithTimeout

        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
      • getCounter

        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
      • getLocalCounter

        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
      • getLocalMap

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

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