Search in sources :

Example 6 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class ServerAsync method createFrontend.

private HttpServer createFrontend() {
    if (config.getServerThreadCount() != null) {
        return createFrontendMultiThreaded();
    }
    log.info("Creating single threaded server");
    TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
    ChannelManager chanMgr = factory.createSingleThreadedChanMgr("svrCmLoop", pool, config.getBackpressureConfig());
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr, metrics);
    HttpFrontendManager mgr = HttpFrontendFactory.createFrontEnd(svrMgr, pool, http2Config, new SimpleMeterRegistry());
    return mgr.createHttpServer(new HttpSvrConfig("asyncsvr"), new EchoListener());
}
Also used : ChannelManager(org.webpieces.nio.api.ChannelManager) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 7 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class ServerAsync method createFrontendMultiThreaded.

private HttpServer createFrontendMultiThreaded() {
    ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor();
    FrontendMgrConfig frontendConfig = new FrontendMgrConfig();
    frontendConfig.setHttp2Config(http2Config);
    frontendConfig.setBackpressureConfig(config.getBackpressureConfig());
    frontendConfig.setThreadPoolSize(config.getServerThreadCount());
    log.info("Creating multithreaded server. threads=" + frontendConfig.getThreadPoolSize());
    HttpFrontendManager mgr = HttpFrontendFactory.createFrontEnd("deansvr", timer, new TwoPools("pl", new SimpleMeterRegistry()), frontendConfig, metrics);
    return mgr.createHttpServer(new HttpSvrConfig("asyncsvr"), new EchoListener());
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) FrontendMgrConfig(org.webpieces.frontend2.api.FrontendMgrConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig)

Example 8 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class HttpFrontendFactory method createFrontEnd.

public static HttpFrontendManager createFrontEnd(ChannelManager chanMgr, ScheduledExecutorService timer, InjectionConfig injConfig, MeterRegistry metrics) {
    TwoPools pool = new TwoPools(chanMgr.getName() + ".bufpoolmain", metrics);
    HttpParser httpParser = HttpParserFactory.createParser(chanMgr.getName(), metrics, pool);
    return createFrontEnd(chanMgr, timer, injConfig, httpParser, metrics);
}
Also used : TwoPools(org.webpieces.data.api.TwoPools) HttpParser(org.webpieces.httpparser.api.HttpParser)

Example 9 with TwoPools

use of org.webpieces.data.api.TwoPools 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 10 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class TestCancelStream method setup.

@Before
public void setup() {
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    TwoPools pool = new TwoPools("client.bufferpool", metrics);
    httpClient = Http2to11ClientFactory.createHttpClient("myClient2", mockChanMgr, new SimpleMeterRegistry(), pool);
    mockChannel.setConnectFuture(XFuture.completedFuture(null));
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    httpSocket = httpClient.createHttpSocket(new Http2CloseListener());
}
Also used : Http2CloseListener(org.webpieces.httpclient.Http2CloseListener) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Before(org.junit.Before)

Aggregations

TwoPools (org.webpieces.data.api.TwoPools)43 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)39 Before (org.junit.Before)15 BufferPool (org.webpieces.data.api.BufferPool)15 ChannelManager (org.webpieces.nio.api.ChannelManager)12 InetSocketAddress (java.net.InetSocketAddress)11 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)11 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)10 Executor (java.util.concurrent.Executor)8 SSLEngine (javax.net.ssl.SSLEngine)8 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)8 DirectExecutor (org.webpieces.util.threading.DirectExecutor)8 ByteBuffer (java.nio.ByteBuffer)7 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)7 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)7 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)6 HttpParser (org.webpieces.httpparser.api.HttpParser)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)5 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)5 ArrayList (java.util.ArrayList)4