Search in sources :

Example 1 with FrontendConfig

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

the class ServerFactory method createTestServer.

static int createTestServer(boolean alwaysHttp2, Long maxConcurrentStreams) {
    BufferCreationPool pool = new BufferCreationPool();
    ScheduledExecutorService timer = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
    HttpFrontendManager frontEndMgr = HttpFrontendFactory.createFrontEnd("frontEnd", 10, timer, pool);
    FrontendConfig config = new FrontendConfig("id2", new InetSocketAddress(0));
    HttpServer server = frontEndMgr.createHttpServer(config, new OurListener());
    server.start();
    return server.getUnderlyingChannel().getLocalAddress().getPort();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InetSocketAddress(java.net.InetSocketAddress) HttpServer(org.webpieces.frontend2.api.HttpServer) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

Example 2 with FrontendConfig

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

the class AbstractHttp2Test method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockTcpChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockTcpChannel));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    FrontendConfig frontendConfig = new FrontendConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    simulateClientConnecting();
    simulateClientSendingPrefaceAndSettings();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) HttpServer(org.webpieces.frontend2.api.HttpServer) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 3 with FrontendConfig

use of org.webpieces.frontend2.api.FrontendConfig 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(CompletableFuture.completedFuture(mockTcpChannel));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    FrontendConfig frontendConfig = new FrontendConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    CompletableFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) HttpServer(org.webpieces.frontend2.api.HttpServer) 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 4 with FrontendConfig

use of org.webpieces.frontend2.api.FrontendConfig 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(CompletableFuture.completedFuture(mockChannel));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    FrontendConfig frontendConfig = new FrontendConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    simulateClientConnecting();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) HttpServer(org.webpieces.frontend2.api.HttpServer) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 5 with FrontendConfig

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

the class WebServerImpl method start.

@Override
public StreamListener start() {
    log.info("starting server");
    routingService.start();
    //validate html route id's and params on startup if 'org.webpieces.routeId.txt' exists
    validateRouteIdsFromHtmlFiles();
    FrontendConfig svrChanConfig = new FrontendConfig("http", config.getHttpListenAddress());
    svrChanConfig.asyncServerConfig.functionToConfigureBeforeBind = config.getFunctionToConfigureServerSocket();
    httpServer = serverMgr.createHttpServer(svrChanConfig, serverListener);
    httpServer.start();
    if (factory != null) {
        FrontendConfig secureChanConfig = new FrontendConfig("https", config.getHttpsListenAddress(), 10000);
        secureChanConfig.asyncServerConfig.functionToConfigureBeforeBind = config.getFunctionToConfigureServerSocket();
        httpsServer = serverMgr.createHttpsServer(secureChanConfig, serverListener, factory);
        httpsServer.start();
    } else {
        log.info("https port is disabled since configuration had no sslEngineFactory");
    }
    log.info("server started");
    return serverListener;
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig)

Aggregations

FrontendConfig (org.webpieces.frontend2.api.FrontendConfig)5 InetSocketAddress (java.net.InetSocketAddress)4 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)4 HttpServer (org.webpieces.frontend2.api.HttpServer)4 Http2Config (com.webpieces.http2engine.api.client.Http2Config)3 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)3 Before (org.junit.Before)3 MockTcpServerChannel (org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)1 ConnectionListener (org.webpieces.nio.api.handlers.ConnectionListener)1 DataListener (org.webpieces.nio.api.handlers.DataListener)1 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)1