private void getMap(Handler<AsyncResult<AsyncMap<String, Session>>> resultHandler) { if (sessionMap == null) { vertx.sharedData().<String, Session>getClusterWideMap(sessionMapName, res -> { if (res.succeeded()) { sessionMap = res.result(); resultHandler.handle(Future.succeededFuture(res.result())); } else { resultHandler.handle(res); } }); } else { resultHandler.handle(Future.succeededFuture(sessionMap)); } } }
/** * 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. * @param name the name of the map * @param resultHandler the map will be returned asynchronously in this handler */ public <K, V> void getClusterWideMap(String name, Handler<AsyncResult<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>>> resultHandler) { delegate.getClusterWideMap(name, new Handler<AsyncResult<io.vertx.core.shareddata.AsyncMap<K,V>>>() { public void handle(AsyncResult<io.vertx.core.shareddata.AsyncMap<K,V>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.shareddata.AsyncMap.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * 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. * @param name the name of the map * @param resultHandler the map will be returned asynchronously in this handler */ public <K, V> void getClusterWideMap(String name, Handler<AsyncResult<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>>> resultHandler) { delegate.getClusterWideMap(name, new Handler<AsyncResult<io.vertx.core.shareddata.AsyncMap<K,V>>>() { public void handle(AsyncResult<io.vertx.core.shareddata.AsyncMap<K,V>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.shareddata.AsyncMap.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
private synchronized void retrieveRegistry(Handler<AsyncResult<AsyncMap<String, String>>> handler) { if (registry != null) { handler.handle(Future.succeededFuture(registry)); } else { vertx.sharedData().<String, String>getClusterWideMap("service.registry", ar -> { synchronized (DefaultServiceDiscoveryBackend.class) { if (ar.failed()) { handler.handle(ar); } else { registry = ar.result(); handler.handle(Future.succeededFuture(registry)); } } }); } }
private void getMap(Handler<AsyncResult<AsyncMap<String, Session>>> resultHandler) { if (sessionMap == null) { vertx.sharedData().<String, Session>getClusterWideMap(sessionMapName, res -> { if (res.succeeded()) { sessionMap = res.result(); resultHandler.handle(Future.succeededFuture(res.result())); } else { resultHandler.handle(res); } }); } else { resultHandler.handle(Future.succeededFuture(sessionMap)); } } }
public SharedGlobalDataRegistry(Vertx vertx, IEngineConfig vxConfig, Map<String, String> options) { this.vertx = vertx; this.vxConfig = vxConfig; this.options = options; if (!vertx.isClustered()) { throw new IllegalStateException(SharedGlobalDataRegistry.class.getCanonicalName() + " only works when operating in clustered mode!"); } vertx.sharedData().<String, Object> getClusterWideMap("SharedGlobalDataRegistry-Shared", async -> { if (async.succeeded()) { objectMap = async.result(); } else { throw new IllegalStateException(async.cause()); } }); }
private synchronized void retrieveRegistry(Handler<AsyncResult<AsyncMap<String, String>>> handler) { if (registry != null) { handler.handle(Future.succeededFuture(registry)); } else { vertx.sharedData().<String, String>getClusterWideMap("service.registry", ar -> { synchronized (DefaultServiceDiscoveryBackend.class) { if (ar.failed()) { handler.handle(ar); } else { registry = ar.result(); handler.handle(Future.succeededFuture(registry)); } } }); } }
public SharedGlobalDataRegistry(Vertx vertx, IEngineConfig vxConfig, Map<String, String> options) { this.vertx = vertx; this.vxConfig = vxConfig; this.options = options; if (!vertx.isClustered()) { throw new IllegalStateException(SharedGlobalDataRegistry.class.getCanonicalName() + " only works when operating in clustered mode!"); } vertx.sharedData().<String, Object> getClusterWideMap("SharedGlobalDataRegistry-Shared", async -> { if (async.succeeded()) { objectMap = async.result(); } else { throw new IllegalStateException(async.cause()); } }); }
shared.<K, V>getClusterWideMap(mapName, res -> { if (res.succeeded()) { fut.handle(new Success<>(res.result()));
assertTrue(res.succeeded()); assertNotNull(mgr.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result());
assertTrue(res.succeeded()); assertNotNull(mgr.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result());
assertTrue(res.succeeded()); assertNotNull(mgr1.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result()); assertNotNull(mgr2.getCuratorFramework()); vertx2.set(res.result()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().get("news", r -> { assertEquals("hello", r.result());
assertTrue(res.succeeded()); assertNotNull(mgr1.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result()); assertNotNull(mgr2.getCuratorFramework()); vertx2.set(res.result()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().get("news", r -> { assertEquals("hello", r.result());
assertTrue(res.succeeded()); assertNotNull(mgr1.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result()); assertNotNull(mgr2.getCuratorFramework()); vertx2.set(res.result()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().get("news", r -> { assertEquals("hello", r.result());
assertTrue(res.succeeded()); assertNotNull(mgr1.getCuratorFramework()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result()); assertNotNull(mgr2.getCuratorFramework()); vertx2.set(res.result()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().get("news", r -> { assertEquals("hello", r.result());
assertTrue(res.succeeded()); assertNotNull(mgr.getHazelcastInstance()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result());
assertTrue(res.succeeded()); assertNotNull(mgr1.getHazelcastInstance()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().put("news", "hello", v -> { vertx1.set(res.result()); assertNotNull(mgr2.getHazelcastInstance()); vertx2.set(res.result()); res.result().sharedData().getClusterWideMap("mymap1", ar -> { ar.result().get("news", r -> { assertEquals("hello", r.result());