Package org.apache.http.impl.nio.client

Examples of org.apache.http.impl.nio.client.CloseableHttpAsyncClient.start()


                        .build();

                HttpGet get = new HttpGet(endpoint.getUri());
                HttpHost target = URIUtils.extractHost(get.getURI());
                BasicAsyncRequestProducer basicAsyncRequestProducer = new BasicAsyncRequestProducer(target, get);
                httpClient.start();
                try {
                    log.debug("sending request");
                    Future<HttpResponse> futureResponse = httpClient.execute(
                            basicAsyncRequestProducer,
                            new SSEResponseConsumer(requestHandler), new FutureCallback<HttpResponse>() {
View Full Code Here


    private  HttpAsyncClient hac;

    @Before
    public void setUp() throws Exception {
        CloseableHttpAsyncClient chac = new InstrumentedNHttpClientBuilder(metricRegistry, metricNameStrategy).build();
        chac.start();
        hac = chac;
        metricRegistry.addListener(registryListener);
    }

    @Test
View Full Code Here

                return ac.isRunning();
            }

            @Override
            public void start() {
                ac.start();
            }

            @Override
            public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, HttpContext context, FutureCallback<T> callback) {
                final Timer.Context timerContext;
View Full Code Here

        final CloseableHttpAsyncClient client = FiberCloseableHttpAsyncClient.wrap(HttpAsyncClients.
                custom().
                setMaxConnPerRoute(concurrencyLevel).
                setMaxConnTotal(concurrencyLevel).
                build());
        client.start();
        // end of snippet
        new Fiber<Void>(new SuspendableRunnable() {
            @Override
            public void run() throws SuspendExecution, InterruptedException {
                try {
View Full Code Here

                return ac.isRunning();
            }

            @Override
            public void start() {
                ac.start();
            }

            @Override
            public <T> Future<T> execute(HttpAsyncRequestProducer requestProducer, HttpAsyncResponseConsumer<T> responseConsumer, HttpContext context, FutureCallback<T> callback) {
                final Timer.Context timerContext;
View Full Code Here

        HttpAsyncClientBuilder clientBuilder = new InstrumentedNHttpClientBuilder(metricRegistry, name);
        clientBuilder.setConnectionManager(manager);
        clientBuilder.setDefaultRequestConfig(createHttpParams);
        setStrategiesForClient(clientBuilder);
        CloseableHttpAsyncClient client = clientBuilder.build();
        client.start();
        return new FiberHttpClient(client, getRetryHandler());
    }

    /**
     * Add strategies to client such as ConnectionReuseStrategy and KeepAliveStrategy Note that this
View Full Code Here

        if (attemptCount < 1) {
            throw new IllegalArgumentException("Argument \'attemptCount\' can't be less than \'1\'.");
        }

        CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
        client.start();


        try {
            int urlStringCount = urlStrings.size();
            String[] urlStringsInternal = new String[urlStrings.size()];
View Full Code Here

    HttpAsyncClientBuilder builder = HttpAsyncClients.custom().setDefaultRequestConfig(requestConfig);
    // default is 2 per host which won't let us monitor multiple directories
    builder.setMaxConnPerRoute(Integer.MAX_VALUE);
    builder.setMaxConnTotal(Integer.MAX_VALUE);
    CloseableHttpAsyncClient httpClient = builder.build();
    httpClient.start();
    return httpClient;
  }

  public EtcdClient(URI baseUri) {
    this(baseUri, buildDefaultHttpClient());
View Full Code Here

public class AsyncClientHttpExchange {

    public static void main(final String[] args) throws Exception {
        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        httpclient.start();
        try {
            final HttpGet request = new HttpGet("http://www.apache.org/");
            final Future<HttpResponse> future = httpclient.execute(request, null);
            final HttpResponse response = future.get();
            System.out.println("Response: " + response.getStatusLine());
View Full Code Here

public class AsyncClientHttpExchangeStreaming {

    public static void main(final String[] args) throws Exception {
        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        httpclient.start();
        try {
            final Future<Boolean> future = httpclient.execute(
                    HttpAsyncMethods.createGet("http://localhost:8080/"),
                    new MyResponseConsumer(), null);
            final Boolean result = future.get();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.