Search in sources :

Example 11 with ClusterManager

use of io.vertx.core.spi.cluster.ClusterManager in project vert.x by eclipse.

the class AsyncMultiMapTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    startNodes(1);
    clusterManager = ((VertxInternal) vertices[0]).getClusterManager();
    CountDownLatch latch = new CountDownLatch(1);
    clusterManager.<String, ServerID>getAsyncMultiMap("mymap", onSuccess(res -> {
        map = res;
        latch.countDown();
    }));
    awaitLatch(latch);
}
Also used : HashSet(java.util.HashSet) CountDownLatch(java.util.concurrent.CountDownLatch) VertxInternal(io.vertx.core.impl.VertxInternal) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) Set(java.util.Set) AsyncMultiMap(io.vertx.core.spi.cluster.AsyncMultiMap) Test(org.junit.Test) ServerID(io.vertx.core.net.impl.ServerID) ServerID(io.vertx.core.net.impl.ServerID) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 12 with ClusterManager

use of io.vertx.core.spi.cluster.ClusterManager in project vertx-zero by silentbalanceyh.

the class ClusterOptionsConverter method fromJson.

static void fromJson(final JsonObject json, final ClusterOptions obj) {
    if (json.getValue("enabled") instanceof Boolean) {
        obj.setEnabled(json.getBoolean("enabled"));
    }
    if (json.getValue("options") instanceof JsonObject) {
        obj.setOptions(json.getJsonObject("options"));
    }
    final Object managerObj = json.getValue("manager");
    Fn.safeNull(() -> {
        final Class<?> clazz = Instance.clazz(managerObj.toString());
        Fn.safeNull(() -> {
            // If null, keep default
            final ClusterManager manager = Instance.instance(clazz);
            obj.setManager(manager);
        }, clazz);
    }, managerObj);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject) ClusterManager(io.vertx.core.spi.cluster.ClusterManager)

Example 13 with ClusterManager

use of io.vertx.core.spi.cluster.ClusterManager in project vert.x by eclipse.

the class VertxBuilder method initClusterManager.

private static void initClusterManager(VertxOptions options, Collection<VertxServiceProvider> providers) {
    ClusterManager clusterManager = options.getClusterManager();
    if (clusterManager == null) {
        String clusterManagerClassName = System.getProperty("vertx.cluster.managerClass");
        if (clusterManagerClassName != null) {
            // We allow specify a sys prop for the cluster manager factory which overrides ServiceLoader
            try {
                Class<?> clazz = Class.forName(clusterManagerClassName);
                clusterManager = (ClusterManager) clazz.newInstance();
            } catch (Exception e) {
                throw new IllegalStateException("Failed to instantiate " + clusterManagerClassName, e);
            }
        }
    }
    if (clusterManager != null) {
        providers.add(clusterManager);
    }
}
Also used : ClusterManager(io.vertx.core.spi.cluster.ClusterManager)

Example 14 with ClusterManager

use of io.vertx.core.spi.cluster.ClusterManager in project vert.x by eclipse.

the class FaultToleranceTest method afterNodesKilled.

protected void afterNodesKilled() throws Exception {
    ClusterManager clusterManager = vertx.getClusterManager();
    assertEqualsEventually("Remaining members", Integer.valueOf(2), () -> clusterManager.getNodes().size());
}
Also used : ClusterManager(io.vertx.core.spi.cluster.ClusterManager)

Example 15 with ClusterManager

use of io.vertx.core.spi.cluster.ClusterManager 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

ClusterManager (io.vertx.core.spi.cluster.ClusterManager)15 JsonObject (io.vertx.core.json.JsonObject)5 Test (org.junit.Test)5 Vertx (io.vertx.core.Vertx)3 VertxOptions (io.vertx.core.VertxOptions)3 FakeClusterManager (io.vertx.test.fakecluster.FakeClusterManager)3 DeploymentOptions (io.vertx.core.DeploymentOptions)2 VertxInternal (io.vertx.core.impl.VertxInternal)2 ZookeeperClusterManager (io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager)2 Set (java.util.Set)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Glue (in.erail.glue.Glue)1 Observable (io.reactivex.Observable)1 AbstractVerticle (io.vertx.core.AbstractVerticle)1 ClusterOptions (io.vertx.core.ClusterOptions)1 Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 VertxInstance (io.vertx.core.VertxInstance)1