org.eclipse.jetty.client.HttpClient.setMaxRequestsQueuedPerDestination()方法的使用及代码示例

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

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

HttpClient.setMaxRequestsQueuedPerDestination介绍

[英]Sets the max number of requests that may be queued to a destination.

If this HttpClient performs a high rate of requests to a destination, and all the connections managed by that destination are busy with other requests, then new requests will be queued up in the destination. This parameter controls how many requests can be queued before starting to reject them. If this HttpClient is used for load testing, it is common to have this parameter set to a high value, although this may impact latency (requests sit in the queue for a long time before being sent).
[中]设置可排队到目标的最大请求数。
如果此HttpClient对目标执行高速率的请求,并且该目标管理的所有连接都忙于其他请求,则新请求将在目标中排队。此参数控制在开始拒绝请求之前可以排队的请求数。如果此HttpClient用于负载测试,通常会将此参数设置为高值,尽管这可能会影响延迟(请求在发送之前在队列中放置很长时间)。

代码示例

代码示例来源:origin: apache/incubator-druid

httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS);
httpClient.setRequestBufferSize(config.getRequestBuffersize());

代码示例来源:origin: labsai/EDDI

@Provides
@Singleton
public HttpClient provideHttpClient(ExecutorService executorService,
                  @Named("httpClient.maxConnectionsQueued") Integer maxConnectionsQueued,
                  @Named("httpClient.maxConnectionPerRoute") Integer maxConnectionPerRoute,
                  @Named("httpClient.requestBufferSize") Integer requestBufferSize,
                  @Named("httpClient.responseBufferSize") Integer responseBufferSize,
                  @Named("httpClient.maxRedirects") Integer maxRedirects,
                  @Named("httpClient.trustAllCertificates") Boolean trustAllCertificates) {
  try {
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setTrustAll(trustAllCertificates);
    HttpClient httpClient = new HttpClient(sslContextFactory);
    httpClient.setExecutor(executorService);
    httpClient.setMaxConnectionsPerDestination(maxConnectionsQueued);
    httpClient.setMaxRequestsQueuedPerDestination(maxConnectionPerRoute);
    httpClient.setRequestBufferSize(requestBufferSize);
    httpClient.setResponseBufferSize(responseBufferSize);
    httpClient.setMaxRedirects(maxRedirects);
    httpClient.start();
    registerHttpClientShutdownHook(httpClient);
    return httpClient;
  } catch (Exception e) {
    System.out.println(Arrays.toString(e.getStackTrace()));
    throw new RuntimeException(e.getLocalizedMessage(), e);
  }
}

代码示例来源:origin: isucon/isucon5-qualify

private HttpClient client() {
 HttpField agent = new HttpField("User-Agent", config.agent);
 HttpClient httpClient = new HttpClient();
 httpClient.setFollowRedirects(false);
 httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST);
 httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST);
 httpClient.setUserAgentField(agent);
 httpClient.setCookieStore(new HttpCookieStore.Empty());
 return httpClient;
}

代码示例来源:origin: isucon/isucon5-final

private HttpClient client() {
  HttpField agent = new HttpField("User-Agent", config.agent);
  // TODO: non-keepalived client connections
  HttpClient httpClient = new HttpClient();
  httpClient.setFollowRedirects(false);
  httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST);
  httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST);
  httpClient.setUserAgentField(agent);
  httpClient.setCookieStore(new HttpCookieStore.Empty());
  return httpClient;
}

代码示例来源:origin: io.druid/druid-server

httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT);
httpClient.setRequestBufferSize(config.getRequestBuffersize());

代码示例来源:origin: org.apache.druid/druid-server

httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS);
httpClient.setRequestBufferSize(config.getRequestBuffersize());

代码示例来源:origin: com.cisco.oss.foundation/http-client-jetty

@Override
protected void configureClient() {
  boolean addSslSupport = StringUtils.isNotEmpty(metadata.getKeyStorePath()) && StringUtils.isNotEmpty(metadata.getKeyStorePassword());
  if(addSslSupport){
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(metadata.getKeyStorePath());
    sslContextFactory.setKeyStorePassword(metadata.getKeyStorePassword());
    boolean addTrustSupport = StringUtils.isNotEmpty(metadata.getTrustStorePath()) && StringUtils.isNotEmpty(metadata.getTrustStorePassword());
    if(addTrustSupport){
      sslContextFactory.setTrustStorePath(metadata.getTrustStorePath());
      sslContextFactory.setTrustStorePassword(metadata.getTrustStorePassword());
    }else{
      sslContextFactory.setTrustAll(true);
    }
    httpClient = new  HttpClient(sslContextFactory);
  }
  httpClient.setConnectTimeout(metadata.getConnectTimeout());
  httpClient.setIdleTimeout(metadata.getIdleTimeout());
  httpClient.setMaxConnectionsPerDestination(metadata.getMaxConnectionsPerAddress());
  httpClient.setMaxRequestsQueuedPerDestination(metadata.getMaxQueueSizePerAddress());
  httpClient.setFollowRedirects(followRedirects);
  try {
    httpClient.start();
  } catch (Exception e) {
    throw new ClientException("failed to start jetty http client: " + e, e);
  }
}

代码示例来源:origin: allegro/hermes

public HttpClient createClientForHttp2() {
  ExecutorService executor = executorFactory.getExecutorService("jetty-http2-client",
      configFactory.getIntProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_SIZE),
      configFactory.getBooleanProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_MONITORING));
  HTTP2Client h2Client = new HTTP2Client();
  h2Client.setExecutor(executor);
  HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client);
  HttpClient client = new HttpClient(transport, createSslContextFactory());
  client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE));
  client.setCookieStore(new HttpCookieStore.Empty());
  return client;
}

代码示例来源:origin: allegro/hermes

public HttpClient createClientForHttp1(String name) {
  ExecutorService executor = executorFactory.getExecutorService(name,
      configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE),
      configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING));
  HttpClient client = new HttpClient(createSslContextFactory());
  client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION));
  client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE));
  client.setExecutor(executor);
  client.setCookieStore(new HttpCookieStore.Empty());
  return client;
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers

public HttpClient createClientForHttp2() {
  ExecutorService executor = executorFactory.getExecutorService("jetty-http2-client",
      configFactory.getIntProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_SIZE),
      configFactory.getBooleanProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_MONITORING));
  HTTP2Client h2Client = new HTTP2Client();
  h2Client.setExecutor(executor);
  HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client);
  HttpClient client = new HttpClient(transport, createSslContextFactory());
  client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE));
  client.setCookieStore(new HttpCookieStore.Empty());
  return client;
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers

public HttpClient createClientForHttp1(String name) {
  ExecutorService executor = executorFactory.getExecutorService(name,
      configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE),
      configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING));
  HttpClient client = new HttpClient(createSslContextFactory());
  client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION));
  client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE));
  client.setExecutor(executor);
  client.setCookieStore(new HttpCookieStore.Empty());
  return client;
}

代码示例来源:origin: org.attribyte/attribyte-http

this.httpClient.setAddressResolutionTimeout(options.getIntProperty("addressResolutionTimeout", 15000));
  this.httpClient.setMaxRedirects(options.getIntProperty("maxRedirects", 8));
  this.httpClient.setMaxRequestsQueuedPerDestination(options.getIntProperty("maxRequestsQueuedPerDestination", 1024));
} else {
  SslContextFactory sslContextFactory = new SslContextFactory();

代码示例来源:origin: airlift/airlift

httpClient.setMaxRequestsQueuedPerDestination(config.getMaxRequestsQueuedPerDestination());

代码示例来源:origin: com.proofpoint.platform/http-client

httpClient.setResponseBufferSize(toIntExact(config.getResponseBufferSize().toBytes()));
httpClient.setMaxRequestsQueuedPerDestination(config.getMaxRequestsQueuedPerDestination());
httpClient.setMaxConnectionsPerDestination(config.getMaxConnectionsPerServer());

相关文章

HttpClient类方法