private void doDeployVerticle(final String verticleName, DeploymentOptions deploymentOptions, final Handler<AsyncResult<String>> doneHandler) { final Handler<AsyncResult<String>> wrappedHandler = ar1 -> { vertx.<String>executeBlocking(fut -> { if (ar1.succeeded()) { // Tell the other nodes of the cluster about the verticle for HA purposes String deploymentID = ar1.result(); addToHA(deploymentID, verticleName, deploymentOptions); fut.complete(deploymentID); } else { fut.fail(ar1.cause()); } }, false, ar2 -> { if (doneHandler != null) { doneHandler.handle(ar2); } else if (ar2.failed()) { log.error("Failed to deploy verticle", ar2.cause()); } }); }; deploymentManager.deployVerticle(verticleName, deploymentOptions, wrappedHandler); }
@Override public void join(Handler<AsyncResult<Void>> resultHandler) { vertx.executeBlocking(fut -> { synchronized (this) { this.nodeID = UUID.randomUUID().toString(); doJoin(nodeID, this); } fut.complete(); }, resultHandler); }
@Override public void leave(Handler<AsyncResult<Void>> resultHandler) { vertx.executeBlocking(fut -> { synchronized (this) { if (nodeID != null) { if (nodeListener != null) { nodeListener = null; } doLeave(nodeID); this.nodeID = null; } } fut.complete(); }, resultHandler); }
serverID = new ServerID(serverPort, serverHost); nodeInfo = new ClusterNodeInfo(clusterManager.getNodeID(), serverID); vertx.executeBlocking(fut -> { haManager.addDataToAHAInfo(SERVER_ID_HA_KEY, new JsonObject().put("host", serverID.host).put("port", serverID.port)); fut.complete();
protected void kill(int pos) { VertxInternal v = (VertxInternal)vertices[pos]; v.executeBlocking(fut -> { try { v.simulateKill(); fut.complete(); } catch (Exception e) { fut.fail(e); } }, false, ar -> { if (!ar.succeeded()) { fail(ar.cause()); } }); }
protected void kill(int pos) { // Save the deploymentIDs first takeDeploymentSnapshots(); VertxInternal v = (VertxInternal)vertices[pos]; killedNode = pos; v.executeBlocking(fut -> { v.simulateKill(); fut.complete(); }, false, ar -> { assertTrue(ar.succeeded()); }); }
} else { if (verticleFactory.blockingCreate()) { vertx.<Verticle[]>executeBlocking(createFut -> { try { Verticle[] verticles = createVerticles(verticleFactory, identifier, options.getInstances(), cl);
private void doDeployVerticle(final String verticleName, DeploymentOptions deploymentOptions, final Handler<AsyncResult<String>> doneHandler) { final Handler<AsyncResult<String>> wrappedHandler = ar1 -> { vertx.<String>executeBlocking(fut -> { if (ar1.succeeded()) { // Tell the other nodes of the cluster about the verticle for HA purposes String deploymentID = ar1.result(); addToHA(deploymentID, verticleName, deploymentOptions); fut.complete(deploymentID); } else { fut.fail(ar1.cause()); } }, false, ar2 -> { if (doneHandler != null) { doneHandler.handle(ar2); } else if (ar2.failed()) { log.error("Failed to deploy verticle", ar2.cause()); } }); }; deploymentManager.deployVerticle(verticleName, deploymentOptions, wrappedHandler); }
@Override public void join(Handler<AsyncResult<Void>> resultHandler) { vertx.executeBlocking(fut -> { synchronized (this) { this.nodeID = UUID.randomUUID().toString(); doJoin(nodeID, this); } fut.complete(); }, resultHandler); }
@Override public void leave(Handler<AsyncResult<Void>> resultHandler) { vertx.executeBlocking(fut -> { synchronized (this) { if (nodeID != null) { if (nodeListener != null) { nodeListener = null; } doLeave(nodeID); this.nodeID = null; } } fut.complete(); }, resultHandler); }
serverID = new ServerID(serverPort, serverHost); nodeInfo = new ClusterNodeInfo(clusterManager.getNodeID(), serverID); vertx.executeBlocking(fut -> { haManager.addDataToAHAInfo(SERVER_ID_HA_KEY, new JsonObject().put("host", serverID.host).put("port", serverID.port)); fut.complete();
protected void kill(int pos) { VertxInternal v = (VertxInternal)vertices[pos]; v.executeBlocking(fut -> { try { v.simulateKill(); fut.complete(); } catch (Exception e) { fut.fail(e); } }, false, ar -> { if (!ar.succeeded()) { fail(ar.cause()); } }); }
protected void kill(int pos) { // Save the deploymentIDs first takeDeploymentSnapshots(); VertxInternal v = (VertxInternal)vertices[pos]; killedNode = pos; v.executeBlocking(fut -> { v.simulateKill(); fut.complete(); }, false, ar -> { assertTrue(ar.succeeded()); }); }
} else { if (verticleFactory.blockingCreate()) { vertx.<Verticle[]>executeBlocking(createFut -> { try { Verticle[] verticles = createVerticles(verticleFactory, identifier, options.getInstances(), cl);
@Override public void put(final K k, final V v, final Handler<AsyncResult<Void>> resultHandler) { FakeClusterManager.this.vertx.executeBlocking(fut -> { this.map.put(k, v); fut.complete(); }, resultHandler); }
@Override public void clear(final Handler<AsyncResult<Void>> resultHandler) { FakeClusterManager.this.vertx.executeBlocking(fut -> { this.map.clear(); fut.complete(); }, resultHandler); }
@Override public void clear(final Handler<AsyncResult<Void>> resultHandler) { FakeClusterManager.this.vertx.executeBlocking(fut -> { this.map.clear(); fut.complete(); }, resultHandler); }
@Override public void remove(final K k, final Handler<AsyncResult<V>> resultHandler) { FakeClusterManager.this.vertx.executeBlocking(fut -> fut.complete(this.map.remove(k)), resultHandler); }
@Override public void join(final Handler<AsyncResult<Void>> resultHandler) { this.vertx.executeBlocking(fut -> { synchronized (this) { this.nodeID = UUID.randomUUID().toString(); doJoin(this.nodeID, this); } fut.complete(); }, resultHandler); }
@Override public void join(final Handler<AsyncResult<Void>> resultHandler) { this.vertx.executeBlocking(fut -> { synchronized (this) { this.nodeID = UUID.randomUUID().toString(); doJoin(this.nodeID, this); } fut.complete(); }, resultHandler); }