Search in sources :

Example 1 with NodeInfo

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);
}
Also used : LoggerFactory(io.vertx.core.impl.logging.LoggerFactory) MultiMap(io.vertx.core.MultiMap) ContextInternal(io.vertx.core.impl.ContextInternal) ConcurrentMap(java.util.concurrent.ConcurrentMap) RecordParser(io.vertx.core.parsetools.RecordParser) EventBusOptions(io.vertx.core.eventbus.EventBusOptions) NetClient(io.vertx.core.net.NetClient) Logger(io.vertx.core.impl.logging.Logger) VertxInternal(io.vertx.core.impl.VertxInternal) NodeSelector(io.vertx.core.spi.cluster.NodeSelector) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) Promise(io.vertx.core.Promise) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) VertxOptions(io.vertx.core.VertxOptions) UUID(java.util.UUID) NetClientOptions(io.vertx.core.net.NetClientOptions) Objects(java.util.Objects) AtomicLong(java.util.concurrent.atomic.AtomicLong) NetServerOptions(io.vertx.core.net.NetServerOptions) MessageCodec(io.vertx.core.eventbus.MessageCodec) Buffer(io.vertx.core.buffer.Buffer) io.vertx.core.eventbus.impl(io.vertx.core.eventbus.impl) RegistrationInfo(io.vertx.core.spi.cluster.RegistrationInfo) AddressHelper(io.vertx.core.eventbus.AddressHelper) NetServer(io.vertx.core.net.NetServer) NodeInfo(io.vertx.core.spi.cluster.NodeInfo) Handler(io.vertx.core.Handler) NetSocket(io.vertx.core.net.NetSocket) NodeInfo(io.vertx.core.spi.cluster.NodeInfo) NetServerOptions(io.vertx.core.net.NetServerOptions)

Example 2 with NodeInfo

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();
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) Promise(io.vertx.core.Promise) Test(org.junit.Test) NodeInfo(io.vertx.core.spi.cluster.NodeInfo) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) VertxTestBase(io.vertx.test.core.VertxTestBase) VertxInternal(io.vertx.core.impl.VertxInternal) NodeInfo(io.vertx.core.spi.cluster.NodeInfo) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) Test(org.junit.Test)

Aggregations

Promise (io.vertx.core.Promise)2 VertxInternal (io.vertx.core.impl.VertxInternal)2 ClusterManager (io.vertx.core.spi.cluster.ClusterManager)2 NodeInfo (io.vertx.core.spi.cluster.NodeInfo)2 Handler (io.vertx.core.Handler)1 MultiMap (io.vertx.core.MultiMap)1 VertxOptions (io.vertx.core.VertxOptions)1 Buffer (io.vertx.core.buffer.Buffer)1 AddressHelper (io.vertx.core.eventbus.AddressHelper)1 EventBusOptions (io.vertx.core.eventbus.EventBusOptions)1 MessageCodec (io.vertx.core.eventbus.MessageCodec)1 io.vertx.core.eventbus.impl (io.vertx.core.eventbus.impl)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 Logger (io.vertx.core.impl.logging.Logger)1 LoggerFactory (io.vertx.core.impl.logging.LoggerFactory)1 NetClient (io.vertx.core.net.NetClient)1 NetClientOptions (io.vertx.core.net.NetClientOptions)1 NetServer (io.vertx.core.net.NetServer)1 NetServerOptions (io.vertx.core.net.NetServerOptions)1 NetSocket (io.vertx.core.net.NetSocket)1