예제 #1
0
 /** Stop the network manager, closing all connections and cleaning up all resources. */
 public void stop() {
   started.set(false);
   logger.info("Network manager stopping!");
   ChannelGroupFuture future = allChannels.close();
   future.awaitUninterruptibly();
   channelFactory.releaseExternalResources();
 }
예제 #2
0
  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");
  }
예제 #3
0
 public void stop() {
   log.info("Shutting down proxy");
   final ChannelGroupFuture future = allChannels.close();
   future.awaitUninterruptibly(6 * 1000);
   serverBootstrap.releaseExternalResources();
   log.info("Done shutting down proxy");
 }
예제 #4
0
  /** Shuts the AirReceiver down gracefully */
  public static void onShutdown() {
    /* Close channels */
    final ChannelGroupFuture allChannelsClosed = s_allChannels.close();

    /* Stop all mDNS responders */
    synchronized (s_jmDNSInstances) {
      for (final JmDNS jmDNS : s_jmDNSInstances) {
        try {
          jmDNS.unregisterAllServices();
          s_logger.info("Unregistered all services on " + jmDNS.getInterface());
        } catch (final IOException e) {
          s_logger.info("Failed to unregister some services");
        }
      }
    }

    /* Wait for all channels to finish closing */
    allChannelsClosed.awaitUninterruptibly();

    /* Stop the ExecutorService */
    ExecutorService.shutdown();

    /* Release the OrderedMemoryAwareThreadPoolExecutor */
    ChannelExecutionHandler.releaseExternalResources();
  }
 @Override
 public final ChannelGroupFuture awaitUninterruptibly() {
   waitForConditionSetUninterruptibly(-1, -1);
   if (condition) {
     backedChannelGroupFuture.awaitUninterruptibly();
   }
   return this;
 }
예제 #6
0
  /** Frees all the server resources. */
  @Override
  public void shutdown() {
    // Close all connections.
    ChannelGroupFuture groupFuture = NeddyBenchmark.getAllChannels().close();
    groupFuture.awaitUninterruptibly();

    // Shutdown the selector loop (boss and workers).
    getBootstrap().getFactory().releaseExternalResources();
  }
예제 #7
0
 public void stop() {
   try {
     myScheduler.shutdown();
     myBuildsExecutor.shutdown();
     final ChannelGroupFuture closeFuture = myAllOpenChannels.close();
     closeFuture.awaitUninterruptibly();
   } finally {
     myChannelFactory.releaseExternalResources();
   }
 }
예제 #8
0
 /**
  * Shutdown this client and close all open connections. The client should be discarded after
  * calling shutdown.
  */
 public void shutdown() {
   for (Channel c : channels) {
     ChannelPipeline pipeline = c.getPipeline();
     RedisAsyncConnection<?, ?> connection = pipeline.get(RedisAsyncConnection.class);
     connection.close();
   }
   ChannelGroupFuture future = channels.close();
   future.awaitUninterruptibly();
   bootstrap.releaseExternalResources();
 }
예제 #9
0
 /** Stop the Server */
 public void stop() {
   try {
     handler.destroy();
     final ChannelGroupFuture future = ALL_CHANNELS.close();
     future.awaitUninterruptibly();
     bootstrap.getFactory().releaseExternalResources();
     ALL_CHANNELS.clear();
   } finally {
     started.set(false);
   }
 }
  @Override
  public final boolean awaitUninterruptibly(final long timeout, final TimeUnit unit) {
    final long nano = unit.toNanos(timeout);
    final long milli = NANOSECONDS.toMillis(nano);
    final int nanoRemain = (int) (nano - MILLISECONDS.toNanos(milli));
    final long remain = nano - waitForConditionSetUninterruptibly(milli, nanoRemain);

    if (conditionSetFlag) {
      if (condition) {
        return backedChannelGroupFuture.awaitUninterruptibly(remain, NANOSECONDS);
      } else {
        return true;
      }
    } else {
      return false;
    }
  }
예제 #11
0
 /**
  * Releases all resources associated with this server so the JVM can shutdown cleanly. Call this
  * method to finish using the server. To utilize the default shutdown hook in main() provided by
  * RestExpress, call awaitShutdown() instead.
  */
 public void shutdown() {
   ChannelGroupFuture future = allChannels.close();
   future.awaitUninterruptibly();
   shutdownPlugins();
   bootstrap.getFactory().releaseExternalResources();
 }
예제 #12
0
 public void stopListening() {
   final ChannelGroupFuture closeFuture = myAllOpenChannels.close();
   closeFuture.awaitUninterruptibly();
 }