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

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

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

VertxOptions.<init>介绍

[英]Default constructor
[中]默认构造函数

代码示例

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

@Override
public Vertx vertx() {
 return vertx(new VertxOptions());
}

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

protected VertxOptions getOptions() {
 VertxOptions options = new VertxOptions();
 options.setPreferNativeTransport(USE_NATIVE_TRANSPORT);
 return options;
}

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

@Override
protected void startNodes(int numNodes) {
 super.startNodes(numNodes, new VertxOptions().setEventBusOptions(options));
}

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

@Test
public void testResolveFromFile() {
 File f = new File(new File(new File(new File("src"), "test"), "resources"), "hosts_config.txt");
 VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath(f.getAbsolutePath())));
 vertx.resolveAddress("server.net", onSuccess(addr -> {
  assertEquals("192.168.0.15", addr.getHostAddress());
  assertEquals("server.net", addr.getHostName());
  testComplete();
 }));
 await();
}

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

protected void createNodes(int nodes) {
 startNodes(nodes, new VertxOptions().setHAEnabled(true));
 aliveNodes = new CopyOnWriteArrayList<>();
 for (int i = 0; i < nodes; i++) {
  aliveNodes.add(i);
  int pos = i;
  ((VertxInternal)vertices[i]).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
   failedOverOnto(pos);
  });
 }
 deploymentSnapshots = new Set[nodes];
}

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

@Test
public void testFactory() throws Exception {
 AtomicReference<Thread> metricsThread = new AtomicReference<>();
 AtomicReference<Context> metricsContext = new AtomicReference<>();
 VertxMetricsFactory factory = (options) -> {
  metricsThread.set(Thread.currentThread());
  metricsContext.set(Vertx.currentContext());
  return DummyVertxMetrics.INSTANCE;
 };
 vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(factory)));
 assertSame(Thread.currentThread(), metricsThread.get());
 assertNull(metricsContext.get());
}

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

@Override
protected VertxOptions getOptions() {
 return new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(false)); // Just to be explicit
}

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

@Test
 public void testNullFileSystemOptions() {
  VertxOptions options = new VertxOptions().setFileSystemOptions(null);
  options.isFileResolverCachingEnabled();
  options.setFileResolverCachingEnabled(true);
 }
}

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

@Test
public void testCreateVertxWithOptions() {
 VertxOptions options = new VertxOptions();
 Vertx vertx = vertx(options);
 assertNotNull(vertx);
 assertFalse(vertx.isClustered());
}

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

@Test
public void testResolveFromBuffer() {
 VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsValue(Buffer.buffer("192.168.0.15 server.net"))));
 vertx.resolveAddress("server.net", onSuccess(addr -> {
  assertEquals("192.168.0.15", addr.getHostAddress());
  assertEquals("server.net", addr.getHostName());
  testComplete();
 }));
 await();
}

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

@Test
public void testFallbackOnJDK() {
 testNetServer(new VertxOptions().setPreferNativeTransport(true));
 assertFalse(vertx.isNativeTransportEnabled());
}

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

@Test
public void testMetricsEnabledWithoutConfig() {
 vertx.close();
 vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true)));
 VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
 assertNull(metrics);
}

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

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyName() throws Exception {
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "nosuchproperty", "123");
 // Should be ignored
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
}

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

@Test
public void testInvalidHostsConfig() {
 try {
  AddressResolverOptions options = new AddressResolverOptions().setHostsPath("whatever.txt");
  vertx(new VertxOptions().setAddressResolverOptions(options));
  fail();
 } catch (VertxException ignore) {
 }
}

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

@Test
public void testResolveFromClasspath() {
 VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
 vertx.resolveAddress("server.net", onSuccess(addr -> {
  assertEquals("192.168.0.15", addr.getHostAddress());
  assertEquals("server.net", addr.getHostName());
  testComplete();
 }));
 await();
}

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

@Test
public void testCaseInsensitiveResolveFromHosts() {
 VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
 vertx.resolveAddress("SERVER.NET", onSuccess(addr -> {
  assertEquals("192.168.0.15", addr.getHostAddress());
  assertEquals("server.net", addr.getHostName());
  testComplete();
 }));
 await();
}

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

@Test
public void testSetMetricsInstance() {
 DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE;
 vertx.close();
 vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics))));
 assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}

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

@Test
public void testMetricsFromServiceLoader() {
 vertx.close();
 VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
 vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
 VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
 assertNotNull(metrics);
 assertTrue(metrics instanceof FakeVertxMetrics);
}

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

@Test
public void testSetMetricsInstanceTakesPrecedenceOverServiceLoader() {
 DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE;
 vertx.close();
 VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics)));
 vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
 assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}

相关文章

VertxOptions类方法