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

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

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

VertxOptions.getClusterPublicHost介绍

[英]Get the public facing hostname to be used when clustering.
[中]获取群集时要使用的面向公众的主机名。

代码示例

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

json.put("clusterPingReplyInterval", obj.getClusterPingReplyInterval());
json.put("clusterPort", obj.getClusterPort());
if (obj.getClusterPublicHost() != null) {
 json.put("clusterPublicHost", obj.getClusterPublicHost());

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

@Test
public void testConfigureClusterPublicHostPortFromCommandLine() throws Exception {
 int clusterPublicPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster", "--cluster-public-host", "127.0.0.1", "--cluster-public-port", Integer.toString(clusterPublicPort)};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterPublicHost());
 assertEquals(clusterPublicPort, launcher.options.getClusterPublicPort());
}

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

clusterPort = options.getClusterPort();
if (!Objects.equals(options.getClusterPublicHost(), VertxOptions.DEFAULT_CLUSTER_PUBLIC_HOST)) {
 clusterPublicHost = options.getClusterPublicHost();

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

@Test
public void testConfigureClusterHostPortFromProperties() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterHost", "127.0.0.1");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterPort", Integer.toString(clusterPort));
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(clusterPort, launcher.options.getClusterPort());
 assertNull(launcher.options.getClusterPublicHost());
 assertEquals(-1, launcher.options.getClusterPublicPort());
}

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

private void testConfigureFromJson(boolean jsonFile) throws Exception {
 JsonObject json = new JsonObject()
  .put("eventLoopPoolSize", 123)
  .put("maxEventLoopExecuteTime", 123767667)
  .put("metricsOptions", new JsonObject().put("enabled", true))
  .put("eventBusOptions", new JsonObject().put("clustered", true).put("clusterPublicHost", "mars"))
  .put("haGroup", "somegroup")
  .put("maxEventLoopExecuteTimeUnit", "SECONDS");
 String optionsArg;
 if (jsonFile) {
  File file = testFolder.newFile();
  Files.write(file.toPath(), json.toBuffer().getBytes());
  optionsArg = file.getPath();
 } else {
  optionsArg = json.toString();
 }
 MyLauncher launcher = new MyLauncher();
 String[] args = new String[]{"run", "java:" + TestVerticle.class.getCanonicalName(), "-options", optionsArg};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 assertEquals(123, opts.getEventLoopPoolSize(), 0);
 assertEquals(123767667L, opts.getMaxEventLoopExecuteTime());
 assertEquals(true, opts.getMetricsOptions().isEnabled());
 assertEquals(true, opts.isClustered());
 assertEquals("mars", opts.getClusterPublicHost());
 assertEquals("somegroup", opts.getHAGroup());
 assertEquals(TimeUnit.SECONDS, opts.getMaxEventLoopExecuteTimeUnit());
}

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

@Test
public void testConfigureClusterHostPortFromCommandLine() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster", "--cluster-host", "127.0.0.1", "--cluster-port", Integer.toString(clusterPort)};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(clusterPort, launcher.options.getClusterPort());
 assertNull(launcher.options.getClusterPublicHost());
 assertEquals(-1, launcher.options.getClusterPublicPort());
}

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

@Test
public void testOverrideClusterHostPortFromProperties() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 int newClusterPort = TestUtils.randomHighPortInt();
 int newClusterPublicPort = TestUtils.randomHighPortInt();
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterHost", "127.0.0.2");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterPort", Integer.toString(clusterPort));
 MyLauncher launcher = new MyLauncher();
 launcher.clusterHost = "127.0.0.1";
 launcher.clusterPort = newClusterPort;
 launcher.clusterPublicHost = "127.0.0.3";
 launcher.clusterPublicPort = newClusterPublicPort;
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(newClusterPort, launcher.options.getClusterPort());
 assertEquals("127.0.0.3", launcher.options.getClusterPublicHost());
 assertEquals(newClusterPublicPort, launcher.options.getClusterPublicPort());
}

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

@Test
public void testOverrideClusterHostPortFromCommandLine() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 int clusterPublicPort = TestUtils.randomHighPortInt();
 int newClusterPort = TestUtils.randomHighPortInt();
 int newClusterPublicPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 launcher.clusterHost = "127.0.0.1";
 launcher.clusterPort = newClusterPort;
 launcher.clusterPublicHost = "127.0.0.3";
 launcher.clusterPublicPort = newClusterPublicPort;
 String[] args = {
  "run", "java:" + TestVerticle.class.getCanonicalName(),
  "-cluster",
  "--cluster-host", "127.0.0.2", "--cluster-port", Integer.toString(clusterPort),
  "--cluster-public-host", "127.0.0.4", "--cluster-public-port", Integer.toString(clusterPublicPort)
 };
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(newClusterPort, launcher.options.getClusterPort());
 assertEquals("127.0.0.3", launcher.options.getClusterPublicHost());
 assertEquals(newClusterPublicPort, launcher.options.getClusterPublicPort());
}

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

assertEquals(1000, options.getBlockedThreadCheckInterval());
assertEquals("localhost", options.getClusterHost());
assertNull(options.getClusterPublicHost());
assertEquals(null, options.getClusterManager());
assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime());
assertEquals(clusterPort, options.getClusterPort());
assertEquals(clusterPublicPort, options.getClusterPublicPort());
assertEquals(clusterPublicHost, options.getClusterPublicHost());
assertEquals(clusterPingInterval, options.getClusterPingInterval());
assertEquals(clusterPingReplyInterval, options.getClusterPingReplyInterval());

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

@Test
public void testDefaultJsonOptions() {
 VertxOptions def = new VertxOptions();
 VertxOptions json = new VertxOptions(new JsonObject());
 assertEquals(def.getEventLoopPoolSize(), json.getEventLoopPoolSize());
 assertEquals(def.getWorkerPoolSize(), json.getWorkerPoolSize());
 assertEquals(def.isClustered(), json.isClustered());
 assertEquals(def.getClusterHost(), json.getClusterHost());
 assertEquals(def.getClusterPublicHost(), json.getClusterPublicHost());
 assertEquals(def.getClusterPublicPort(), json.getClusterPublicPort());
 assertEquals(def.getClusterPingInterval(), json.getClusterPingInterval());
 assertEquals(def.getClusterPingReplyInterval(), json.getClusterPingReplyInterval());
 assertEquals(def.getBlockedThreadCheckInterval(), json.getBlockedThreadCheckInterval());
 assertEquals(def.getMaxEventLoopExecuteTime(), json.getMaxEventLoopExecuteTime());
 assertEquals(def.getMaxWorkerExecuteTime(), json.getMaxWorkerExecuteTime());
 assertEquals(def.getInternalBlockingPoolSize(), json.getInternalBlockingPoolSize());
 assertEquals(def.isHAEnabled(), json.isHAEnabled());
 assertEquals(def.getQuorumSize(), json.getQuorumSize());
 assertEquals(def.getHAGroup(), json.getHAGroup());
 assertEquals(def.getWarningExceptionTime(), json.getWarningExceptionTime());
 assertEquals(def.isFileResolverCachingEnabled(), json.isFileResolverCachingEnabled());
 assertEquals(def.getMaxEventLoopExecuteTimeUnit(), json.getMaxEventLoopExecuteTimeUnit());
 assertEquals(def.getMaxWorkerExecuteTimeUnit(), json.getMaxWorkerExecuteTimeUnit());
 assertEquals(def.getWarningExceptionTimeUnit(), json.getWarningExceptionTimeUnit());
 assertEquals(def.getBlockedThreadCheckIntervalUnit(), json.getBlockedThreadCheckIntervalUnit());
}

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

assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval());
assertEquals(clusterHost, options.getClusterHost());
assertEquals(clusterPublicHost, options.getClusterPublicHost());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());

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

@Test
public void testConfigureClusterPublicHostPortFromCommandLine() throws Exception {
 int clusterPublicPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster", "--cluster-public-host", "127.0.0.1", "--cluster-public-port", Integer.toString(clusterPublicPort)};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterPublicHost());
 assertEquals(clusterPublicPort, launcher.options.getClusterPublicPort());
}

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

@Test
public void testConfigureClusterHostPortFromProperties() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterHost", "127.0.0.1");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterPort", Integer.toString(clusterPort));
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(clusterPort, launcher.options.getClusterPort());
 assertNull(launcher.options.getClusterPublicHost());
 assertEquals(-1, launcher.options.getClusterPublicPort());
}

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

private void testConfigureFromJson(boolean jsonFile) throws Exception {
 JsonObject json = new JsonObject()
  .put("eventLoopPoolSize", 123)
  .put("maxEventLoopExecuteTime", 123767667)
  .put("metricsOptions", new JsonObject().put("enabled", true))
  .put("eventBusOptions", new JsonObject().put("clustered", true).put("clusterPublicHost", "mars"))
  .put("haGroup", "somegroup")
  .put("maxEventLoopExecuteTimeUnit", "SECONDS");
 String optionsArg;
 if (jsonFile) {
  File file = testFolder.newFile();
  Files.write(file.toPath(), json.toBuffer().getBytes());
  optionsArg = file.getPath();
 } else {
  optionsArg = json.toString();
 }
 MyLauncher launcher = new MyLauncher();
 String[] args = new String[]{"run", "java:" + TestVerticle.class.getCanonicalName(), "-options", optionsArg};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 assertEquals(123, opts.getEventLoopPoolSize(), 0);
 assertEquals(123767667L, opts.getMaxEventLoopExecuteTime());
 assertEquals(true, opts.getMetricsOptions().isEnabled());
 assertEquals(true, opts.isClustered());
 assertEquals("mars", opts.getClusterPublicHost());
 assertEquals("somegroup", opts.getHAGroup());
 assertEquals(TimeUnit.SECONDS, opts.getMaxEventLoopExecuteTimeUnit());
}

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

@Test
public void testConfigureClusterHostPortFromCommandLine() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster", "--cluster-host", "127.0.0.1", "--cluster-port", Integer.toString(clusterPort)};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(clusterPort, launcher.options.getClusterPort());
 assertNull(launcher.options.getClusterPublicHost());
 assertEquals(-1, launcher.options.getClusterPublicPort());
}

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

@Test
public void testOverrideClusterHostPortFromProperties() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 int newClusterPort = TestUtils.randomHighPortInt();
 int newClusterPublicPort = TestUtils.randomHighPortInt();
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterHost", "127.0.0.2");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "clusterPort", Integer.toString(clusterPort));
 MyLauncher launcher = new MyLauncher();
 launcher.clusterHost = "127.0.0.1";
 launcher.clusterPort = newClusterPort;
 launcher.clusterPublicHost = "127.0.0.3";
 launcher.clusterPublicPort = newClusterPublicPort;
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(newClusterPort, launcher.options.getClusterPort());
 assertEquals("127.0.0.3", launcher.options.getClusterPublicHost());
 assertEquals(newClusterPublicPort, launcher.options.getClusterPublicPort());
}

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

@Test
public void testOverrideClusterHostPortFromCommandLine() throws Exception {
 int clusterPort = TestUtils.randomHighPortInt();
 int clusterPublicPort = TestUtils.randomHighPortInt();
 int newClusterPort = TestUtils.randomHighPortInt();
 int newClusterPublicPort = TestUtils.randomHighPortInt();
 MyLauncher launcher = new MyLauncher();
 launcher.clusterHost = "127.0.0.1";
 launcher.clusterPort = newClusterPort;
 launcher.clusterPublicHost = "127.0.0.3";
 launcher.clusterPublicPort = newClusterPublicPort;
 String[] args = {
  "run", "java:" + TestVerticle.class.getCanonicalName(),
  "-cluster",
  "--cluster-host", "127.0.0.2", "--cluster-port", Integer.toString(clusterPort),
  "--cluster-public-host", "127.0.0.4", "--cluster-public-port", Integer.toString(clusterPublicPort)
 };
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 assertEquals("127.0.0.1", launcher.options.getClusterHost());
 assertEquals(newClusterPort, launcher.options.getClusterPort());
 assertEquals("127.0.0.3", launcher.options.getClusterPublicHost());
 assertEquals(newClusterPublicPort, launcher.options.getClusterPublicPort());
}

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

assertEquals(options, options.setClusterHost(randString));
assertEquals(randString, options.getClusterHost());
assertEquals(null, options.getClusterPublicHost());
randString = TestUtils.randomUnicodeString(100);
assertEquals(options, options.setClusterPublicHost(randString));
assertEquals(randString, options.getClusterPublicHost());
assertEquals(20000, options.getClusterPingInterval());
long randomLong = TestUtils.randomPositiveLong();

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

@Test
public void testDefaultJsonOptions() {
 VertxOptions def = new VertxOptions();
 VertxOptions json = new VertxOptions(new JsonObject());
 assertEquals(def.getEventLoopPoolSize(), json.getEventLoopPoolSize());
 assertEquals(def.getWorkerPoolSize(), json.getWorkerPoolSize());
 assertEquals(def.isClustered(), json.isClustered());
 assertEquals(def.getClusterHost(), json.getClusterHost());
 assertEquals(def.getClusterPublicHost(), json.getClusterPublicHost());
 assertEquals(def.getClusterPublicPort(), json.getClusterPublicPort());
 assertEquals(def.getClusterPingInterval(), json.getClusterPingInterval());
 assertEquals(def.getClusterPingReplyInterval(), json.getClusterPingReplyInterval());
 assertEquals(def.getBlockedThreadCheckInterval(), json.getBlockedThreadCheckInterval());
 assertEquals(def.getMaxEventLoopExecuteTime(), json.getMaxEventLoopExecuteTime());
 assertEquals(def.getMaxWorkerExecuteTime(), json.getMaxWorkerExecuteTime());
 assertEquals(def.getInternalBlockingPoolSize(), json.getInternalBlockingPoolSize());
 assertEquals(def.isHAEnabled(), json.isHAEnabled());
 assertEquals(def.getQuorumSize(), json.getQuorumSize());
 assertEquals(def.getHAGroup(), json.getHAGroup());
 assertEquals(def.getWarningExceptionTime(), json.getWarningExceptionTime());
 assertEquals(def.isFileResolverCachingEnabled(), json.isFileResolverCachingEnabled());
 assertEquals(def.getMaxEventLoopExecuteTimeUnit(), json.getMaxEventLoopExecuteTimeUnit());
 assertEquals(def.getMaxWorkerExecuteTimeUnit(), json.getMaxWorkerExecuteTimeUnit());
 assertEquals(def.getWarningExceptionTimeUnit(), json.getWarningExceptionTimeUnit());
 assertEquals(def.getBlockedThreadCheckIntervalUnit(), json.getBlockedThreadCheckIntervalUnit());
}

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

assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval());
assertEquals(clusterHost, options.getClusterHost());
assertEquals(clusterPublicHost, options.getClusterPublicHost());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());

相关文章

VertxOptions类方法