public void stop() {
    log.info("Shutting down proxy");
    if (stopped.get()) {
      log.info("Already stopped");
      return;
    }
    stopped.set(true);

    log.info("Closing all channels...");

    // See http://static.netty.io/3.5/guide/#start.12

    final ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly(10 * 1000);

    if (!future.isCompleteSuccess()) {
      final Iterator<ChannelFuture> iter = future.iterator();
      while (iter.hasNext()) {
        final ChannelFuture cf = iter.next();
        if (!cf.isSuccess()) {
          log.warn("Cause of failure for {} is {}", cf.getChannel(), cf.getCause());
        }
      }
    }
    log.info("Stopping timer");
    timer.stop();
    serverChannelFactory.releaseExternalResources();
    clientChannelFactory.releaseExternalResources();

    log.info("Done shutting down proxy");
  }
Esempio n. 2
0
  @Override
  protected void doStop() throws Exception {
    if (timer != null) {
      timer.stop();
      timer = null;
    }
    if (executorService != null) {
      getCamelContext().getExecutorServiceManager().shutdownNow(executorService);
      executorService = null;
    }

    super.doStop();
  }
  public void close() {
    if (closed.compareAndSet(false, true)) {
      try {
        channelManager.close();

        // FIXME shouldn't close if not allowed
        config.executorService().shutdown();

        if (allowStopNettyTimer) nettyTimer.stop();

      } catch (Throwable t) {
        LOGGER.warn("Unexpected error on close", t);
      }
    }
  }
Esempio n. 4
0
 @Override
 protected void doStop() throws Exception {
   timer.stop();
   timer = null;
   super.doStop();
 }
 @Override
 public void dispose() {
   timer.stop();
 }
Esempio n. 6
0
 /**
  * Stops the {@link Timer} which was specified in the constructor of this handler. You should not
  * call this method if the {@link Timer} is in use by other objects.
  */
 @Override
 public void releaseExternalResources() {
   timer.stop();
 }