本文整理了Java中io.netty.util.concurrent.Future.await()
方法的一些代码示例,展示了Future.await()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.await()
方法的具体详情如下:
包路径:io.netty.util.concurrent.Future
类名称:Future
方法名:await
[英]Waits for this future to be completed.
[中]等待这个未来完成。
代码示例来源:origin: line/armeria
@Override
public Future<T> await() throws InterruptedException {
return delegate.await();
}
代码示例来源:origin: line/armeria
@Override
public boolean await(long timeoutMillis) throws InterruptedException {
return delegate.await(timeoutMillis);
}
代码示例来源:origin: line/armeria
@Override
public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
return delegate.await(timeout, unit);
}
代码示例来源:origin: yu199195/Raincat
private void stop() {
try {
if (null != bossGroup) {
bossGroup.shutdownGracefully().await();
}
if (null != workerGroup) {
workerGroup.shutdownGracefully().await();
}
if (null != servletExecutor) {
servletExecutor.shutdownGracefully().await();
}
} catch (InterruptedException e) {
throw new TransactionRuntimeException(" Netty Container stop interrupted", e);
}
}
代码示例来源:origin: AsyncHttpClient/async-http-client
public static void shutdown() {
Future<?> bossFuture = bossGroup.shutdownGracefully();
Future<?> workerFuture = workerGroup.shutdownGracefully();
try {
bossFuture.await();
workerFuture.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: relayrides/pushy
@TearDown
public void tearDown() throws Exception {
this.client.close().await();
this.server.shutdown().await();
final Future<?> clientShutdownFuture = this.clientEventLoopGroup.shutdownGracefully();
final Future<?> serverShutdownFuture = this.serverEventLoopGroup.shutdownGracefully();
clientShutdownFuture.await();
serverShutdownFuture.await();
}
代码示例来源:origin: kaaproject/kaa
Future<? extends Object> future = bossGroup.shutdownGracefully(
250, 1000, TimeUnit.MILLISECONDS);
future.await();
} catch (InterruptedException exception) {
LOG.trace("NettyHttpServer stopping: bossGroup error", exception);
Future<? extends Object> future = workerGroup.shutdownGracefully(
250, 1000, TimeUnit.MILLISECONDS);
future.await();
} catch (InterruptedException exception) {
LOG.trace("NettyHttpServer stopping: workerGroup error", exception);
代码示例来源:origin: micronaut-projects/micronaut-core
future.await(shutdownTimeout.toMillis());
} catch (InterruptedException e) {
代码示例来源:origin: andsel/moquette
workerWaiter.await(10, TimeUnit.SECONDS);
bossWaiter.await(10, TimeUnit.SECONDS);
} catch (InterruptedException iex) {
LOG.warn("An InterruptedException was caught while waiting for event loops to terminate...");
代码示例来源:origin: relayrides/pushy
this.server.start(PORT).await();
代码示例来源:origin: glowroot/glowroot
@OnlyUsedByTests
void awaitClose() throws InterruptedException {
if (!retryExecutor.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate executor");
}
if (!channel.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate channel");
}
channelExecutor.shutdown();
if (!channelExecutor.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate executor");
}
if (!eventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException("Could not terminate event loop group");
}
}
代码示例来源:origin: glowroot/glowroot
void close() throws InterruptedException {
Stopwatch stopwatch = Stopwatch.createStarted();
while (stopwatch.elapsed(SECONDS) < 10 && !downstreamService.closedByAgent) {
MILLISECONDS.sleep(10);
}
checkState(downstreamService.closedByAgent);
// TODO shutdownNow() has been needed to interrupt grpc threads since grpc-java 1.7.0
server.shutdownNow();
if (!server.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate channel");
}
// not sure why, but server needs a little extra time to shut down properly
// without this sleep, this warning is logged (but tests still pass):
// io.grpc.netty.NettyServerHandler - Connection Error: RejectedExecutionException
MILLISECONDS.sleep(100);
executor.shutdown();
if (!executor.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate executor");
}
if (!bossEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException("Could not terminate event loop group");
}
if (!workerEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException("Could not terminate event loop group");
}
}
代码示例来源:origin: glowroot/glowroot
@Override
public @Nullable Void call() throws Exception {
server.shutdown();
if (!server.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate channel");
}
executor.shutdown();
if (!executor.awaitTermination(10, SECONDS)) {
throw new IllegalStateException("Could not terminate executor");
}
if (!bossEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException(
"Could not terminate gRPC boss event loop group");
}
if (!workerEventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException(
"Could not terminate gRPC worker event loop group");
}
socketHeartbeat.close();
return null;
}
});
代码示例来源:origin: glowroot/glowroot
throw new IllegalStateException("Could not terminate executor");
if (!eventLoopGroup.shutdownGracefully(0, 0, SECONDS).await(10, SECONDS)) {
throw new IllegalStateException("Could not terminate event loop group");
代码示例来源:origin: rakam-io/rakam
@Override
public void operationComplete(Future<Object> future)
throws Exception {
if (future.await(1, TimeUnit.SECONDS)) {
Object body = future.getNow();
if (body == null) {
return;
}
if (!(body instanceof ScriptObjectMirror)) {
returnError(request, "The script must return an object or array {collection: '', properties: {}}", BAD_REQUEST);
}
ScriptObjectMirror json = (ScriptObjectMirror) ((ScriptObjectMirror) body).eval("JSON");
Object stringify = json.callMember("stringify", body);
request.response(stringify.toString()).end();
} else {
byte[] bytes = JsonHelper.encodeAsBytes(errorMessage("Webhook code timeouts.",
INTERNAL_SERVER_ERROR));
request.response(bytes, INTERNAL_SERVER_ERROR).end();
}
}
});
代码示例来源:origin: rakam-io/rakam
@Override
public void operationComplete(Future<Object> future)
throws Exception {
if (future.await(3, TimeUnit.SECONDS)) {
Object body;
try {
代码示例来源:origin: airlift/drift
private static void await(Future<?> future)
{
try {
future.await();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
代码示例来源:origin: drallgood/jpasskit
@Override
public void close() throws InterruptedException {
if (this.client != null) {
this.client.close().await();
}
}
代码示例来源:origin: com.github.alaisi.pgasync/postgres-async-driver
@Override
public void close() throws Exception {
super.close();
group.shutdownGracefully().await(10, TimeUnit.SECONDS);
}
}
代码示例来源:origin: org.infinispan/infinispan-server-hotrod
public static void killClient(HotRodClient client) {
try {
if (client != null) {
client.stop().await();
}
}
catch (Throwable t) {
log.error("Error stopping client", t);
}
}
内容来源于网络,如有侵权,请联系作者删除!