@Override public void start() { delegate.start(); } }
@Autowired public AsyncNotifyService(ServerListService serverListService) { this.serverListService = serverListService; httpclient.start(); }
private HttpAsyncClient startAsyncClient() { HttpAsyncClient client = getAsyncClient(); if (client instanceof CloseableHttpAsyncClient) { CloseableHttpAsyncClient closeableAsyncClient = (CloseableHttpAsyncClient) client; if (!closeableAsyncClient.isRunning()) { closeableAsyncClient.start(); } } return client; }
private HttpAsyncClient startAsyncClient() { HttpAsyncClient client = getAsyncClient(); if (client instanceof CloseableHttpAsyncClient) { CloseableHttpAsyncClient closeableAsyncClient = (CloseableHttpAsyncClient) client; if (!closeableAsyncClient.isRunning()) { closeableAsyncClient.start(); } } return client; }
@Override protected CloseableHttpAsyncClient newClient(HttpTracing httpTracing) { CloseableHttpAsyncClient result = TracingHttpAsyncClientBuilder.create(httpTracing).build(); result.start(); return result; }
@Override protected CloseableHttpAsyncClient newClient() { CloseableHttpAsyncClient result = HttpAsyncClients.custom().build(); result.start(); return result; }
TimerTaskService.scheduleWithFixedDelay(task, 0L, 5L, TimeUnit.SECONDS); httpclient.start(); CheckServerHealthTask checkServerHealthTask = new CheckServerHealthTask(); TimerTaskService.scheduleWithFixedDelay(checkServerHealthTask, 0L, 5L, TimeUnit.SECONDS);
public <T extends JestResult> void executeAsync(final Action<T> clientRequest, final JestResultHandler<? super T> resultHandler, final RequestConfig requestConfig) { synchronized (this) { if (!asyncClient.isRunning()) { asyncClient.start(); } } HttpUriRequest request = prepareRequest(clientRequest, requestConfig); executeAsyncRequest(clientRequest, resultHandler, request); }
public ApacheHttpAsyncClient(HttpAsyncClientBuilder builder, Config config, SharedResourcesBroker<GobblinScopeTypes> broker) { super (broker, HttpUtils.createApacheHttpClientLimiterKey(config)); config = config.withFallback(FALLBACK); RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT) .setSocketTimeout(config.getInt(REQUEST_TIME_OUT_MS_KEY)) .setConnectTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY)) .setConnectionRequestTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY)) .build(); try { builder.disableCookieManagement().useSystemProperties().setDefaultRequestConfig(requestConfig); builder.setConnectionManager(getNHttpConnManager(config)); client = builder.build(); client.start(); } catch (IOException e) { throw new RuntimeException("ApacheHttpAsyncClient cannot be initialized"); } }
public MetricFetcher() { int cores = Runtime.getRuntime().availableProcessors() * 2; long keepAliveTime = 0; int queueSize = 2048; RejectedExecutionHandler handler = new DiscardPolicy(); fetchService = new ThreadPoolExecutor(cores, cores, keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), new NamedThreadFactory("sentinel-dashboard-metrics-fetchService"), handler); fetchWorker = new ThreadPoolExecutor(cores, cores, keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker"), handler); IOReactorConfig ioConfig = IOReactorConfig.custom() .setConnectTimeout(3000) .setSoTimeout(3000) .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2) .build(); httpclient = HttpAsyncClients.custom() .setRedirectStrategy(new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(final String method) { return false; } }).setMaxConnTotal(4000) .setMaxConnPerRoute(1000) .setDefaultIOReactorConfig(ioConfig) .build(); httpclient.start(); start(); }
public SentinelApiClient() { IOReactorConfig ioConfig = IOReactorConfig.custom().setConnectTimeout(3000).setSoTimeout(10000) .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2).build(); httpClient = HttpAsyncClients.custom().setRedirectStrategy(new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(final String method) { return false; } }).setMaxConnTotal(4000).setMaxConnPerRoute(1000).setDefaultIOReactorConfig(ioConfig).build(); httpClient.start(); }
private void setupAsyncClient() { final HttpAsyncClientBuilder clientBuilder = HttpAsyncClients.custom(); if (sslContext != null) { clientBuilder.setSSLContext(sslContext); clientBuilder.addInterceptorFirst(new HttpsResponseInterceptor()); } httpAsyncClient = clientBuilder.setDefaultCredentialsProvider(getCredentialsProvider()).build(); httpAsyncClient.start(); }
public static <T> Future<HttpResponse<T>> requestAsync(HttpRequest request, final Class<T> responseClass, Callback<T> callback) { HttpUriRequest requestObj = prepareRequest(request, true); CloseableHttpAsyncClient asyncHttpClient = ClientFactory.getAsyncHttpClient(); if (!asyncHttpClient.isRunning()) { asyncHttpClient.start(); AsyncIdleConnectionMonitorThread asyncIdleConnectionMonitorThread = (AsyncIdleConnectionMonitorThread) Options.getOption(Option.ASYNC_MONITOR); asyncIdleConnectionMonitorThread.start(); } final Future<org.apache.http.HttpResponse> future = asyncHttpClient.execute(requestObj, prepareCallback(responseClass, callback)); return new Future<HttpResponse<T>>() { public boolean cancel(boolean mayInterruptIfRunning) { return future.cancel(mayInterruptIfRunning); } public boolean isCancelled() { return future.isCancelled(); } public boolean isDone() { return future.isDone(); } public HttpResponse<T> get() throws InterruptedException, ExecutionException { org.apache.http.HttpResponse httpResponse = future.get(); return new HttpResponse<T>(httpResponse, responseClass); } public HttpResponse<T> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { org.apache.http.HttpResponse httpResponse = future.get(timeout, unit); return new HttpResponse<T>(httpResponse, responseClass); } }; }
public ApacheHttpAsyncClient4Engine(final CloseableHttpAsyncClient client, final boolean closeHttpClient) { if (client == null) throw new NullPointerException("client"); this.client = client; this.closeHttpClient = closeHttpClient; if (closeHttpClient && !client.isRunning()) { client.start(); } }
public HttpQuery () { super(); client.start(); } public int prepare (long id, Serializable o) {
public ApacheHttpAsyncClient4Engine(CloseableHttpAsyncClient client, boolean closeHttpClient) { if (client == null) throw new NullPointerException("client"); this.client = client; this.closeHttpClient = closeHttpClient; if (closeHttpClient && !client.isRunning()) { client.start(); } }
public static synchronized CloseableHttpAsyncClient buildCloseableHttpAsyncClient(MainConfigurationSet config) { if (closeableHttpAsyncClient == null) { closeableHttpAsyncClient = buildAsync(config); closeableHttpAsyncClient.start(); } return closeableHttpAsyncClient; }
private ApacheHttpClientAdapterImpl(final CloseableHttpAsyncClient apacheHttpClient) { this.apacheHttpClient = apacheHttpClient; if (!apacheHttpClient.isRunning()) { apacheHttpClient.start(); } }
public HttpPostDeliverService(final String postUrl, final int connectTimeout, final int soTimeout) { httpClient = HttpAsyncClients.createDefault(); httpClient.start(); httpPost = new HttpPost(postUrl); final RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout).setSocketTimeout(soTimeout).build(); httpPost.setConfig(requestConfig); httpPost.setHeader("Content-type", "application/json"); httpPost.setHeader("Content-Type", "text/html;charset=UTF-8"); }
/** * Creates a new {@link RestClient} based on the provided configuration. */ public RestClient build() { if (failureListener == null) { failureListener = new RestClient.FailureListener(); } CloseableHttpAsyncClient httpClient = createHttpClient(); RestClient restClient = new RestClient(httpClient, maxRetryTimeout, defaultHeaders, hosts, pathPrefix, failureListener); httpClient.start(); return restClient; }