io.vertx.core.VertxOptions.setClusterHost()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中io.vertx.core.VertxOptions.setClusterHost()方法的一些代码示例,展示了VertxOptions.setClusterHost()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VertxOptions.setClusterHost()方法的具体详情如下:
包路径:io.vertx.core.VertxOptions
类名称:VertxOptions
方法名:setClusterHost

VertxOptions.setClusterHost介绍

[英]Set the hostname to be used for clustering.
[中]设置用于群集的主机名。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

case "clusterHost":
 if (member.getValue() instanceof String) {
  obj.setClusterHost((String)member.getValue());

代码示例来源:origin: eclipse-vertx/vert.x

AtomicReference<AsyncResult<Vertx>> result = new AtomicReference<>();
options.setClusterHost(clusterHost).setClusterPort(clusterPort).setClustered(true);
if (ha) {
 String haGroup = args.map.get("-hagroup");

代码示例来源:origin: eclipse-vertx/vert.x

@Test
 public void testCallbackInvokedOnFailure() throws Exception {

  // will trigger java.net.UnknownHostException
  String hostName = "zoom.zoom.zen.tld";

  VertxOptions options = new VertxOptions()
   .setClusterManager(new FakeClusterManager())
   .setClusterHost(hostName);

  AtomicReference<AsyncResult<Vertx>> resultRef = new AtomicReference<>();

  CountDownLatch latch = new CountDownLatch(1);
  Vertx.clusteredVertx(options, ar -> {
   resultRef.set(ar);
   latch.countDown();
  });
  awaitLatch(latch);

  assertFalse(resultRef.get() == null);
  assertTrue(resultRef.get().failed());
  assertTrue("Was expecting failure to be an instance of UnknownHostException", resultRef.get().cause() instanceof UnknownHostException);
 }
}

代码示例来源: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

@Override
public void beforeStartingVertx(VertxOptions options) {
 beforeStartingVertxInvoked = true;
 this.options = options;
 if (clusterHost != null) {
  options.setClusterHost(clusterHost);
  options.setClusterPort(clusterPort);
  options.setClusterPublicHost(clusterPublicHost);
  options.setClusterPublicPort(clusterPublicPort);
  super.beforeStartingVertx(options);
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

.setClusterHost(clusterHost).setClusterPort(clusterPort)
 .setClusterPublicHost(clusterPublicHost);
if (clusterPublicPort != -1) {

代码示例来源:origin: io.vertx/vertx-core

case "clusterHost":
 if (member.getValue() instanceof String) {
  obj.setClusterHost((String)member.getValue());

代码示例来源:origin: io.vertx/vertx-core

AtomicReference<AsyncResult<Vertx>> result = new AtomicReference<>();
options.setClusterHost(clusterHost).setClusterPort(clusterPort).setClustered(true);
if (ha) {
 String haGroup = args.map.get("-hagroup");

代码示例来源:origin: eclipse-vertx/vert.x

options.setWorkerPoolSize(workerPoolSize);
options.setBlockedThreadCheckInterval(blockedThreadCheckInterval);
options.setClusterHost(clusterHost);
options.setClusterPublicHost(clusterPublicHost);
options.setClusterPingInterval(clusterPingInterval);

代码示例来源:origin: io.vertx/vertx-core

@Test
 public void testCallbackInvokedOnFailure() throws Exception {

  // will trigger java.net.UnknownHostException
  String hostName = "zoom.zoom.zen.tld";

  VertxOptions options = new VertxOptions()
   .setClusterManager(new FakeClusterManager())
   .setClusterHost(hostName);

  AtomicReference<AsyncResult<Vertx>> resultRef = new AtomicReference<>();

  CountDownLatch latch = new CountDownLatch(1);
  Vertx.clusteredVertx(options, ar -> {
   resultRef.set(ar);
   latch.countDown();
  });
  awaitLatch(latch);

  assertFalse(resultRef.get() == null);
  assertTrue(resultRef.get().failed());
  assertTrue("Was expecting failure to be an instance of UnknownHostException", resultRef.get().cause() instanceof UnknownHostException);
 }
}

代码示例来源:origin: io.vertx/vertx-core

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: io.vertx/vertx-core

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: io.vertx/vertx-core

@Override
public void beforeStartingVertx(VertxOptions options) {
 beforeStartingVertxInvoked = true;
 this.options = options;
 if (clusterHost != null) {
  options.setClusterHost(clusterHost);
  options.setClusterPort(clusterPort);
  options.setClusterPublicHost(clusterPublicHost);
  options.setClusterPublicPort(clusterPublicPort);
  super.beforeStartingVertx(options);
 }
}

代码示例来源:origin: io.vertx/vertx-core

.setClusterHost(clusterHost).setClusterPort(clusterPort)
 .setClusterPublicHost(clusterPublicHost);
if (clusterPublicPort != -1) {

代码示例来源:origin: eclipse-vertx/vert.x

assertEquals(options, options.setClusterHost(randString));
assertEquals(randString, options.getClusterHost());
assertEquals(null, options.getClusterPublicHost());

代码示例来源:origin: io.vertx/vertx-service-discovery

@Before
public void setUp() {
 System.setProperty("vertx-service-discovery-backend-local", "true");
 backend = new DefaultServiceDiscoveryBackend();
 Vertx.clusteredVertx(new VertxOptions().setClusterHost("127.0.0.1"), ar -> {
  backend.init(ar.result(), new JsonObject());
  vertx = ar.result();
 });
 await().until(() -> vertx != null);
}

代码示例来源:origin: io.vertx/vertx-service-discovery

@Before
public void setUp() {
 backend = new DefaultServiceDiscoveryBackend();
 Vertx.clusteredVertx(new VertxOptions().setClusterHost("127.0.0.1"), ar -> {
  backend.init(ar.result(), new JsonObject());
  vertx = ar.result();
 });
 await().until(() -> vertx != null);
}

代码示例来源:origin: io.vertx/vertx-core

options.setWorkerPoolSize(workerPoolSize);
options.setBlockedThreadCheckInterval(blockedThreadCheckInterval);
options.setClusterHost(clusterHost);
options.setClusterPublicHost(clusterPublicHost);
options.setClusterPingInterval(clusterPingInterval);

代码示例来源:origin: io.vertx/vertx-core

assertEquals(options, options.setClusterHost(randString));
assertEquals(randString, options.getClusterHost());
assertEquals(null, options.getClusterPublicHost());

相关文章

VertxOptions类方法