use of io.vertx.core.spi.cluster.NodeInfo in project vert.x by eclipse.
the class ClusteredEventBus method start.
@Override
public void start(Promise<Void> promise) {
NetServerOptions serverOptions = getServerOptions();
server = vertx.createNetServer(serverOptions);
server.connectHandler(getServerHandler());
int port = getClusterPort();
String host = getClusterHost();
server.listen(port, host).flatMap(v -> {
int publicPort = getClusterPublicPort(server.actualPort());
String publicHost = getClusterPublicHost(host);
nodeInfo = new NodeInfo(publicHost, publicPort, options.getClusterNodeMetadata());
nodeId = clusterManager.getNodeId();
Promise<Void> setPromise = Promise.promise();
clusterManager.setNodeInfo(nodeInfo, setPromise);
return setPromise.future();
}).onSuccess(v -> {
started = true;
nodeSelector.eventBusStarted();
}).onComplete(promise);
}
use of io.vertx.core.spi.cluster.NodeInfo in project vert.x by eclipse.
the class NodeInfoTest method testFailedFutureForUnknownNode.
@Test
public void testFailedFutureForUnknownNode() {
startNodes(2);
ClusterManager clusterManager = ((VertxInternal) vertices[0]).getClusterManager();
// Create unknown node identifier
String unknown = String.join("", clusterManager.getNodes());
// Needed as callback might be done from non Vert.x thread
disableThreadChecks();
Promise<NodeInfo> promise = Promise.promise();
clusterManager.getNodeInfo(unknown, promise);
promise.future().onComplete(onFailure(t -> testComplete()));
await();
}
Aggregations