Search in sources :

Example 1 with SocketListener

use of org.webpieces.http2client.SocketListener in project webpieces by deanhiller.

the class IntegSingleRequest method createHttpClient.

public static Http2Socket createHttpClient(String id, boolean isHttp, InetSocketAddress addr) {
    BufferPool pool2 = new TwoPools("pl", new SimpleMeterRegistry());
    HpackParser hpackParser = HpackParserFactory.createParser(pool2, false);
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, new BackpressureConfig(), executor2);
    InjectionConfig injConfig = new InjectionConfig(hpackParser);
    String host = addr.getHostName();
    int port = addr.getPort();
    ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
    SSLEngine engine = ssl.createSslEngine(host, port);
    Http2Client client = Http2ClientFactory.createHttpClient(id, mgr, injConfig);
    Http2Socket socket;
    if (isHttp) {
        socket = client.createHttpSocket(new SocketListener());
    } else {
        socket = client.createHttpsSocket(engine, new SocketListener());
    }
    return socket;
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) BackpressureConfig(org.webpieces.nio.api.BackpressureConfig) ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) SSLEngine(javax.net.ssl.SSLEngine) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) SocketListener(org.webpieces.http2client.SocketListener) Http2Socket(org.webpieces.http2client.api.Http2Socket) Http2Client(org.webpieces.http2client.api.Http2Client)

Aggregations

HpackParser (com.webpieces.hpack.api.HpackParser)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 Executor (java.util.concurrent.Executor)1 SSLEngine (javax.net.ssl.SSLEngine)1 BufferPool (org.webpieces.data.api.BufferPool)1 TwoPools (org.webpieces.data.api.TwoPools)1 SocketListener (org.webpieces.http2client.SocketListener)1 Http2Client (org.webpieces.http2client.api.Http2Client)1 Http2Socket (org.webpieces.http2client.api.Http2Socket)1 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)1 ChannelManager (org.webpieces.nio.api.ChannelManager)1 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)1 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)1