Search in sources :

Example 1 with FrontendMgrConfig

use of org.webpieces.frontend2.api.FrontendMgrConfig in project webpieces by deanhiller.

the class ServerFactory method createTestServer.

static int createTestServer(boolean alwaysHttp2, Long maxConcurrentStreams) {
    TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
    ScheduledExecutorService timer = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
    FrontendMgrConfig config = new FrontendMgrConfig();
    HttpFrontendManager frontEndMgr = HttpFrontendFactory.createFrontEnd("frontEnd", timer, pool, config, Metrics.globalRegistry);
    HttpSvrConfig svrConfig = new HttpSvrConfig("id2");
    HttpServer server = frontEndMgr.createHttpServer(svrConfig, new OurListener());
    XFuture<Void> fut = server.start();
    try {
        fut.get(2, TimeUnit.SECONDS);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        throw SneakyThrow.sneak(e);
    }
    return server.getUnderlyingChannel().getLocalAddress().getPort();
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) TwoPools(org.webpieces.data.api.TwoPools) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) FrontendMgrConfig(org.webpieces.frontend2.api.FrontendMgrConfig) HttpServer(org.webpieces.frontend2.api.HttpServer) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with FrontendMgrConfig

use of org.webpieces.frontend2.api.FrontendMgrConfig 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 3 with FrontendMgrConfig

use of org.webpieces.frontend2.api.FrontendMgrConfig 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)

Aggregations

SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 TwoPools (org.webpieces.data.api.TwoPools)2 FrontendMgrConfig (org.webpieces.frontend2.api.FrontendMgrConfig)2 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)2 HttpSvrConfig (org.webpieces.frontend2.api.HttpSvrConfig)2 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)2 HpackParser (com.webpieces.hpack.api.HpackParser)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 Http2ServerEngineFactory (com.webpieces.http2engine.api.server.Http2ServerEngineFactory)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executor (java.util.concurrent.Executor)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 TimeoutException (java.util.concurrent.TimeoutException)1 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)1 HttpServer (org.webpieces.frontend2.api.HttpServer)1 FrontEndServerManagerImpl (org.webpieces.frontend2.impl.FrontEndServerManagerImpl)1 HttpParser (org.webpieces.httpparser.api.HttpParser)1 ChannelManager (org.webpieces.nio.api.ChannelManager)1 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)1