@Override public boolean isRunning() { return delegate.isRunning(); }
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; }
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); }
/** * Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit. */ public static void shutdown() throws IOException { // Closing the Sync HTTP client CloseableHttpClient syncClient = (CloseableHttpClient) Options.getOption(Option.HTTPCLIENT); if (syncClient != null) { syncClient.close(); } SyncIdleConnectionMonitorThread syncIdleConnectionMonitorThread = (SyncIdleConnectionMonitorThread) Options.getOption(Option.SYNC_MONITOR); if (syncIdleConnectionMonitorThread != null) { syncIdleConnectionMonitorThread.interrupt(); } // Closing the Async HTTP client (if running) CloseableHttpAsyncClient asyncClient = (CloseableHttpAsyncClient) Options.getOption(Option.ASYNCHTTPCLIENT); if (asyncClient != null && asyncClient.isRunning()) { asyncClient.close(); } AsyncIdleConnectionMonitorThread asyncMonitorThread = (AsyncIdleConnectionMonitorThread) Options.getOption(Option.ASYNC_MONITOR); if (asyncMonitorThread != null) { asyncMonitorThread.interrupt(); } }
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(); } }
@Override public boolean isRunning() { return ac.isRunning(); }
@Override public boolean isRunning() { return delegate.isRunning(); }
private IntegrationTestHttpClient(final CloseableHttpAsyncClient apacheHttpClient) { this.apacheHttpClient = apacheHttpClient; if (!apacheHttpClient.isRunning()) { apacheHttpClient.start(); } }
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 ApacheHttpAsyncClient4Engine(CloseableHttpAsyncClient client, boolean closeHttpClient) { if (client == null) throw new NullPointerException("client"); this.client = client; this.closeHttpClient = closeHttpClient; if (closeHttpClient && !client.isRunning()) { client.start(); } }
private ApacheHttpClientAdapterImpl(final CloseableHttpAsyncClient apacheHttpClient) { this.apacheHttpClient = apacheHttpClient; if (!apacheHttpClient.isRunning()) { apacheHttpClient.start(); } }
private ApacheHttpClientAdapterImpl(final CloseableHttpAsyncClient apacheHttpClient) { this.apacheHttpClient = apacheHttpClient; if (!apacheHttpClient.isRunning()) { apacheHttpClient.start(); } }
private static CloseableHttpAsyncClient asyncClient() { CloseableHttpAsyncClient asyncHttpClient = ClientFactory.getAsyncHttpClient(); if (!asyncHttpClient.isRunning()) { tryStart(asyncHttpClient); } return asyncHttpClient; }
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 public Stream<Exception> close() { return Util.collectExceptions(Util.tryCast(client, CloseableHttpAsyncClient.class) .filter(c -> c.isRunning()) .map(c -> Util.tryDo(c, d -> d.close())) .filter(c -> c.isPresent()) .map(c -> c.get()), Util.tryDo(manager, m -> m.shutdown()), Util.tryDo(syncMonitor, m -> m.interrupt())); } }
private static synchronized void tryStart(CloseableHttpAsyncClient asyncHttpClient) { if (!asyncHttpClient.isRunning()) { asyncHttpClient.start(); AsyncIdleConnectionMonitorThread asyncIdleConnectionMonitorThread = (AsyncIdleConnectionMonitorThread) Options.getOption(Option.ASYNC_MONITOR); asyncIdleConnectionMonitorThread.tryStart(); } } }
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); }