本文整理了Java中io.vertx.core.VertxOptions.setClustered()
方法的一些代码示例,展示了VertxOptions.setClustered()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VertxOptions.setClustered()
方法的具体详情如下:
包路径:io.vertx.core.VertxOptions
类名称:VertxOptions
方法名:setClustered
[英]Set whether or not the Vert.x instance will be clustered.
[中]设置是否垂直。x实例将被集群化。
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public void clusteredVertx(VertxOptions options, final Handler<AsyncResult<Vertx>> resultHandler) {
// We don't require the user to set clustered to true if they use this method
options.setClustered(true);
VertxImpl.clusteredVertx(options, resultHandler);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public void beforeStartingVertx(VertxOptions options) {
options.setClustered(true);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClustered(true), ar -> {
if (ar.failed()) {
System.err.println("Cannot create vert.x instance : " + ar.cause());
} else {
Vertx vertx = ar.result();
vertx.deployVerticle(ConsumerApp.class.getName());
}
});
}
代码示例来源:origin: vert-x3/vertx-examples
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClustered(true), ar -> {
if (ar.failed()) {
System.err.println("Cannot create vert.x instance : " + ar.cause());
} else {
Vertx vertx = ar.result();
vertx.deployVerticle(StatsConsumerApp.class.getName());
}
});
}
}
代码示例来源:origin: vert-x3/vertx-examples
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClustered(true), ar -> {
if (ar.failed()) {
System.err.println("Cannot create vert.x instance : " + ar.cause());
} else {
Vertx vertx = ar.result();
vertx.deployVerticle(DisplayStatsApp.class.getName());
}
});
}
}
代码示例来源:origin: vert-x3/vertx-examples
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClustered(true), ar -> {
if (ar.failed()) {
System.err.println("Cannot create vert.x instance : " + ar.cause());
} else {
Vertx vertx = ar.result();
vertx.deployVerticle(ProducerApp.class.getName());
}
});
}
代码示例来源:origin: vert-x3/vertx-examples
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClustered(true), ar -> {
if (ar.failed()) {
System.err.println("Cannot create vert.x instance : " + ar.cause());
} else {
Vertx vertx = ar.result();
vertx.deployVerticle(StatsProducerApp.class.getName());
}
});
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runExample(Class clazz) {
runExample(SHELL_EXAMPLES_JAVA_DIR, clazz,
new VertxOptions(DROPWIZARD_OPTIONS).setClustered(false), null);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runClusteredExample(Class clazz) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(true), null);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runExample(Class clazz) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(false), null);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runClusteredExample(Class clazz) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(true), null);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runExample(Class clazz, DeploymentOptions options) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(false), options);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runExample(Class clazz) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(false), null);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runExample(Class clazz, DeploymentOptions options) {
runExample(EXAMPLES_JAVA_DIR, clazz,
new VertxOptions().setClustered(false), options);
}
代码示例来源:origin: vert-x3/vertx-examples
public static void runRubyExample(String scriptName) {
runScriptExample(CORE_EXAMPLES_RUBY_DIR, scriptName, new VertxOptions().setClustered(false));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testFailCreateClusteredVertxSynchronously() {
VertxOptions options = new VertxOptions();
options.setClustered(true);
try {
Vertx.vertx(options);
fail("Should throw exception");
} catch (IllegalArgumentException e) {
// OK
}
}
代码示例来源:origin: eclipse-vertx/vert.x
protected void startNodes(int numNodes, VertxOptions options) {
CountDownLatch latch = new CountDownLatch(numNodes);
vertices = new Vertx[numNodes];
for (int i = 0; i < numNodes; i++) {
int index = i;
clusteredVertx(options.setClusterHost("localhost").setClusterPort(0).setClustered(true)
.setClusterManager(getClusterManager()), ar -> {
try {
if (ar.failed()) {
ar.cause().printStackTrace();
}
assertTrue("Failed to start node", ar.succeeded());
vertices[index] = ar.result();
}
finally {
latch.countDown();
}
});
}
try {
assertTrue(latch.await(2, TimeUnit.MINUTES));
} catch (InterruptedException e) {
fail(e.getMessage());
}
}
代码示例来源:origin: eclipse-vertx/vert.x
protected Vertx startVertx(String haGroup, int quorumSize, boolean ha) throws Exception {
VertxOptions options = new VertxOptions().setHAEnabled(ha).setClustered(true).
setClusterHost("localhost").setClusterManager(getClusterManager());
if (ha) {
options.setQuorumSize(quorumSize);
if (haGroup != null) {
options.setHAGroup(haGroup);
}
}
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Vertx> vertxRef = new AtomicReference<>();
clusteredVertx(options, onSuccess(vertx -> {
vertxRef.set(vertx);
latch.countDown();
}));
latch.await(2, TimeUnit.MINUTES);
return vertxRef.get();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testFactoryInCluster() throws Exception {
AtomicReference<Thread> metricsThread = new AtomicReference<>();
AtomicReference<Context> metricsContext = new AtomicReference<>();
Thread testThread = Thread.currentThread();
VertxMetricsFactory factory = (options) -> {
metricsThread.set(Thread.currentThread());
metricsContext.set(Vertx.currentContext());
return DummyVertxMetrics.INSTANCE;
};
clusteredVertx(new VertxOptions().setClustered(true).setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(factory)), onSuccess(vertx -> {
assertSame(testThread, metricsThread.get());
assertNull(metricsContext.get());
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testCreateClusteredVertxAsync() {
VertxOptions options = new VertxOptions();
options.setClustered(true);
clusteredVertx(options, ar -> {
assertTrue(ar.succeeded());
assertNotNull(ar.result());
assertTrue(ar.result().isClustered());
Vertx v = ar.result();
v.close(ar2 -> {
assertTrue(ar2.succeeded());
testComplete();
});
});
await();
}
内容来源于网络,如有侵权,请联系作者删除!