Package com.facebook.presto.jdbc.internal.airlift.http.client.netty

Source Code of com.facebook.presto.jdbc.internal.airlift.http.client.netty.StandaloneNettyAsyncHttpClient

package com.facebook.presto.jdbc.internal.airlift.http.client.netty;

import com.facebook.presto.jdbc.internal.airlift.http.client.AsyncHttpClient;
import com.facebook.presto.jdbc.internal.airlift.http.client.HttpClientConfig;
import com.facebook.presto.jdbc.internal.airlift.http.client.HttpRequestFilter;
import com.facebook.presto.jdbc.internal.airlift.http.client.Request;
import com.facebook.presto.jdbc.internal.airlift.http.client.RequestStats;
import com.facebook.presto.jdbc.internal.airlift.http.client.ResponseHandler;

import java.util.Collections;
import java.util.Set;

/**
* Standalone variant of the {@link NettyAsyncHttpClient} which manages the thread pool itself.
*/
public class StandaloneNettyAsyncHttpClient
        implements AsyncHttpClient
{
    private final NettyIoPool ioPool;
    private final NettyAsyncHttpClient httpClient;

    public StandaloneNettyAsyncHttpClient(String name)
    {
        this(name, new HttpClientConfig());
    }

    public StandaloneNettyAsyncHttpClient(String name, HttpClientConfig httpClientConfig)
    {
        this(name, httpClientConfig, new NettyAsyncHttpClientConfig(), new NettyIoPoolConfig(), Collections.<HttpRequestFilter>emptySet());
    }

    public StandaloneNettyAsyncHttpClient(
            String name,
            HttpClientConfig httpClientConfig,
            NettyAsyncHttpClientConfig asyncHttpClientConfig,
            NettyIoPoolConfig ioPoolConfig,
            Set<? extends HttpRequestFilter> filters)
    {
        this.ioPool = new NettyIoPool(name, ioPoolConfig);
        this.httpClient = new NettyAsyncHttpClient(name, ioPool, httpClientConfig, asyncHttpClientConfig, filters);
    }

    @Override
    @SuppressWarnings("deprecation")
    public void close()
    {
        httpClient.close();
        ioPool.close();
    }

    @Override
    public <T, E extends Exception> T execute(Request request, ResponseHandler<T, E> responseHandler)
            throws E
    {
        return httpClient.execute(request, responseHandler);
    }

    @Override
    public RequestStats getStats()
    {
        return httpClient.getStats();
    }

    @Override
    public <T, E extends Exception> AsyncHttpResponseFuture<T> executeAsync(Request request, ResponseHandler<T, E> responseHandler)
    {
        return httpClient.executeAsync(request, responseHandler);
    }
}
TOP

Related Classes of com.facebook.presto.jdbc.internal.airlift.http.client.netty.StandaloneNettyAsyncHttpClient

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.