下面列出了io.netty.util.concurrent.Future#awaitUninterruptibly ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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();
}
@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
}
}
/**
* 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();
}
@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");
}
}
}
}
}
@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");
}
}
}
}
}
@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);
}
}
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);
}
/**
* 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);
}