org.vertx.java.core.http.HttpClient.setMaxPoolSize()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(172)

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

HttpClient.setMaxPoolSize介绍

[英]Set the maximum pool size

The client will maintain up to maxConnections HTTP connections in an internal pool
[中]设置最大池大小
客户端将在内部池中维护最多maxConnections HTTP连接

代码示例

代码示例来源:origin: vert-x/mod-lang-php

/**
 * Sets the max connection pool size.
 */
public HttpClient maxPoolSize(Env env, NumberValue size) {
 PhpTypes.assertNotNull(env, size, "Size to Vertx\\Http\\HttpClient::maxPoolSize() must be an integer.");
 client.setMaxPoolSize(size.toInt());
 return this;
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: io.fastjson/etcd-client

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

相关文章