Search in sources :

Example 1 with Engine

use of org.jboss.modcluster.container.Engine in project wildfly by wildfly.

the class UndertowEngineTestCase method getObfuscatedJvmRoute.

@Test
public void getObfuscatedJvmRoute() {
    // scenario 1, just create a service with obfuscated route but same config as this.service
    final TestUndertowService service1 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, this.route, true, null);
    final Server server1 = new TestServer(this.serverName, this.hostName, service1, this.host, this.listener);
    final Engine engine1 = new UndertowEngine(this.serverName, server1, service1, this.connector);
    assertNotEquals(this.route, engine1.getJvmRoute());
    // after restart, recreate all objects, is the route still the same if config is kept unchanged?
    final Host host2 = new Host(null, null, null, null, null, this.hostName, Collections.emptyList(), "ROOT.war", StatusCodes.NOT_FOUND, false);
    final HttpsListenerService listener2 = new HttpsListenerService(null, PathAddress.pathAddress(Constants.HTTPS_LISTENER, "default"), "https", OptionMap.EMPTY, null, OptionMap.EMPTY, false);
    final UndertowService service2 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, this.route, true, null);
    final Server server2 = new TestServer(this.serverName, this.hostName, service2, host2, listener2);
    final Connector connector2 = mock(Connector.class);
    final Engine engine2 = new UndertowEngine(this.serverName, server2, service2, connector2);
    assertEquals(engine1.getJvmRoute(), engine2.getJvmRoute());
    // with a different route, is the obfuscated route different from previous one?
    final TestUndertowService service3 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, "adifferentroute", true, null);
    final Server server3 = new TestServer(this.serverName, this.hostName, service3, this.host, this.listener);
    final Engine engine3 = new UndertowEngine(this.serverName, server3, service3, this.connector);
    assertNotEquals(engine1.getJvmRoute(), engine3.getJvmRoute());
    // just double check it is obfuscated for engine3 as well
    assertNotEquals("adifferentroute", engine3.getJvmRoute());
    // with a different server name, is the obfuscated route different from previous one?
    final TestUndertowService service4 = new TestUndertowService(null, "default-container", "another.server", this.hostName, "this.route", true, null);
    final Server server4 = new TestServer("another.server", this.hostName, service4, this.host, this.listener);
    final Engine engine4 = new UndertowEngine(this.serverName, server4, service4, this.connector);
    assertNotEquals(engine1.getJvmRoute(), engine4.getJvmRoute());
    // just double check it is obfuscated for engine4 as well
    assertNotEquals(this.route, engine4.getJvmRoute());
}
Also used : Connector(org.jboss.modcluster.container.Connector) Server(org.wildfly.extension.undertow.Server) Host(org.wildfly.extension.undertow.Host) HttpsListenerService(org.wildfly.extension.undertow.HttpsListenerService) Engine(org.jboss.modcluster.container.Engine) UndertowService(org.wildfly.extension.undertow.UndertowService) Test(org.junit.Test)

Example 2 with Engine

use of org.jboss.modcluster.container.Engine in project wildfly by wildfly.

the class UndertowServerTestCase method getEngines.

@Test
public void getEngines() {
    when(configuration.getServer()).thenReturn(mock(org.wildfly.extension.undertow.Server.class));
    when(configuration.getServer().getName()).thenReturn(undertowServer.getName());
    Iterator<Engine> engines = this.server.getEngines().iterator();
    assertTrue(engines.hasNext());
    Engine engine = engines.next();
    assertSame(this.connector, engine.getProxyConnector());
    assertFalse(engines.hasNext());
}
Also used : Server(org.jboss.modcluster.container.Server) Engine(org.jboss.modcluster.container.Engine) Test(org.junit.Test)

Example 3 with Engine

use of org.jboss.modcluster.container.Engine in project wildfly by wildfly.

the class UndertowEventHandlerAdapterService method start.

@Override
public void start(StartContext context) {
    UndertowService service = this.configuration.getUndertowService();
    ContainerEventHandler eventHandler = this.configuration.getContainerEventHandler();
    this.connector = new UndertowConnector(this.configuration.getListener());
    this.serverName = this.configuration.getServer().getName();
    this.server = new UndertowServer(this.serverName, service, this.connector);
    // Register ourselves as a listener to the container events
    service.registerListener(this);
    // Initialize mod_cluster and start it now
    eventHandler.init(this.server);
    eventHandler.start(this.server);
    for (Engine engine : this.server.getEngines()) {
        for (org.jboss.modcluster.container.Host host : engine.getHosts()) {
            host.getContexts().forEach(c -> contexts.add(c));
        }
    }
    // Start the periodic STATUS thread
    this.executor = Executors.newScheduledThreadPool(1, new DefaultThreadFactory(UndertowEventHandlerAdapterService.class));
    this.executor.scheduleWithFixedDelay(this, 0, this.configuration.getStatusInterval().toMillis(), TimeUnit.MILLISECONDS);
    this.configuration.getSuspendController().registerActivity(this);
}
Also used : DefaultThreadFactory(org.jboss.as.clustering.context.DefaultThreadFactory) ContainerEventHandler(org.jboss.modcluster.container.ContainerEventHandler) Engine(org.jboss.modcluster.container.Engine) UndertowService(org.wildfly.extension.undertow.UndertowService)

Aggregations

Engine (org.jboss.modcluster.container.Engine)3 Test (org.junit.Test)2 UndertowService (org.wildfly.extension.undertow.UndertowService)2 DefaultThreadFactory (org.jboss.as.clustering.context.DefaultThreadFactory)1 Connector (org.jboss.modcluster.container.Connector)1 ContainerEventHandler (org.jboss.modcluster.container.ContainerEventHandler)1 Server (org.jboss.modcluster.container.Server)1 Host (org.wildfly.extension.undertow.Host)1 HttpsListenerService (org.wildfly.extension.undertow.HttpsListenerService)1 Server (org.wildfly.extension.undertow.Server)1