use of org.webpieces.frontend2.api.HttpSvrConfig in project webpieces by deanhiller.
the class AbstractFrontendHttp2Test method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
MockTcpServerChannel svrChannel = new MockTcpServerChannel();
mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
mockTcpChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
mockListener.setDefaultRetVal(mockStreamWriter);
mockStreamWriter.setDefaultRetValToThis();
Http2Config config = new Http2Config();
config.setLocalSettings(localSettings);
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
HttpSvrConfig frontendConfig = new HttpSvrConfig("http", new InetSocketAddress("me", 8080));
HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig, Metrics.globalRegistry);
HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
httpServer.start();
simulateClientConnecting();
simulateClientSendingPrefaceAndSettings();
}
use of org.webpieces.frontend2.api.HttpSvrConfig 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.HttpSvrConfig 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());
}
use of org.webpieces.frontend2.api.HttpSvrConfig 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.HttpSvrConfig in project webpieces by deanhiller.
the class WebServerImpl method startServerOnHttpPort.
private XFuture<Void> startServerOnHttpPort(Injector injector, InetSocketAddress httpAddress, boolean httpsOverHttpEnabled) {
XFuture<Void> fut1;
String type;
if (httpsOverHttpEnabled) {
type = "both";
// This is inside the if statement BECAUSE we do not need to bind an SSLConfiguration if they do not
// enable the backend or https ports
SSLEngineFactory factory = fetchSSLEngineFactory(injector);
HttpSvrConfig httpSvrConfig = new HttpSvrConfig(type, httpAddress, 10000);
httpSvrConfig.asyncServerConfig.functionToConfigureBeforeBind = s -> configure(s);
httpServer = serverMgr.createUpgradableServer(httpSvrConfig, serverListener, factory);
} else {
type = "http";
HttpSvrConfig httpSvrConfig = new HttpSvrConfig(type, httpAddress, 10000);
httpSvrConfig.asyncServerConfig.functionToConfigureBeforeBind = s -> configure(s);
httpServer = serverMgr.createHttpServer(httpSvrConfig, serverListener);
}
log.info("Created and now starting the '" + type + "' over port=" + httpAddress + " 'both' means this port supports both http and https");
fut1 = httpServer.start();
return fut1;
}
Aggregations