@Override public void handleCompleted() { trackerService.unregisterTracker(processor); } });
@Override public void run() { try { // Wait for all mgmt requests to complete trackerService.awaitShutdown(SHUTDOWN_TIMEOUT, TIME_UNIT); } catch (InterruptedException e) { // } finally { context.complete(); } } });
@Override public synchronized void start(StartContext context) throws StartException { trackerService.reset(); }
@Override public void channelOpened(Channel channel) { // When the server/host is stopping we don't accept new connections // 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); } }); }
@Override public synchronized void stop(final StopContext context) { // Signal all management services we are about to shutdown. trackerService.prepareShutdown(); context.asynchronous(); try { executorValue.getValue().execute(new Runnable() { @Override public void run() { try { // Wait for all mgmt requests to complete trackerService.awaitShutdown(SHUTDOWN_TIMEOUT, TIME_UNIT); } catch (InterruptedException e) { // } finally { context.complete(); } } }); } catch (RejectedExecutionException e) { context.complete(); } }
@Override public synchronized void stop(final StopContext context) { this.trackerService.stop(); final ArrayList<Registration> registrations = this.registrations; for(final Registration registration : registrations) { registration.close(); } registrations.clear(); }
@Override public synchronized void start(StartContext context) throws StartException { // Register the http request processor on the mgmt request tracker final ManagementHttpRequestProcessor processor = processorValue.getValue(); trackerService = mgmtChannelRegistry.getValue().getTrackerService(); trackerService.registerTracker(processor); processor.addShutdownListener(new ManagementHttpRequestProcessor.ShutdownListener() { @Override public void handleCompleted() { trackerService.unregisterTracker(processor); } }); }
@Override public synchronized void stop(final StopContext context) { // Signal all management services we are about to shutdown. trackerService.prepareShutdown(); context.asynchronous(); try { executorValue.getValue().execute(new Runnable() { @Override public void run() { try { // Wait for all mgmt requests to complete trackerService.awaitShutdown(SHUTDOWN_TIMEOUT, TIME_UNIT); } catch (InterruptedException e) { // } finally { context.complete(); } } }); } catch (RejectedExecutionException e) { context.complete(); } }
@Override public void handleCompleted() { trackerService.unregisterTracker(processor); } });
@Override public synchronized void start(StartContext context) throws StartException { // Register the http request processor on the mgmt request tracker final ManagementHttpRequestProcessor processor = processorValue.getValue(); trackerService = mgmtChannelRegistry.getValue().getTrackerService(); trackerService.registerTracker(processor); processor.addShutdownListener(new ManagementHttpRequestProcessor.ShutdownListener() { @Override public void handleCompleted() { trackerService.unregisterTracker(processor); } }); }
closed = true; trackerService.prepareShutdown();
@Override public void run() { try { // Wait for all mgmt requests to complete trackerService.awaitShutdown(SHUTDOWN_TIMEOUT, TIME_UNIT); } catch (InterruptedException e) { // } finally { context.complete(); } } });
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); } });
@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(); } } } };