io.netty.util.concurrent.Future#awaitUninterruptibly ( )源码实例Demo

下面列出了io.netty.util.concurrent.Future#awaitUninterruptibly ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: incubator-nemo   文件: ByteTransport.java
/**
 * Closes all channels and releases all resources.
 */
@Override
public void close() {
  LOG.info("Stopping listening at {} and closing", serverListeningChannel.localAddress());

  final ChannelFuture closeListeningChannelFuture = serverListeningChannel.close();
  final ChannelGroupFuture channelGroupCloseFuture = channelGroup.close();
  final Future serverListeningGroupCloseFuture = serverListeningGroup.shutdownGracefully();
  final Future serverWorkingGroupCloseFuture = serverWorkingGroup.shutdownGracefully();
  final Future clientGroupCloseFuture = clientGroup.shutdownGracefully();

  closeListeningChannelFuture.awaitUninterruptibly();
  channelGroupCloseFuture.awaitUninterruptibly();
  serverListeningGroupCloseFuture.awaitUninterruptibly();
  serverWorkingGroupCloseFuture.awaitUninterruptibly();
  clientGroupCloseFuture.awaitUninterruptibly();
}
 
源代码2 项目: esjc   文件: HttpClient.java
@Override
public void close() {
    Future shutdownFuture = group.shutdownGracefully(0, 15, SECONDS);
    queueExecutor.shutdown();

    HttpOperation operation;
    while ((operation = queue.poll()) != null) {
        operation.response.completeExceptionally(new HttpClientException("Client closed"));
    }

    shutdownFuture.awaitUninterruptibly();

    try {
        queueExecutor.awaitTermination(5, SECONDS);
    } catch (InterruptedException e) {
        // ignore
    }
}
 
源代码3 项目: nemo   文件: ByteTransport.java
/**
 * Closes all channels and releases all resources.
 */
@Override
public void close() {
  LOG.info("Stopping listening at {} and closing", serverListeningChannel.localAddress());

  final ChannelFuture closeListeningChannelFuture = serverListeningChannel.close();
  final ChannelGroupFuture channelGroupCloseFuture = channelGroup.close();
  final Future serverListeningGroupCloseFuture = serverListeningGroup.shutdownGracefully();
  final Future serverWorkingGroupCloseFuture = serverWorkingGroup.shutdownGracefully();
  final Future clientGroupCloseFuture = clientGroup.shutdownGracefully();

  closeListeningChannelFuture.awaitUninterruptibly();
  channelGroupCloseFuture.awaitUninterruptibly();
  serverListeningGroupCloseFuture.awaitUninterruptibly();
  serverWorkingGroupCloseFuture.awaitUninterruptibly();
  clientGroupCloseFuture.awaitUninterruptibly();
}
 
源代码4 项目: activemq-artemis   文件: NettyTcpTransport.java
@Override
public void close() throws IOException {
   if (closed.compareAndSet(false, true)) {
      connected.set(false);
      try {
         if (channel != null) {
            channel.close().syncUninterruptibly();
         }
      } finally {
         if (group != null) {
            Future<?> fut = group.shutdownGracefully(0, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
            if (!fut.awaitUninterruptibly(2 * SHUTDOWN_TIMEOUT)) {
               LOG.trace("Channel group shutdown failed to complete in allotted time");
            }
         }
      }
   }
}
 
源代码5 项目: qpid-jms   文件: NettyTcpTransport.java
@Override
public void close() throws IOException {
    if (closed.compareAndSet(false, true)) {
        connected.set(false);
        try {
            if (channel != null) {
                channel.close().syncUninterruptibly();
            }
        } finally {
            if (group != null) {
                Future<?> fut = group.shutdownGracefully(0, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
                if (!fut.awaitUninterruptibly(2 * SHUTDOWN_TIMEOUT)) {
                    LOG.trace("Channel group shutdown failed to complete in allotted time");
                }
            }
        }
    }
}
 
源代码6 项目: twill   文件: TrackerService.java
@Override
protected void shutDown() throws Exception {
  channelGroup.close().awaitUninterruptibly();

  List<Future<?>> futures = new ArrayList<>();
  futures.add(bootstrap.config().group().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS));
  futures.add(bootstrap.config().childGroup().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS));

  for (Future<?> future : futures) {
    future.awaitUninterruptibly();
  }

  LOG.info("Tracker service stopped at {}", url);
}
 
protected void get(XioClient client, String pathIncludingQuery) throws Exception {
  // System.out.println("get client: " + client + " path: " + pathIncludingQuery);
  HttpRequest payload = new DefaultFullHttpRequest(HTTP_1_1, GET, pathIncludingQuery);
  XioRequest<HttpRequest> request = buildRequest(client, payload);
  Future<Void> future = client.write(request);
  future.awaitUninterruptibly();
  try {
    local.get();
  } catch (Exception e) {
    // System.out.println("caught e: " + e);
  }
}
 
源代码8 项目: pinpoint   文件: ServerFactory.java
public void close() {
    final Future<?> workerShutdown = this.workerEventLoopGroup.shutdownGracefully();
    workerShutdown.awaitUninterruptibly();
    ExecutorUtils.shutdownExecutorService(name + "-Channel-Worker", workerExecutor);

    final Future<?> bossShutdown = this.bossEventLoopGroup.shutdownGracefully();
    bossShutdown.awaitUninterruptibly();
    ExecutorUtils.shutdownExecutorService(name + "-Channel-Boss", bossExecutor);
}
 
源代码9 项目: reef   文件: NettyMessagingTransport.java
/**
 * Closes all channels and releases all resources.
 */
@Override
public void close() {

  LOG.log(Level.FINE, "Closing netty transport socket address: {0}", this.localAddress);

  final ChannelGroupFuture clientChannelGroupFuture = this.clientChannelGroup.close();
  final ChannelGroupFuture serverChannelGroupFuture = this.serverChannelGroup.close();
  final ChannelFuture acceptorFuture = this.acceptor.close();

  final ArrayList<Future> eventLoopGroupFutures = new ArrayList<>(3);
  eventLoopGroupFutures.add(this.clientWorkerGroup.shutdownGracefully());
  eventLoopGroupFutures.add(this.serverBossGroup.shutdownGracefully());
  eventLoopGroupFutures.add(this.serverWorkerGroup.shutdownGracefully());

  clientChannelGroupFuture.awaitUninterruptibly();
  serverChannelGroupFuture.awaitUninterruptibly();

  try {
    acceptorFuture.sync();
  } catch (final Exception ex) {
    LOG.log(Level.SEVERE, "Error closing the acceptor channel for " + this.localAddress, ex);
  }

  for (final Future eventLoopGroupFuture : eventLoopGroupFutures) {
    eventLoopGroupFuture.awaitUninterruptibly();
  }

  LOG.log(Level.FINE, "Closing netty transport socket address: {0} done", this.localAddress);
}