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

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

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

HttpClient.setThreadPool介绍

[英]Set the ThreadPool. The threadpool passed is added via #addBean(Object) so that it's lifecycle may be managed as a AggregateLifeCycle.
[中]设置线程池。传递的线程池通过#addBean(对象)添加,因此它的生命周期可以作为AggregateLifeCycle进行管理。

代码示例

代码示例来源:origin: 4thline/cling

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
  this.configuration = configuration;
  log.info("Starting Jetty HttpClient...");
  client = new HttpClient();
  // Jetty client needs threads for its internal expiration routines, which we don't need but
  // can't disable, so let's abuse the request executor service for this
  client.setThreadPool(
    new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
      @Override
      protected void doStop() throws Exception {
        // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
      }
    }
  );
  // These are some safety settings, we should never run into these timeouts as we
  // do our own expiration checking
  client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setMaxRetries(configuration.getRequestRetryCount());
  try {
    client.start();
  } catch (Exception ex) {
    throw new InitializationException(
      "Could not start Jetty HTTP client: " + ex, ex
    );
  }
}

代码示例来源:origin: kingthy/TVRemoteIME

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
  this.configuration = configuration;
  log.info("Starting Jetty HttpClient...");
  client = new HttpClient();
  // Jetty client needs threads for its internal expiration routines, which we don't need but
  // can't disable, so let's abuse the request executor service for this
  client.setThreadPool(
    new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
      @Override
      protected void doStop() throws Exception {
        // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
      }
    }
  );
  // These are some safety settings, we should never run into these timeouts as we
  // do our own expiration checking
  client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setMaxRetries(configuration.getRequestRetryCount());
  try {
    client.start();
  } catch (Exception ex) {
    throw new InitializationException(
      "Could not start Jetty HTTP client: " + ex, ex
    );
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

client.setThreadPool(new QueuedThreadPool(Integer.parseInt(t)));
client.setThreadPool(new QueuedThreadPool());

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

_client.setThreadPool(new QueuedThreadPool(Integer.parseInt(_maxThreads)));
_client.setThreadPool(new QueuedThreadPool());

代码示例来源:origin: org.fourthline.cling/cling-core

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
  this.configuration = configuration;
  log.info("Starting Jetty HttpClient...");
  client = new HttpClient();
  // Jetty client needs threads for its internal expiration routines, which we don't need but
  // can't disable, so let's abuse the request executor service for this
  client.setThreadPool(
    new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
      @Override
      protected void doStop() throws Exception {
        // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
      }
    }
  );
  // These are some safety settings, we should never run into these timeouts as we
  // do our own expiration checking
  client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setMaxRetries(configuration.getRequestRetryCount());
  try {
    client.start();
  } catch (Exception ex) {
    throw new InitializationException(
      "Could not start Jetty HTTP client: " + ex, ex
    );
  }
}

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

public org.eclipse.jetty.client.HttpClient createNewJettyClient() throws Exception {
  org.eclipse.jetty.client.HttpClient tempClient = new org.eclipse.jetty.client.HttpClient();
  QueuedThreadPool btp = new QueuedThreadPool();
  btp.setMaxThreads(getConfiguration().getJettyClientThreadPoolSize());
  tempClient.setThreadPool(btp);
  tempClient.setConnectorType(org.eclipse.jetty.client.HttpClient.CONNECTOR_SELECT_CHANNEL);
  tempClient.setTimeout(getConfiguration().getProviderExpirationTime());
  tempClient.setConnectTimeout(getConfiguration().getClientConnectTimeout());
  tempClient.setMaxConnectionsPerAddress(getConfiguration().getMaxConnectionsPerAddress());
  tempClient.start();
  return tempClient;
}

代码示例来源:origin: net.anthavio/hatatitla

public HttpClient buildHttpClient() {
  HttpClient client = new HttpClient();
  //client.setConnectBlocking(false);
  client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
  client.setConnectTimeout(getConnectTimeoutMillis());
  client.setTimeout(getReadTimeoutMillis());
  client.setMaxConnectionsPerAddress(getPoolMaximumSize());
  client.setThreadPool(new QueuedThreadPool(getPoolMaximumSize()));
  //client.setIdleTimeout(config.get???);
  if (getFollowRedirects()) {
    client.setMaxRedirects(10);
  }
  if (getAuthentication() != null) {
    Realm realm = new SimpleRealm("whatever", getAuthentication().getUsername(), getAuthentication().getPassword());
    client.setRealmResolver(new SimpleRealmResolver(realm));
  }
  return client;
}

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

ownClient = true;
jettyClient = new SSLManagedHttpClient();
jettyClient.setThreadPool(new QueuedThreadPool(getConfiguration().getJettyClientThreadPoolSize()));
jettyClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
if (proxyHost != null) {

相关文章

HttpClient类方法