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);
}
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);
}
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);
}
}
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());
}
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();
}
Aggregations