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

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

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

HttpClient.setExecutor介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Constructor with an {@link JettyResourceFactory} that will manage shared resources.
 * @param resourceFactory the {@link JettyResourceFactory} to use
 * @param customizer the lambda used to customize the {@link HttpClient}
 */
public JettyClientHttpConnector(
    JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
  HttpClient httpClient = new HttpClient();
  httpClient.setExecutor(resourceFactory.getExecutor());
  httpClient.setByteBufferPool(resourceFactory.getByteBufferPool());
  httpClient.setScheduler(resourceFactory.getScheduler());
  if (customizer != null) {
    customizer.accept(httpClient);
  }
  this.httpClient = httpClient;
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Constructor with an {@link JettyResourceFactory} that will manage shared resources.
 * @param resourceFactory the {@link JettyResourceFactory} to use
 * @param customizer the lambda used to customize the {@link HttpClient}
 */
public JettyClientHttpConnector(
    JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
  HttpClient httpClient = new HttpClient();
  httpClient.setExecutor(resourceFactory.getExecutor());
  httpClient.setByteBufferPool(resourceFactory.getByteBufferPool());
  httpClient.setScheduler(resourceFactory.getScheduler());
  if (customizer != null) {
    customizer.accept(httpClient);
  }
  this.httpClient = httpClient;
}

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

final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads());
pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode());
httpClient.setExecutor(pool);

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

final QueuedThreadPool threadPool = new QueuedThreadPool((Integer) threadPoolSize);
threadPool.setName(name);
client.setExecutor(threadPool);

代码示例来源:origin: org.eclipse.jetty.websocket/websocket-client

/**
 * @param executor The executor to use
 * @deprecated Use {@link HttpClient#setExecutor(Executor)}
 * on the instance passed to {@link #WebSocketClient(HttpClient)}
 */
@Deprecated
public void setExecutor(Executor executor)
{
  this.httpClient.setExecutor(executor);
}

代码示例来源:origin: openhab/openhab-core

@Override
  public HttpClient run() {
    if (logger.isDebugEnabled()) {
      if (endpoint == null) {
        logger.debug("creating http client for consumer {}", consumerName);
      } else {
        logger.debug("creating http client for consumer {}, endpoint {}", consumerName, endpoint);
      }
    }
    HttpClient httpClient = new HttpClient(createSslContextFactory(endpoint));
    httpClient.setMaxConnectionsPerDestination(2);
    if (threadPool != null) {
      httpClient.setExecutor(threadPool);
    } else {
      final QueuedThreadPool queuedThreadPool = createThreadPool(consumerName, minThreadsCustom,
          maxThreadsCustom, keepAliveTimeoutCustom);
      httpClient.setExecutor(queuedThreadPool);
    }
    if (startClient) {
      try {
        httpClient.start();
      } catch (Exception e) {
        logger.error("Could not start Jetty http client", e);
        throw new HttpClientInitializationException("Could not start Jetty http client", e);
      }
    }
    return httpClient;
  }
});

代码示例来源: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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

/**
 * Constructor with an {@link JettyResourceFactory} that will manage shared resources.
 * @param resourceFactory the {@link JettyResourceFactory} to use
 * @param customizer the lambda used to customize the {@link HttpClient}
 */
public JettyClientHttpConnector(
    JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
  HttpClient httpClient = new HttpClient();
  httpClient.setExecutor(resourceFactory.getExecutor());
  httpClient.setByteBufferPool(resourceFactory.getByteBufferPool());
  httpClient.setScheduler(resourceFactory.getScheduler());
  if (customizer != null) {
    customizer.accept(httpClient);
  }
  this.httpClient = httpClient;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Constructor with an {@link JettyResourceFactory} that will manage shared resources.
 * @param resourceFactory the {@link JettyResourceFactory} to use
 * @param customizer the lambda used to customize the {@link HttpClient}
 */
public JettyClientHttpConnector(
    JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
  HttpClient httpClient = new HttpClient();
  httpClient.setExecutor(resourceFactory.getExecutor());
  httpClient.setByteBufferPool(resourceFactory.getByteBufferPool());
  httpClient.setScheduler(resourceFactory.getScheduler());
  if (customizer != null) {
    customizer.accept(httpClient);
  }
  this.httpClient = httpClient;
}

代码示例来源:origin: org.apache.pulsar/pulsar-proxy

client.setExecutor(executor);

代码示例来源:origin: org.eclipse.jetty/jetty-proxy

client.setExecutor(executor);

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

final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads());
pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode());
httpClient.setExecutor(pool);

代码示例来源:origin: org.glassfish.jersey.connectors/jersey-jetty-connector

final QueuedThreadPool threadPool = new QueuedThreadPool((Integer) threadPoolSize);
threadPool.setName(name);
client.setExecutor(threadPool);

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

final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads());
pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode());
httpClient.setExecutor(pool);

代码示例来源:origin: org.eclipse.jetty.websocket/websocket-client

executor = threadPool;
client.setExecutor(executor);

代码示例来源: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 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: com.proofpoint.platform/http-client

QueuedThreadPool executor = createExecutor(name, config.getMinThreads(), config.getMaxThreads());
stats = stats(executor);
httpClient.setExecutor(executor);

代码示例来源:origin: org.eclipse.jetty/jetty-client

@Override
protected void doStart() throws Exception
{
  if (executor == null)
  {
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName(name);
    setExecutor(threadPool);
  }
  if (byteBufferPool == null)
    setByteBufferPool(new MappedByteBufferPool(2048,
        executor instanceof ThreadPool.SizedThreadPool
            ? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2
            : ProcessorUtils.availableProcessors() * 2));
  if (scheduler == null)
    setScheduler(new ScheduledExecutorScheduler(name + "-scheduler", false));
  if (resolver == null)
    setSocketAddressResolver(new SocketAddressResolver.Async(executor, scheduler, getAddressResolutionTimeout()));
  handlers.put(new ContinueProtocolHandler());
  handlers.put(new RedirectProtocolHandler(this));
  handlers.put(new WWWAuthenticationProtocolHandler(this));
  handlers.put(new ProxyAuthenticationProtocolHandler(this));
  decoderFactories.add(new GZIPContentDecoder.Factory(byteBufferPool));
  cookieManager = newCookieManager();
  cookieStore = cookieManager.getCookieStore();
  transport.setHttpClient(this);
  super.doStart();
}

代码示例来源:origin: org.eclipse.jetty.tests/test-sessions-common

HttpClient client = new HttpClient();
QueuedThreadPool executor = new QueuedThreadPool();
client.setExecutor(executor);
client.start();

相关文章

HttpClient类方法