Search in sources :

Example 1 with HpackParser

use of com.webpieces.hpack.api.HpackParser in project webpieces by deanhiller.

the class Http2ClientFactory method createHttpClient.

public static Http2Client createHttpClient(Http2ClientConfig config, MeterRegistry metrics) {
    Executor executor = Executors.newFixedThreadPool(config.getNumThreads(), new NamedThreadFactory("httpclient"));
    MetricsCreator.monitor(metrics, executor, config.getId());
    TwoPools pool = new TwoPools(config.getId() + ".bufferpool", metrics);
    HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
    ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, config.getBackpressureConfig(), executor);
    InjectionConfig injConfig = new InjectionConfig(hpackParser, new TimeImpl(), config.getHttp2Config());
    return createHttpClient(config.getHttp2Config().getId(), mgr, injConfig);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) TwoPools(org.webpieces.data.api.TwoPools) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(org.webpieces.util.time.TimeImpl)

Example 2 with HpackParser

use of com.webpieces.hpack.api.HpackParser in project webpieces by deanhiller.

the class HttpFrontendFactory method createFrontEnd.

/**
 * @param id Use for logging and also file recording names
 * use the SessionExecutorImpl found in webpieces
 * @param metrics
 *
 * @return
 */
public static HttpFrontendManager createFrontEnd(String id, ScheduledExecutorService timer, BufferPool pool, FrontendMgrConfig config, MeterRegistry metrics) {
    Executor executor = Executors.newFixedThreadPool(config.getThreadPoolSize(), new NamedThreadFactory(id));
    MetricsCreator.monitor(metrics, executor, id);
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
    ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, config.getBackpressureConfig(), executor);
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr, metrics);
    HttpParser httpParser = HttpParserFactory.createParser(id, metrics, pool);
    HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
    InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), config.getHttp2Config());
    Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
    return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) HttpParser(org.webpieces.httpparser.api.HttpParser) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) Http2ServerEngineFactory(com.webpieces.http2engine.api.server.Http2ServerEngineFactory) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(org.webpieces.util.time.TimeImpl) FrontEndServerManagerImpl(org.webpieces.frontend2.impl.FrontEndServerManagerImpl)

Example 3 with HpackParser

use of com.webpieces.hpack.api.HpackParser 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("myClient", mgr, injConfig);
    Http2Socket socket;
    if (isHttp) {
        socket = client.createHttpSocket(new Http2CloseListener());
    } else {
        socket = client.createHttpsSocket(engine, new Http2CloseListener());
    }
    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) Http2Socket(org.webpieces.http2client.api.Http2Socket) Http2Client(org.webpieces.http2client.api.Http2Client)

Example 4 with HpackParser

use of com.webpieces.hpack.api.HpackParser in project webpieces by deanhiller.

the class WebServerModule method providesAsyncServerMgr.

@Provides
@Singleton
public HttpFrontendManager providesAsyncServerMgr(ChannelManager chanMgr, ScheduledExecutorService timer, BufferPool pool, Time time, WebServerConfig config, MeterRegistry metrics) {
    HttpParser httpParser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), pool);
    HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
    InjectionConfig injConfig = new InjectionConfig(http2Parser, time, config.getHttp2Config());
    return HttpFrontendFactory.createFrontEnd(chanMgr, timer, injConfig, httpParser, metrics);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) HttpParser(org.webpieces.httpparser.api.HttpParser) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 5 with HpackParser

use of com.webpieces.hpack.api.HpackParser 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)11 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)11 Executor (java.util.concurrent.Executor)6 ChannelManager (org.webpieces.nio.api.ChannelManager)6 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)6 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)6 HttpParser (org.webpieces.httpparser.api.HttpParser)5 TimeImpl (org.webpieces.util.time.TimeImpl)4 Http2ServerEngineFactory (com.webpieces.http2engine.api.server.Http2ServerEngineFactory)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)3 TwoPools (org.webpieces.data.api.TwoPools)3 FrontEndServerManagerImpl (org.webpieces.frontend2.impl.FrontEndServerManagerImpl)3 Provides (com.google.inject.Provides)2 Http2Config (com.webpieces.http2engine.api.client.Http2Config)2 TimeImpl (com.webpieces.util.time.TimeImpl)2 Singleton (javax.inject.Singleton)2 SSLEngine (javax.net.ssl.SSLEngine)2 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)2 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)2 BufferPool (org.webpieces.data.api.BufferPool)2