protected void stopDelayedExecutor() { if (delayedExecutor != null) { final DelayedExecutor localDelayedExecutor = delayedExecutor; delayedExecutor = null; if (localDelayedExecutor != null) { localDelayedExecutor.stop(); localDelayedExecutor.destroy(); } final ExecutorService localThreadPool = auxExecutorService; auxExecutorService = null; if (localThreadPool != null) { localThreadPool.shutdownNow(); } } }
/** Immediately shuts down the <code>HttpServer</code> instance. */ public synchronized void shutdownNow() { if (state == State.STOPPED) { return; } state = State.STOPPED; try { if (serverConfig.isJmxEnabled()) { for (final JmxEventListener l : serverConfig.getJmxEventListeners()) { l.jmxDisabled(); } } tearDownHttpHandler(); final String[] names = listeners.keySet().toArray(new String[listeners.size()]); for (final String name : names) { removeListener(name); } delayedExecutor.stop(); delayedExecutor.destroy(); delayedExecutor = null; stopAuxThreadPool(); if (serverConfig.isJmxEnabled()) { disableJMX(); } } catch (Exception e) { LOGGER.log(Level.WARNING, null, e); } finally { for (final NetworkListener listener : listeners.values()) { final FilterChain filterChain = listener.getTransport().getFilterChain(); filterChain.clear(); } if (shutdownFuture != null) { shutdownFuture.result(this); } } }
/** * Starts the <code>HttpServer</code>. * * @throws IOException if an error occurs while attempting to start the server. */ public synchronized void start() throws IOException { if (state == State.RUNNING) { return; } else if (state == State.STOPPING) { throw new IllegalStateException( "The server is currently in pending" + " shutdown state. You have to either wait for shutdown to" + " complete or force it by calling shutdownNow()"); } state = State.RUNNING; shutdownFuture = null; configureAuxThreadPool(); delayedExecutor = new DelayedExecutor(auxExecutorService); delayedExecutor.start(); for (final NetworkListener listener : listeners.values()) { configureListener(listener); } if (serverConfig.isJmxEnabled()) { enableJMX(); } for (final NetworkListener listener : listeners.values()) { try { listener.start(); } catch (IOException ioe) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log( Level.FINEST, "Failed to start listener [{0}] : {1}", new Object[] {listener.toString(), ioe.toString()}); LOGGER.log(Level.FINEST, ioe.toString(), ioe); } throw ioe; } } setupHttpHandler(); if (serverConfig.isJmxEnabled()) { for (final JmxEventListener l : serverConfig.getJmxEventListeners()) { l.jmxEnabled(); } } if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "[{0}] Started.", getServerConfiguration().getName()); } }
protected void startDelayedExecutor() { if (delayedExecutor != null) { delayedExecutor.start(); } }
public void initialize(final DelayedExecutor delayedExecutor) { delayQueue = delayedExecutor.createDelayQueue(new EntryWorker(), new EntryResolver()); }