Top Description Methods
io.vertx.core.shareddata

public Interface SharedData

Known Direct Implementers
io.vertx.core.shareddata.impl.SharedDataImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.VertxGen, io.vertx.core.AsyncResult, .Future, .Handler

Shared data allows you to share data safely between different parts of your application in a safe way.

Shared data provides:

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 TypeMethod and Description
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
)

Get the AsyncMap with the specified name.

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

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
)

Get the cluster wide map with the specified name.

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

Same as getClusterWideMap(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
)

Get an asynchronous counter.

public Future<Counter>
getCounter(String name)

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

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
)

Get the AsyncMap with the specified name.

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

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
)

Get an asynchronous local counter.

public Future<Counter>
getLocalCounter(String name)

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
)

Get an asynchronous local lock with the specified name.

public Future<Lock>
getLocalLock(String name)

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
)

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

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

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

public <K, V> LocalMap<K, V>

Returns:

the map
getLocalMap
(String
the name of the map
name
)

Return a LocalMap with the specific name.

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

Get an asynchronous lock with the specified name.

public Future<Lock>
getLock(String name)

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
)

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

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

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

Method Detail

getAsyncMapback to summary
public <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:String

the name of the map

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

the map will be returned asynchronously in this handler

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

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

getClusterWideMapback to summary
public <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:String

the name of the map

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

the map will be returned asynchronously in this handler

Exceptions
IllegalStateException:
if the parent io.vertx.core.Vertx instance is not clustered
getClusterWideMapback to summary
public <K, V> Future<AsyncMap<K, V>> getClusterWideMap(String name)

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

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

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

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

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

getLocalAsyncMapback to summary
public <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:String

the name of the map

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

the map will be returned asynchronously in this handler

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

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

getLocalCounterback to summary
public void getLocalCounter(String name, Handler<AsyncResult<Counter>> resultHandler)

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

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

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

getLocalLockback to summary
public 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:String

the name of the lock

resultHandler:Handler<AsyncResult<Lock>>

the handler

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

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

getLocalLockWithTimeoutback to summary
public 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:String

the name of the lock

timeout:long

the timeout in ms

resultHandler:Handler<AsyncResult<Lock>>

the handler

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

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

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

Return a LocalMap with the specific name.

Parameters
name:String

the name of the map

Returns:LocalMap<K, V>

the map

getLockback to summary
public 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:String

the name of the lock

resultHandler:Handler<AsyncResult<Lock>>

the handler

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

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

getLockWithTimeoutback to summary
public 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:String

the name of the lock

timeout:long

the timeout in ms

resultHandler:Handler<AsyncResult<Lock>>

the handler

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

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