Search in sources :

Example 1 with ManagementChannelShutdownHandle

use of org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle in project wildfly-core by wildfly.

the class ManagementRequestTracker method stop.

synchronized void stop() {
    shutdown = true;
    final List<ManagementChannelShutdownHandle> trackers = new ArrayList<>(this.trackers);
    for (final ManagementChannelShutdownHandle tracker : trackers) {
        tracker.shutdownNow();
    }
    this.trackers.clear();
    notifyAll();
}
Also used : ManagementChannelShutdownHandle(org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle) ArrayList(java.util.ArrayList)

Example 2 with ManagementChannelShutdownHandle

use of org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle in project wildfly-core by wildfly.

the class AbstractChannelOpenListenerService method channelOpened.

@Override
public void channelOpened(Channel channel) {
    // this should be using the graceful shutdown control
    if (closed) {
        RemotingLogger.ROOT_LOGGER.debugf("server shutting down, closing channel %s.", channel);
        channel.closeAsync();
        return;
    }
    final ManagementChannelShutdownHandle handle = handleChannelOpened(channel);
    trackerService.registerTracker(handle);
    handles.add(handle);
    channel.addCloseHandler(new CloseHandler<Channel>() {

        public void handleClose(final Channel closed, final IOException exception) {
            handles.remove(handle);
            handle.shutdownNow();
            trackerService.unregisterTracker(handle);
            RemotingLogger.ROOT_LOGGER.tracef("Handling close for %s", handle);
        }
    });
}
Also used : ManagementChannelShutdownHandle(org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle) Channel(org.jboss.remoting3.Channel) IOException(java.io.IOException)

Example 3 with ManagementChannelShutdownHandle

use of org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle in project wildfly-core by wildfly.

the class AbstractChannelOpenListenerService method stop.

@Override
public synchronized void stop(final StopContext context) {
    closed = true;
    // Signal all mgmt services that we are shutting down
    trackerService.prepareShutdown();
    // Copy off the set to avoid ConcurrentModificationException
    final Set<ManagementChannelShutdownHandle> handlesCopy = copyHandles();
    for (final ManagementChannelShutdownHandle handle : handlesCopy) {
        handle.shutdown();
    }
    final Runnable shutdownTask = new Runnable() {

        @Override
        public void run() {
            final long end = System.currentTimeMillis() + CHANNEL_SHUTDOWN_TIMEOUT;
            boolean interrupted = Thread.currentThread().isInterrupted();
            try {
                for (final ManagementChannelShutdownHandle handle : handlesCopy) {
                    final long remaining = end - System.currentTimeMillis();
                    try {
                        if (!interrupted && !handle.awaitCompletion(remaining, TimeUnit.MILLISECONDS)) {
                            ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownTimedOut(CHANNEL_SHUTDOWN_TIMEOUT);
                        }
                        trackerService.unregisterTracker(handle);
                    } catch (InterruptedException e) {
                        interrupted = true;
                        ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownFailed(e);
                    } catch (Exception e) {
                        ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownFailed(e);
                    } finally {
                        handle.shutdownNow();
                    }
                }
            } finally {
                context.complete();
                if (interrupted) {
                    Thread.currentThread().interrupt();
                }
            }
        }
    };
    // Execute async shutdown task
    context.asynchronous();
    execute(shutdownTask);
}
Also used : ManagementChannelShutdownHandle(org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle) IOException(java.io.IOException) StartException(org.jboss.msc.service.StartException)

Example 4 with ManagementChannelShutdownHandle

use of org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle in project wildfly-core by wildfly.

the class ManagementRequestTracker method prepareShutdown.

public synchronized void prepareShutdown() {
    shutdown = true;
    final List<ManagementChannelShutdownHandle> trackers = new ArrayList<>(this.trackers);
    for (final ManagementChannelShutdownHandle tracker : trackers) {
        tracker.shutdown();
    }
}
Also used : ManagementChannelShutdownHandle(org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle) ArrayList(java.util.ArrayList)

Aggregations

ManagementChannelShutdownHandle (org.jboss.as.protocol.mgmt.support.ManagementChannelShutdownHandle)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 StartException (org.jboss.msc.service.StartException)1 Channel (org.jboss.remoting3.Channel)1