Search in sources :

Example 1 with ContainerEventHandler

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

the class UndertowEventHandlerAdapter method stop.

@Override
public void stop(StopContext context) {
    suspendController.getValue().unRegisterActivity(this);
    this.service.getValue().unregisterListener(this);
    this.executor.shutdownNow();
    try {
        this.executor.awaitTermination(statusInterval, TimeUnit.SECONDS);
    } catch (InterruptedException ignore) {
    // Move on.
    }
    ContainerEventHandler eventHandler = this.eventHandler.getValue();
    eventHandler.stop(this.server);
}
Also used : ContainerEventHandler(org.jboss.modcluster.container.ContainerEventHandler)

Example 2 with ContainerEventHandler

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

the class UndertowEventHandlerAdapter method start.

@Override
public void start(StartContext context) {
    UndertowService service = this.service.getValue();
    ContainerEventHandler eventHandler = this.eventHandler.getValue();
    this.connector = new UndertowConnector(this.listener.getValue());
    this.server = new UndertowServer(service, 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);
    // Start the periodic STATUS thread
    ThreadGroup group = new ThreadGroup(UndertowEventHandlerAdapter.class.getSimpleName());
    ThreadFactory factory = doPrivileged(new PrivilegedAction<ThreadFactory>() {

        public ThreadFactory run() {
            return new JBossThreadFactory(group, Boolean.FALSE, null, "%G - %t", null, null);
        }
    });
    this.executor = Executors.newScheduledThreadPool(1, factory);
    this.executor.scheduleWithFixedDelay(this, 0, statusInterval, TimeUnit.SECONDS);
    suspendController.getValue().registerActivity(this);
}
Also used : ContainerEventHandler(org.jboss.modcluster.container.ContainerEventHandler) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) UndertowService(org.wildfly.extension.undertow.UndertowService)

Example 3 with ContainerEventHandler

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

the class UndertowEventHandlerAdapterService method onStop.

private synchronized void onStop(Context context) {
    ContainerEventHandler handler = this.configuration.getContainerEventHandler();
    handler.stop(context);
    // TODO break into onDeploymentRemove once implemented in Undertow
    handler.remove(context);
    this.contexts.remove(context);
}
Also used : ContainerEventHandler(org.jboss.modcluster.container.ContainerEventHandler)

Example 4 with ContainerEventHandler

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

the class UndertowEventHandlerAdapterService method onStart.

private synchronized void onStart(Context context) {
    ContainerEventHandler handler = this.configuration.getContainerEventHandler();
    handler.add(context);
    State state = this.configuration.getSuspendController().getState();
    // TODO break into onDeploymentAdd once implemented in Undertow
    if (state == State.RUNNING) {
        handler.start(context);
    }
    this.contexts.add(context);
}
Also used : ContainerEventHandler(org.jboss.modcluster.container.ContainerEventHandler) State(org.jboss.as.server.suspend.SuspendController.State)

Example 5 with ContainerEventHandler

use of org.jboss.modcluster.container.ContainerEventHandler 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

ContainerEventHandler (org.jboss.modcluster.container.ContainerEventHandler)5 UndertowService (org.wildfly.extension.undertow.UndertowService)2 ThreadFactory (java.util.concurrent.ThreadFactory)1 DefaultThreadFactory (org.jboss.as.clustering.context.DefaultThreadFactory)1 State (org.jboss.as.server.suspend.SuspendController.State)1 Engine (org.jboss.modcluster.container.Engine)1 JBossThreadFactory (org.jboss.threads.JBossThreadFactory)1