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();
}
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());
}
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);
}
Aggregations