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

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

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

VertxOptions.setPreferNativeTransport介绍

[英]Set wether to prefer the native transport to the JDK transport.
[中]设置是否更喜欢本机传输而不是JDK传输。

代码示例

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

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

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

case "preferNativeTransport":
 if (member.getValue() instanceof Boolean) {
  obj.setPreferNativeTransport((Boolean)member.getValue());

代码示例来源: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 testListenDomainSocketAddress() throws Exception {
 Vertx vx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
 Assume.assumeTrue("Native transport must be enabled", vx.isNativeTransportEnabled());
 NetClient netClient = vx.createNetClient();
 HttpServer httpserver = vx.createHttpServer().requestHandler(req -> req.response().end());
 File sockFile = TestUtils.tmpFile(".sock");
 SocketAddress sockAddress = SocketAddress.domainSocketAddress(sockFile.getAbsolutePath());
 httpserver.listen(sockAddress, onSuccess(server -> {
  netClient.connect(sockAddress, onSuccess(sock -> {
   sock.handler(buf -> {
    assertTrue("Response is not an http 200", buf.toString("UTF-8").startsWith("HTTP/1.1 200 OK"));
    testComplete();
   });
   sock.write("GET / HTTP/1.1\r\n\r\n");
  }));
 }));
 try {
  await();
 } finally {
  vx.close();
 }
}

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

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

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

case "preferNativeTransport":
 if (member.getValue() instanceof Boolean) {
  obj.setPreferNativeTransport((Boolean)member.getValue());

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

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

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

@Test
public void testListenDomainSocketAddress() throws Exception {
 Vertx vx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
 Assume.assumeTrue("Native transport must be enabled", vx.isNativeTransportEnabled());
 NetClient netClient = vx.createNetClient();
 HttpServer httpserver = vx.createHttpServer().requestHandler(req -> req.response().end());
 File sockFile = TestUtils.tmpFile(".sock");
 SocketAddress sockAddress = SocketAddress.domainSocketAddress(sockFile.getAbsolutePath());
 httpserver.listen(sockAddress, onSuccess(server -> {
  netClient.connect(sockAddress, onSuccess(sock -> {
   sock.handler(buf -> {
    assertTrue("Response is not an http 200", buf.toString("UTF-8").startsWith("HTTP/1.1 200 OK"));
    testComplete();
   });
   sock.write("GET / HTTP/1.1\r\n\r\n");
  }));
 }));
 try {
  await();
 } finally {
  vx.close();
 }
}

代码示例来源:origin: silentbalanceyh/vertx-zero

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

代码示例来源:origin: cn.vertxup/vertx-co

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

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Configure the Vertx options according to our settings.
 * 
 * @param options The options to configure.
 */
public void configureVertx(final VertxOptions options) {
  options.setPreferNativeTransport(this.preferNative);
  if (this.enableMetrics) {
    options.setMetricsOptions(new MetricsOptions().setEnabled(true));
  }
}

代码示例来源:origin: reactiverse/reactive-pg-client

/**
 * Create a connection pool to the database configured with the given {@code options}.
 *
 * @param options the options for creating the pool
 * @return the connection pool
 */
static PgPool pool(PgPoolOptions options) {
 if (Vertx.currentContext() != null) {
  throw new IllegalStateException("Running in a Vertx context => use PgPool#pool(Vertx, PgPoolOptions) instead");
 }
 VertxOptions vertxOptions = new VertxOptions();
 if (options.isUsingDomainSocket()) {
  vertxOptions.setPreferNativeTransport(true);
 }
 Vertx vertx = Vertx.vertx(vertxOptions);
 return new PgPoolImpl(vertx, true, options);
}

代码示例来源:origin: io.reactiverse/reactive-pg-client

/**
 * Create a connection pool to the database configured with the given {@code options}.
 *
 * @param options the options for creating the pool
 * @return the connection pool
 */
static PgPool pool(PgPoolOptions options) {
 if (Vertx.currentContext() != null) {
  throw new IllegalStateException("Running in a Vertx context => use PgPool#pool(Vertx, PgPoolOptions) instead");
 }
 VertxOptions vertxOptions = new VertxOptions();
 if (options.isUsingDomainSocket()) {
  vertxOptions.setPreferNativeTransport(true);
 }
 Vertx vertx = Vertx.vertx(vertxOptions);
 return new PgPoolImpl(vertx, true, options);
}

代码示例来源:origin: io.vertx/vertx-mysql-postgresql-client-jasync

@BeforeClass
public static void setUp() {
 boolean useNativeTransport = Boolean.parseBoolean(System.getProperty("vertx.useNativeTransport", "false"));
 vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(useNativeTransport));
}

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

@BeforeClass
public static void setUp() {
 boolean useNativeTransport = Boolean.parseBoolean(System.getProperty("vertx.useNativeTransport", "false"));
 vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(useNativeTransport));
}

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

@Test
public void testNativeTransportEnabled(TestContext ctx) {
 assumeNativeTransport();
 testInternal(ctx, Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)));
}

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

@Test
public void testNativeTransportDisabled(TestContext ctx) {
 assumeNativeTransport();
 testInternal(ctx, Vertx.vertx(new VertxOptions().setPreferNativeTransport(false)));
}

代码示例来源:origin: reactiverse/reactive-pg-client

@BeforeClass
public static void beforeClass() throws Exception {
 Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
 boolean nativeTransportEnabled = vertx.isNativeTransportEnabled();
 vertx.close();
 options = PgTestBase.startPg(nativeTransportEnabled, false);
 if (unixSocketDirectory != null && !unixSocketDirectory.isEmpty()) {
  options.setHost(unixSocketDirectory);
 }
 if (unixSocketPort != null && !unixSocketPort.isEmpty()) {
  options.setPort(Integer.parseInt(unixSocketPort));
 }
}

代码示例来源:origin: eclipse/hono

/**
 * Configures the Vert.x options based on this object's property values.
 * 
 * @param options The options to configure.
 * @return The (updated) options.
 */
public VertxOptions configureVertx(final VertxOptions options) {
  options.setPreferNativeTransport(this.preferNative);
  if (this.enableMetrics) {
    options.setMetricsOptions(new MetricsOptions().setEnabled(true));
  }
  options.setMaxEventLoopExecuteTime(maxEventLoopExecuteTimeMillis * 1000000L);
  options.setWarningExceptionTime(maxEventLoopExecuteTimeMillis * 1500000L);
  options.setAddressResolverOptions(new AddressResolverOptions()
      .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately
      .setCacheMaxTimeToLive(0) // support DNS based service resolution
      .setQueryTimeout(dnsQueryTimeout));
  return options;
}

代码示例来源:origin: reactiverse/reactive-pg-client

@Test
public void connectWithVertxInstance(TestContext context) {
 assumeTrue(options.isUsingDomainSocket());
 Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
 try {
  client = PgClient.pool(vertx, new PgPoolOptions(options));
  Async async = context.async();
  client.getConnection(context.asyncAssertSuccess(pgConnection -> {
   async.complete();
   pgConnection.close();
  }));
  async.await();
 } finally {
  vertx.close();
 }
}

相关文章

VertxOptions类方法