Top Inners Fields Constructors Methods
io.vertx.core.shareddata.impl

public Class SharedDataImpl

extends Object
implements SharedData
Class Inheritance
All Implemented Interfaces
io.vertx.core.shareddata.SharedData
Imports
io.vertx.core.AsyncResult, .Future, .Handler, .Promise, io.vertx.core.impl.Arguments, .ContextInternal, .VertxInternal, io.vertx.core.shareddata.*, io.vertx.core.spi.cluster.ClusterManager, java.io.Serializable, java.util.List, .Map, .Objects, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap

Author
Tim Fox

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final ClusterManager
private static final long
private final LocalAsyncLocks
private final ConcurrentMap<String, LocalAsyncMapImpl<?, ?>>
private final ConcurrentMap<String, Counter>
private final ConcurrentMap<String, LocalMap<?, ?>>
private final VertxInternal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
public <K, V> void
getAsyncMap(String
the name of the map
name
,
Handler<AsyncResult<AsyncMap<K, V>>>
the map will be returned asynchronously in this handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getAsyncMap.

Get the AsyncMap with the specified name.

public <K, V> Future<AsyncMap<K, V>>
getAsyncMap(String name)

Implements io.vertx.core.shareddata.SharedData.getAsyncMap.

Same as getAsyncMap(String, Handler) but returns a Future of the asynchronous result

public <K, V> void
getClusterWideMap(String
the name of the map
name
,
Handler<AsyncResult<AsyncMap<K, V>>>
the map will be returned asynchronously in this handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getClusterWideMap.

Get the cluster wide map with the specified name.

public <K, V> Future<AsyncMap<K, V>>
getClusterWideMap(String name)

Implements io.vertx.core.shareddata.SharedData.getClusterWideMap.

Same as getClusterWideMap(String, Handler) but returns a Future of the asynchronous result

public Future<Counter>
getCounter(String name)

Implements io.vertx.core.shareddata.SharedData.getCounter.

Same as getCounter(String, Handler) but returns a Future of the asynchronous result

public void
getCounter(String
the name of the counter.
name
,
Handler<AsyncResult<Counter>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getCounter.

Get an asynchronous counter.

public <K, V> void
getLocalAsyncMap(String
the name of the map
name
,
Handler<AsyncResult<AsyncMap<K, V>>>
the map will be returned asynchronously in this handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

Get the AsyncMap with the specified name.

public <K, V> Future<AsyncMap<K, V>>
getLocalAsyncMap(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

Same as getLocalAsyncMap(String, Handler) but returns a Future of the asynchronous result

public void
getLocalCounter(String
the name of the counter.
name
,
Handler<AsyncResult<Counter>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLocalCounter.

Get an asynchronous local counter.

public Future<Counter>
getLocalCounter(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalCounter.

Same as getLocalCounter(String, Handler) but returns a Future of the asynchronous result

public void
getLocalLock(String
the name of the lock
name
,
Handler<AsyncResult<Lock>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLocalLock.

Get an asynchronous local lock with the specified name.

public Future<Lock>
getLocalLock(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalLock.

Same as getLocalLock(String, Handler) but returns a Future of the asynchronous result

public void
getLocalLockWithTimeout(String
the name of the lock
name
,
long
the timeout in ms
timeout
,
Handler<AsyncResult<Lock>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

Like getLocalLock(String, Handler) but specifying a timeout.

public Future<Lock>
getLocalLockWithTimeout(String name, long timeout)

Implements io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

Same as getLocalLockWithTimeout(String, long, Handler) but returns a Future of the asynchronous result

public <K, V> LocalMap<K, V>
getLocalMap(String
the name of the map
name
)

Implements io.vertx.core.shareddata.SharedData.getLocalMap.

Return a Map with the specific name.

public void
getLock(String
the name of the lock
name
,
Handler<AsyncResult<Lock>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLock.

Get an asynchronous lock with the specified name.

public Future<Lock>
getLock(String name)

Implements io.vertx.core.shareddata.SharedData.getLock.

Same as getLock(String, Handler) but returns a Future of the asynchronous result

public void
getLockWithTimeout(String
the name of the lock
name
,
long
the timeout in ms
timeout
,
Handler<AsyncResult<Lock>>
the handler
resultHandler
)

Implements io.vertx.core.shareddata.SharedData.getLockWithTimeout.

Like getLock(String, Handler) but specifying a timeout.

public Future<Lock>
getLockWithTimeout(String name, long timeout)

Implements io.vertx.core.shareddata.SharedData.getLockWithTimeout.

Same as getLockWithTimeout(String, long, Handler) but returns a Future of the asynchronous result

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clusterManagerback to summary
private final ClusterManager clusterManager
DEFAULT_LOCK_TIMEOUTback to summary
private static final long DEFAULT_LOCK_TIMEOUT
localAsyncLocksback to summary
private final LocalAsyncLocks localAsyncLocks
localAsyncMapsback to summary
private final ConcurrentMap<String, LocalAsyncMapImpl<?, ?>> localAsyncMaps
localCountersback to summary
private final ConcurrentMap<String, Counter> localCounters
localMapsback to summary
private final ConcurrentMap<String, LocalMap<?, ?>> localMaps
vertxback to summary
private final VertxInternal vertx

Constructor Detail

SharedDataImplback to summary
public SharedDataImpl(VertxInternal vertx, ClusterManager clusterManager)

Method Detail

checkTypeback to summary
private static void checkType(Object obj)
getAsyncMapback to summary
public <K, V> void getAsyncMap(String name, Handler<AsyncResult<AsyncMap<K, V>>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getAsyncMap.

Doc from io.vertx.core.shareddata.SharedData.getAsyncMap.

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:String

the name of the map

resultHandler:Handler<AsyncResult<AsyncMap<K, V>>>

the map will be returned asynchronously in this handler

Annotations
@Override
getAsyncMapback to summary
public <K, V> Future<AsyncMap<K, V>> getAsyncMap(String name)

Implements io.vertx.core.shareddata.SharedData.getAsyncMap.

Doc from io.vertx.core.shareddata.SharedData.getAsyncMap.

Same as getAsyncMap(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getClusterWideMapback to summary
public <K, V> void getClusterWideMap(String name, Handler<AsyncResult<AsyncMap<K, V>>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getClusterWideMap.

Doc from io.vertx.core.shareddata.SharedData.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:String

the name of the map

resultHandler:Handler<AsyncResult<AsyncMap<K, V>>>

the map will be returned asynchronously in this handler

Annotations
@Override
getClusterWideMapback to summary
public <K, V> Future<AsyncMap<K, V>> getClusterWideMap(String name)

Implements io.vertx.core.shareddata.SharedData.getClusterWideMap.

Doc from io.vertx.core.shareddata.SharedData.getClusterWideMap.

Same as getClusterWideMap(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getCounterback to summary
public Future<Counter> getCounter(String name)

Implements io.vertx.core.shareddata.SharedData.getCounter.

Doc from io.vertx.core.shareddata.SharedData.getCounter.

Same as getCounter(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getCounterback to summary
public void getCounter(String name, Handler<AsyncResult<Counter>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getCounter.

Doc from io.vertx.core.shareddata.SharedData.getCounter.

Get an asynchronous counter. The counter will be passed to the handler.

Parameters
name:String

the name of the counter.

resultHandler:Handler<AsyncResult<Counter>>

the handler

Annotations
@Override
getLocalAsyncMapback to summary
public <K, V> void getLocalAsyncMap(String name, Handler<AsyncResult<AsyncMap<K, V>>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

Doc from io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

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:String

the name of the map

resultHandler:Handler<AsyncResult<AsyncMap<K, V>>>

the map will be returned asynchronously in this handler

Annotations
@Override
getLocalAsyncMapback to summary
public <K, V> Future<AsyncMap<K, V>> getLocalAsyncMap(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

Doc from io.vertx.core.shareddata.SharedData.getLocalAsyncMap.

Same as getLocalAsyncMap(String, Handler) but returns a Future of the asynchronous result

Annotations
@SuppressWarnings:unchecked
@Override
getLocalCounterback to summary
public void getLocalCounter(String name, Handler<AsyncResult<Counter>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLocalCounter.

Doc from io.vertx.core.shareddata.SharedData.getLocalCounter.

Get an asynchronous local counter. The counter will be passed to the handler.

Parameters
name:String

the name of the counter.

resultHandler:Handler<AsyncResult<Counter>>

the handler

Annotations
@Override
getLocalCounterback to summary
public Future<Counter> getLocalCounter(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalCounter.

Doc from io.vertx.core.shareddata.SharedData.getLocalCounter.

Same as getLocalCounter(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getLocalLockback to summary
public void getLocalLock(String name, Handler<AsyncResult<Lock>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLocalLock.

Doc from io.vertx.core.shareddata.SharedData.getLocalLock.

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:String

the name of the lock

resultHandler:Handler<AsyncResult<Lock>>

the handler

Annotations
@Override
getLocalLockback to summary
public Future<Lock> getLocalLock(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalLock.

Doc from io.vertx.core.shareddata.SharedData.getLocalLock.

Same as getLocalLock(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getLocalLockWithTimeoutback to summary
public void getLocalLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

Doc from io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

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:String

the name of the lock

timeout:long

the timeout in ms

resultHandler:Handler<AsyncResult<Lock>>

the handler

Annotations
@Override
getLocalLockWithTimeoutback to summary
public Future<Lock> getLocalLockWithTimeout(String name, long timeout)

Implements io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

Doc from io.vertx.core.shareddata.SharedData.getLocalLockWithTimeout.

Same as getLocalLockWithTimeout(String, long, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getLocalMapback to summary
public <K, V> LocalMap<K, V> getLocalMap(String name)

Implements io.vertx.core.shareddata.SharedData.getLocalMap.

Return a Map with the specific name. All invocations of this method with the same value of name are guaranteed to return the same Map instance.

Parameters
name:String

Doc from io.vertx.core.shareddata.SharedData.getLocalMap.

the name of the map

Returns:LocalMap<K, V>

Doc from io.vertx.core.shareddata.SharedData.getLocalMap.

the map

Annotations
@SuppressWarnings:unchecked
@Override
getLockback to summary
public void getLock(String name, Handler<AsyncResult<Lock>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLock.

Doc from io.vertx.core.shareddata.SharedData.getLock.

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:String

the name of the lock

resultHandler:Handler<AsyncResult<Lock>>

the handler

Annotations
@Override
getLockback to summary
public Future<Lock> getLock(String name)

Implements io.vertx.core.shareddata.SharedData.getLock.

Doc from io.vertx.core.shareddata.SharedData.getLock.

Same as getLock(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getLockWithTimeoutback to summary
public void getLockWithTimeout(String name, long timeout, Handler<AsyncResult<Lock>> resultHandler)

Implements io.vertx.core.shareddata.SharedData.getLockWithTimeout.

Doc from io.vertx.core.shareddata.SharedData.getLockWithTimeout.

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:String

the name of the lock

timeout:long

the timeout in ms

resultHandler:Handler<AsyncResult<Lock>>

the handler

Annotations
@Override
getLockWithTimeoutback to summary
public Future<Lock> getLockWithTimeout(String name, long timeout)

Implements io.vertx.core.shareddata.SharedData.getLockWithTimeout.

Doc from io.vertx.core.shareddata.SharedData.getLockWithTimeout.

Same as getLockWithTimeout(String, long, Handler) but returns a Future of the asynchronous result

Annotations
@Override
io.vertx.core.shareddata.impl back to summary

public final Class SharedDataImpl.WrappedAsyncMap<K, V>

extends Object
implements AsyncMap<K, V>
Class Inheritance
All Implemented Interfaces
io.vertx.core.shareddata.AsyncMap

Field Summary

Modifier and TypeField and Description
private final AsyncMap<K, V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Future<Void>
clear()

Implements io.vertx.core.shareddata.AsyncMap.clear.

Same as clear(Handler) but returns a Future of the asynchronous result

public Future<Map<K, V>>
entries()

Implements io.vertx.core.shareddata.AsyncMap.entries.

Same as entries(Handler) but returns a Future of the asynchronous result

public Future<V>
get(K k)

Implements io.vertx.core.shareddata.AsyncMap.get.

Same as get(K, Handler) but returns a Future of the asynchronous result

public AsyncMap<K, V>
public Future<Set<K>>
keys()

Implements io.vertx.core.shareddata.AsyncMap.keys.

Same as keys(Handler) but returns a Future of the asynchronous result

public Future<Void>
put(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.put.

Same as put(K, V, Handler) but returns a Future of the asynchronous result

public Future<Void>
put(K k, V v, long ttl)

Implements io.vertx.core.shareddata.AsyncMap.put.

Same as put(K, V, long, Handler) but returns a Future of the asynchronous result

public Future<V>
putIfAbsent(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Same as putIfAbsent(K, V, Handler) but returns a Future of the asynchronous result

public Future<V>
putIfAbsent(K k, V v, long ttl)

Implements io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Same as putIfAbsent(K, V, long, Handler) but returns a Future of the asynchronous result

public Future<V>
remove(K k)

Implements io.vertx.core.shareddata.AsyncMap.remove.

Same as remove(K, Handler) but returns a Future of the asynchronous result

public Future<Boolean>
removeIfPresent(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.removeIfPresent.

Same as removeIfPresent(K, V, Handler) but returns a Future of the asynchronous result

public Future<V>
replace(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.replace.

Same as replace(K, V, Handler) but returns a Future of the asynchronous result

public Future<V>
replace(K k, V v, long ttl)

Overrides default io.vertx.core.shareddata.AsyncMap.replace.

Same as replace(K, V, long, Handler) but returns a Future of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

public Future<Boolean>
replaceIfPresent(K k, V oldValue, V newValue)

Implements io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Same as replaceIfPresent(K, V, V, Handler) but returns a Future of the asynchronous result

public Future<Boolean>
replaceIfPresent(K k, V oldValue, V newValue, long ttl)

Overrides default io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Same as replaceIfPresent(K, V, V, long, Handler) but returns a Future of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

public Future<Integer>
size()

Implements io.vertx.core.shareddata.AsyncMap.size.

Same as size(Handler) but returns a Future of the asynchronous result

public Future<List<V>>
values()

Implements io.vertx.core.shareddata.AsyncMap.values.

Same as values(Handler) but returns a Future of the asynchronous result

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final AsyncMap<K, V> delegate

Constructor Detail

WrappedAsyncMapback to summary
pack-priv WrappedAsyncMap(AsyncMap<K, V> other)

Method Detail

clearback to summary
public Future<Void> clear()

Implements io.vertx.core.shareddata.AsyncMap.clear.

Doc from io.vertx.core.shareddata.AsyncMap.clear.

Same as clear(Handler) but returns a Future of the asynchronous result

Annotations
@Override
entriesback to summary
public Future<Map<K, V>> entries()

Implements io.vertx.core.shareddata.AsyncMap.entries.

Doc from io.vertx.core.shareddata.AsyncMap.entries.

Same as entries(Handler) but returns a Future of the asynchronous result

Annotations
@Override
getback to summary
public Future<V> get(K k)

Implements io.vertx.core.shareddata.AsyncMap.get.

Doc from io.vertx.core.shareddata.AsyncMap.get.

Same as get(K, Handler) but returns a Future of the asynchronous result

Annotations
@Override
getDelegateback to summary
public AsyncMap<K, V> getDelegate()
keysback to summary
public Future<Set<K>> keys()

Implements io.vertx.core.shareddata.AsyncMap.keys.

Doc from io.vertx.core.shareddata.AsyncMap.keys.

Same as keys(Handler) but returns a Future of the asynchronous result

Annotations
@Override
putback to summary
public Future<Void> put(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.put.

Doc from io.vertx.core.shareddata.AsyncMap.put.

Same as put(K, V, Handler) but returns a Future of the asynchronous result

Annotations
@Override
putback to summary
public Future<Void> put(K k, V v, long ttl)

Implements io.vertx.core.shareddata.AsyncMap.put.

Doc from io.vertx.core.shareddata.AsyncMap.put.

Same as put(K, V, long, Handler) but returns a Future of the asynchronous result

Annotations
@Override
putIfAbsentback to summary
public Future<V> putIfAbsent(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Doc from io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Same as putIfAbsent(K, V, Handler) but returns a Future of the asynchronous result

Annotations
@Override
putIfAbsentback to summary
public Future<V> putIfAbsent(K k, V v, long ttl)

Implements io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Doc from io.vertx.core.shareddata.AsyncMap.putIfAbsent.

Same as putIfAbsent(K, V, long, Handler) but returns a Future of the asynchronous result

Annotations
@Override
removeback to summary
public Future<V> remove(K k)

Implements io.vertx.core.shareddata.AsyncMap.remove.

Doc from io.vertx.core.shareddata.AsyncMap.remove.

Same as remove(K, Handler) but returns a Future of the asynchronous result

Annotations
@Override
removeIfPresentback to summary
public Future<Boolean> removeIfPresent(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.removeIfPresent.

Doc from io.vertx.core.shareddata.AsyncMap.removeIfPresent.

Same as removeIfPresent(K, V, Handler) but returns a Future of the asynchronous result

Annotations
@Override
replaceback to summary
public Future<V> replace(K k, V v)

Implements io.vertx.core.shareddata.AsyncMap.replace.

Doc from io.vertx.core.shareddata.AsyncMap.replace.

Same as replace(K, V, Handler) but returns a Future of the asynchronous result

Annotations
@Override
replaceback to summary
public Future<V> replace(K k, V v, long ttl)

Overrides default io.vertx.core.shareddata.AsyncMap.replace.

Doc from io.vertx.core.shareddata.AsyncMap.replace.

Same as replace(K, V, long, Handler) but returns a Future of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

Annotations
@Override
replaceIfPresentback to summary
public Future<Boolean> replaceIfPresent(K k, V oldValue, V newValue)

Implements io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Doc from io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Same as replaceIfPresent(K, V, V, Handler) but returns a Future of the asynchronous result

Annotations
@Override
replaceIfPresentback to summary
public Future<Boolean> replaceIfPresent(K k, V oldValue, V newValue, long ttl)

Overrides default io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Doc from io.vertx.core.shareddata.AsyncMap.replaceIfPresent.

Same as replaceIfPresent(K, V, V, long, Handler) but returns a Future of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

Annotations
@Override
sizeback to summary
public Future<Integer> size()

Implements io.vertx.core.shareddata.AsyncMap.size.

Doc from io.vertx.core.shareddata.AsyncMap.size.

Same as size(Handler) but returns a Future of the asynchronous result

Annotations
@Override
valuesback to summary
public Future<List<V>> values()

Implements io.vertx.core.shareddata.AsyncMap.values.

Doc from io.vertx.core.shareddata.AsyncMap.values.

Same as values(Handler) but returns a Future of the asynchronous result

Annotations
@Override