Interface SharedData
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
Modifier and TypeMethodDescriptiongetAsyncMap(String name) Get theAsyncMapwith the specified name.getClusterWideMap(String name) Get the cluster wide map with the specified name.getCounter(String name) Get an asynchronous counter.getLocalAsyncMap(String name) Get theAsyncMapwith the specified name.getLocalCounter(String name) Get an asynchronous local counter.getLocalLock(String name) Get an asynchronous local lock with the specified name.getLocalLockWithTimeout(String name, long timeout) LikegetLocalLock(String)but specifying a timeout.<K,V> LocalMap <K, V> getLocalMap(String name) Return aLocalMapwith the specificname.Get an asynchronous lock with the specified name.getLockWithTimeout(String name, long timeout) LikegetLock(String)but specifying a timeout.default <T> Future<T> withLocalLock(String name, long timeout, Supplier<Future<T>> block) LikewithLocalLock(String, Supplier)but specifying a timeout.default <T> Future<T> withLocalLock(String name, Supplier<Future<T>> block) Get an asynchronous local lock with the specified name.default <T> Future<T> LikewithLock(String, Supplier)but specifying a timeout.default <T> Future<T> Get an asynchronous lock with the specified name.
-
Method Details
-
getClusterWideMap
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- Returns:
- a future notified with the map
- Throws:
IllegalStateException- if the parentVertxinstance is not clustered
-
getAsyncMap
Get theAsyncMapwith 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- Returns:
- a future notified with the map
-
getLocalAsyncMap
Get theAsyncMapwith 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- Returns:
- a future notified with the map
-
getLock
Get an asynchronous lock with the specified name. The returned future will be completed with the lock 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- Returns:
- a future notified with the lock
-
getLockWithTimeout
LikegetLock(String)but specifying a timeout. If the lock is not obtained within the timeout the returned future is failed.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 locktimeout- the timeout in ms- Returns:
- a future notified with the lock
-
withLock
Get an asynchronous lock with the specified name.When the
blockis called, the lock is already acquired, it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned future is failed with the cause of the failure.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- Returns:
- the future returned by the
block
-
withLock
LikewithLock(String, Supplier)but specifying a timeout. If the lock is not obtained within the timeout the returned future is failed.- Parameters:
name- the name of the locktimeout- the timeout in msblock- the code block called after lock acquisition- Returns:
- the future returned by the
block
-
getLocalLock
Get an asynchronous local lock with the specified name. The returned future will be completed with the lock 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- Returns:
- a future notified with the lock
-
getLocalLockWithTimeout
LikegetLocalLock(String)but specifying a timeout. If the lock is not obtained within the timeout the returned future is failed.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 locktimeout- the timeout in ms- Returns:
- a future notified with the lock
-
withLocalLock
Get an asynchronous local lock with the specified name.When the
blockis called, the lock is already acquired, it will be released when theFuture<T>returned by the block completes.When the
blockfails, the lock is released and the returned future is failed with the cause of the failure.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- Returns:
- the future returned by the
block
-
withLocalLock
LikewithLocalLock(String, Supplier)but specifying a timeout. If the lock is not obtained within the timeout the returned future is failed.- Parameters:
name- the name of the locktimeout- the timeout in msblock- the code block called after lock acquisition- Returns:
- the future returned by the
block
-
getCounter
-
getLocalCounter
-
getLocalMap
-