this.grizzlyClient = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(asyncClientConfig), asyncClientConfig);
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); SSLContext sslContext = null; try { sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, null, secureRandom); } catch (Exception e) { e.printStackTrace(); } AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() .setConnectTimeout(5000) .setSSLContext(sslContext).build(); AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); long start = System.currentTimeMillis(); try { client.executeRequest(client.prepareGet("http://www.google.com").build()).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } LOGGER.debug("COMPLETE: " + (System.currentTimeMillis() - start) + "ms"); } }
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); SSLContext sslContext = null; try { sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, null, secureRandom); } catch (Exception e) { e.printStackTrace(); } AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() .setConnectTimeout(5000) .setSSLContext(sslContext).build(); AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); long start = System.currentTimeMillis(); try { client.executeRequest(client.prepareGet("http://www.google.com").build()).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } LOGGER.debug("COMPLETE: " + (System.currentTimeMillis() - start) + "ms"); } }
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); SSLContext sslContext = null; try { sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, null, secureRandom); } catch (Exception e) { e.printStackTrace(); } AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() .setConnectTimeout(5000) .setSSLContext(sslContext).build(); AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); long start = System.currentTimeMillis(); try { client.executeRequest(client.prepareGet("http://www.google.com").build()).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } LOGGER.debug("COMPLETE: " + (System.currentTimeMillis() - start) + "ms"); } }
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); SSLContext sslContext = null; try { sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, null, secureRandom); } catch (Exception e) { e.printStackTrace(); } AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() .setConnectionTimeout(5000) .setSSLContext(sslContext).build(); AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); try { long start = System.currentTimeMillis(); try { client.executeRequest(client.prepareGet("http://www.google.com").build()).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } System.out.println("COMPLETE: " + (System.currentTimeMillis() - start) + "ms"); } catch (IOException e) { e.printStackTrace(); } } }
@Override public void start() throws MuleException { AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder(); builder.setAllowPoolingConnections(true); configureTransport(builder); configureTlsContext(builder); configureProxy(builder); configureConnections(builder); AsyncHttpClientConfig config = builder.build(); asyncHttpClient = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); }
public static AsyncHttpClient grizzlyProvider(AsyncHttpClientConfig config) { if (config == null) { config = new AsyncHttpClientConfig.Builder().build(); } return new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); }
@Override public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) { if (config == null) { config = new AsyncHttpClientConfig.Builder().build(); } return new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); }
@Test public void referencedResponseHC() throws InterruptedException { AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder().build(); AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); final CountDownLatch responseLatch = new CountDownLatch(1); final AtomicReference<Response> responseRef = new AtomicReference<>(); client.prepareGet("http://www.ning.com/").execute(new AsyncCompletionHandler<Response>() { @Override public Response onCompleted(Response response) throws Exception { responseLatch.countDown(); responseRef.set(response); return response; } @Override public void onThrowable(Throwable t) { // Something wrong happened. } }); responseLatch.await(5, TimeUnit.SECONDS); verifyNotLeaked(new PhantomReference<>(responseRef.getAndSet(null), new ReferenceQueue<>())); }
@Override public void start() { selectorScheduler = schedulerService.customScheduler(schedulersConfig .withDirectRunCpuLightWhenTargetBusy(true) .withMaxConcurrentTasks(DEFAULT_SELECTOR_THREAD_COUNT) .withName(name), MAX_VALUE); workerScheduler = schedulerService.ioScheduler(schedulersConfig); AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder(); builder.setAllowPoolingConnections(true); configureTransport(builder); configureTlsContext(builder); configureProxy(builder); configureConnections(builder); AsyncHttpClientConfig config = builder.build(); asyncHttpClient = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); }
this.grizzlyClient = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(asyncClientConfig), asyncClientConfig);
.setAcceptAnyCertificate(true) .build(); try (AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config)) { final int[] statusCodes = new int[threadCount]; final int[] totalsReceived = new int[threadCount];
.setAcceptAnyCertificate(true) .build(); try (AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config)) { final int[] statusCodes = new int[threadCount]; final int[] totalsReceived = new int[threadCount];
@Test public void testNoTransferEncoding() throws Exception { String url = "http://localhost:" + port + "/test"; AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() .setFollowRedirect(false) .setConnectTimeout(15000) .setRequestTimeout(15000) .setAllowPoolingConnections(false) .setDisableUrlEncodingForBoundedRequests(true) .setIOThreadMultiplier(2) // 2 is default .build(); try (AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config)) { Future<com.ning.http.client.Response> f = client.prepareGet(url).execute(); com.ning.http.client.Response r = f.get(10, TimeUnit.SECONDS); Assert.assertEquals(TEST_MESSAGE, r.getResponseBody()); } } }