Search in sources :

Example 1 with NettyServerBuilder

use of com.hotels.styx.server.netty.NettyServerBuilder in project styx by ExpediaGroup.

the class AdminServerBuilder method build.

public InetServer build() {
    LOG.debug("event bus that will be used is {}", environment.eventBus());
    StyxConfig styxConfig = environment.configuration();
    AdminServerConfig adminServerConfig = styxConfig.adminServerConfig();
    NettyExecutor bossExecutor = NettyExecutor.create("Admin-Boss", adminServerConfig.bossThreadsCount());
    NettyExecutor workerExecutor = NettyExecutor.create("Admin-Worker", adminServerConfig.workerThreadsCount());
    NettyServerBuilder builder = NettyServerBuilder.newBuilder().setMetricsRegistry(environment.metricRegistry()).bossExecutor(bossExecutor).workerExecutor(workerExecutor).handler(adminEndpoints(styxConfig, startupConfig)).shutdownAction(() -> {
        bossExecutor.shut();
        workerExecutor.shut();
    });
    // Currently admin server cannot be started over TLS protocol.
    // This appears to be an existing issue that needs rectifying.
    adminServerConfig.httpConnectorConfig().ifPresent(it -> builder.setProtocolConnector(new WebServerConnectorFactory().create(it)));
    return builder.build();
}
Also used : WebServerConnectorFactory(com.hotels.styx.server.netty.WebServerConnectorFactory) StyxConfig(com.hotels.styx.StyxConfig) NettyServerBuilder(com.hotels.styx.server.netty.NettyServerBuilder) NettyExecutor(com.hotels.styx.NettyExecutor)

Example 2 with NettyServerBuilder

use of com.hotels.styx.server.netty.NettyServerBuilder in project styx by ExpediaGroup.

the class StyxProxyTest method startsAndStopsAServer.

@Test
public void startsAndStopsAServer() {
    Service server = StyxServers.toGuavaService(new NettyServerBuilder().setProtocolConnector(connector(0)).bossExecutor(NettyExecutor.create("Test-Server-Boss", 1)).workerExecutor(NettyExecutor.create("Test-Server-Worker", 0)).build());
    server.startAsync().awaitRunning();
    assertThat("Server should be running", server.isRunning());
    server.stopAsync().awaitTerminated();
    assertThat("Server should not be running", !server.isRunning());
}
Also used : NettyServerBuilder(com.hotels.styx.server.netty.NettyServerBuilder) Service(com.google.common.util.concurrent.Service) Test(org.junit.jupiter.api.Test)

Aggregations

NettyServerBuilder (com.hotels.styx.server.netty.NettyServerBuilder)2 Service (com.google.common.util.concurrent.Service)1 NettyExecutor (com.hotels.styx.NettyExecutor)1 StyxConfig (com.hotels.styx.StyxConfig)1 WebServerConnectorFactory (com.hotels.styx.server.netty.WebServerConnectorFactory)1 Test (org.junit.jupiter.api.Test)1