@Override public Future<T> await() throws InterruptedException { return delegate.await(); }
@Override public boolean await(long timeoutMillis) throws InterruptedException { return delegate.await(timeoutMillis); }
@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { return delegate.await(timeout, unit); }
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); } }
@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(); }
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);
future.await(shutdownTimeout.toMillis()); } catch (InterruptedException e) {
this.server.start(PORT).await();
@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"); } }
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"); } }
@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; } });
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");
@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(); } } });
@Override public void operationComplete(Future<Object> future) throws Exception { if (future.await(3, TimeUnit.SECONDS)) { Object body; try {
private static void await(Future<?> future) { try { future.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
@Override public void close() throws InterruptedException { if (this.client != null) { this.client.close().await(); } }
@Override public void close() throws Exception { super.close(); group.shutdownGracefully().await(10, TimeUnit.SECONDS); } }
public static void killClient(HotRodClient client) { try { if (client != null) { client.stop().await(); } } catch (Throwable t) { log.error("Error stopping client", t); } }