io.vertx.core.shareddata

## Interface SharedData

-     public interface SharedData

  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.
  Author:
    Tim Fox

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> void` | `getAsyncMap(String name, Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)` Get the `AsyncMap` with the specified name.
    `<K,V> void` | `getClusterWideMap(String name, Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)` Get the cluster wide map with the specified name.
    `void` | `getCounter(String name, Handler<AsyncResult<Counter>> resultHandler)` Get an asynchronous counter.
    `<K,V> void` | `getLocalAsyncMap(String name, Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)` Get the `AsyncMap` with the specified name.
    `void` | `getLocalCounter(String name, Handler<AsyncResult<Counter>> resultHandler)` Get an asynchronous local counter.
    `void` | `getLocalLock(String name, Handler<AsyncResult<Lock>> resultHandler)` Get an asynchronous local lock with the specified name.
    `void` | `getLocalLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler)` Like `getLocalLock(String, Handler)` but specifying a timeout.
    `<K,V> LocalMap<K,V>` | `getLocalMap(String name)` Return a `LocalMap` with the specific `name`.
    `void` | `getLock(String name, Handler<AsyncResult<Lock>> resultHandler)` Get an asynchronous lock with the specified name.
    `void` | `getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler)` Like `getLock(String, Handler)` but specifying a timeout.

- - ### Method Detail

    - #### getClusterWideMap

          <K,V> void getClusterWideMap(String name,
                                       Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)

      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.
      Parameters:
        `name` - the name of the map
        `resultHandler` - the map will be returned asynchronously in this handler
      Throws:
        `IllegalStateException` - if the parent `Vertx` instance is not clustered

    - #### getAsyncMap

          <K,V> void getAsyncMap(String name,
                                 Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)

      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.

      Parameters:
        `name` - the name of the map
        `resultHandler` - the map will be returned asynchronously in this handler

    - #### getLocalAsyncMap

          <K,V> void getLocalAsyncMap(String name,
                                      Handler<AsyncResult<AsyncMap<K,V>>> resultHandler)

      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.

      Parameters:
        `name` - the name of the map
        `resultHandler` - the map will be returned asynchronously in this handler

    - #### getLock

          void getLock(String name,
                       Handler<AsyncResult<Lock>> resultHandler)

      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.

      Parameters:
        `name` - the name of the lock
        `resultHandler` - the handler

    - #### getLockWithTimeout

          void getLockWithTimeout(String name,
                                  long timeout,
                                  Handler<AsyncResult<Lock>> resultHandler)

      Like `getLock(String, Handler)` 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.

      Parameters:
        `name` - the name of the lock
        `timeout` - the timeout in ms
        `resultHandler` - the handler

    - #### getLocalLock

          void getLocalLock(String name,
                            Handler<AsyncResult<Lock>> resultHandler)

      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.

      Parameters:
        `name` - the name of the lock
        `resultHandler` - the handler

    - #### getLocalLockWithTimeout

          void getLocalLockWithTimeout(String name,
                                       long timeout,
                                       Handler<AsyncResult<Lock>> resultHandler)

      Like `getLocalLock(String, Handler)` 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.

      Parameters:
        `name` - the name of the lock
        `timeout` - the timeout in ms
        `resultHandler` - the handler

    - #### getCounter

          void getCounter(String name,
                          Handler<AsyncResult<Counter>> resultHandler)

      Get an asynchronous counter. The counter will be passed to the handler.
      Parameters:
        `name` - the name of the counter.
        `resultHandler` - the handler

    - #### getLocalCounter

          void getLocalCounter(String name,
                               Handler<AsyncResult<Counter>> resultHandler)

      Get an asynchronous local counter. The counter will be passed to the handler.
      Parameters:
        `name` - the name of the counter.
        `resultHandler` - the handler

    - #### getLocalMap

          <K,V> LocalMap<K,V> getLocalMap(String name)

      Return a `LocalMap` with the specific `name`.
      Parameters:
        `name` - the name of the map
      Returns:
        the msp

Copyright © 2021 Eclipse. All rights reserved.