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();
}
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);
}
});
}
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);
}
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();
}
}
Aggregations