Search in sources :

Example 6 with HttpSvrConfig

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

the class WebServerImpl method startHttpsServer.

private XFuture<Void> startHttpsServer(Injector injector, InetSocketAddress httpsAddress) {
    XFuture<Void> fut2;
    // 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);
    String type = "https";
    log.info("Creating and starting https over port=" + httpsAddress + " AND using '" + type + "'");
    HttpSvrConfig httpSvrConfig = new HttpSvrConfig(type, httpsAddress, 10000);
    httpSvrConfig.asyncServerConfig.functionToConfigureBeforeBind = s -> configure(s);
    httpsServer = serverMgr.createHttpsServer(httpSvrConfig, serverListener, factory);
    fut2 = httpsServer.start();
    return fut2;
}
Also used : HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) SSLEngineFactory(org.webpieces.nio.api.SSLEngineFactory)

Example 7 with HttpSvrConfig

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

the class AbstractHttp1Test method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockChannel.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();
}
Also used : HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpServer(org.webpieces.frontend2.api.HttpServer) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 8 with HttpSvrConfig

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

the class TestS3InitialHttpConnections 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();
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    XFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpServer(org.webpieces.frontend2.api.HttpServer) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 9 with HttpSvrConfig

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

the class WebServerImpl method startBackendServer.

private XFuture<Void> startBackendServer(Injector injector, InetSocketAddress backendAddress) {
    XFuture<Void> fut33;
    // 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
    SSLConfiguration sslConfiguration = injector.getInstance(SSLConfiguration.class);
    String type = "https";
    if (sslConfiguration.getBackendSslEngineFactory() == null)
        type = "http";
    String serverName = "backend." + type;
    log.info("Creating and starting the " + serverName + " over port=" + backendAddress + " AND using '" + type + "'");
    HttpSvrConfig httpSvrConfig = new HttpSvrConfig(serverName, backendAddress, 10000);
    httpSvrConfig.asyncServerConfig.functionToConfigureBeforeBind = s -> configure(s);
    SSLEngineFactory factory = (SSLEngineFactory) sslConfiguration.getBackendSslEngineFactory();
    backendServer = serverMgr.createBackendHttpsServer(httpSvrConfig, serverListener, factory);
    fut33 = backendServer.start();
    return fut33;
}
Also used : SSLConfiguration(org.webpieces.nio.api.SSLConfiguration) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) SSLEngineFactory(org.webpieces.nio.api.SSLEngineFactory)

Aggregations

HttpSvrConfig (org.webpieces.frontend2.api.HttpSvrConfig)9 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)6 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)6 HttpServer (org.webpieces.frontend2.api.HttpServer)4 Http2Config (com.webpieces.http2engine.api.client.Http2Config)3 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)3 InetSocketAddress (java.net.InetSocketAddress)3 Before (org.junit.Before)3 TwoPools (org.webpieces.data.api.TwoPools)3 MockTcpServerChannel (org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel)3 SSLEngineFactory (org.webpieces.nio.api.SSLEngineFactory)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 FrontendMgrConfig (org.webpieces.frontend2.api.FrontendMgrConfig)2 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 TimeoutException (java.util.concurrent.TimeoutException)1 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)1 ChannelManager (org.webpieces.nio.api.ChannelManager)1 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)1 SSLConfiguration (org.webpieces.nio.api.SSLConfiguration)1