public void destroy() { channel.shutdownNow(); }
private void shutdown(ManagedChannel managedChannel) { try { managedChannel.shutdownNow().awaitTermination(1, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.debug("Interrupted during shutdown"); } }
private synchronized void scheduleReconnect(boolean immediate) { if( !shutdown && (reconnectTask == null || reconnectTask.isDone())) { if( channel != null) { try { channel.shutdownNow().awaitTermination(1, TimeUnit.SECONDS); } catch(Exception ignored) { } } channel = null; reconnectTask = scheduler.schedule(this::tryReconnect, immediate ? 100 : 5000, TimeUnit.MILLISECONDS); } }
private void shutdownManagedChannel(ManagedChannel managedChannel) { managedChannel.shutdown(); try { managedChannel.awaitTermination(mChannelShutdownTimeoutMs, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); // Allow thread to exit. } finally { managedChannel.shutdownNow(); } Verify.verify(managedChannel.isShutdown()); }
dataChannel.shutdownNow(); adminChannel.shutdownNow();
@AfterClass public static void tearDownChannel() { channel.shutdownNow(); }
void stop() throws Exception { try { dataClient.close(); channel.shutdownNow(); channel.awaitTermination(1, TimeUnit.MINUTES); } finally { isStopped = true; process.destroy(); } }
@Test public void noMaxMessageSize() { ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverWithNoMaxMessageSize.httpPort()) .usePlaintext() .build(); try { UnitTestServiceBlockingStub stub = UnitTestServiceGrpc.newBlockingStub(channel); assertThat(stub.staticUnaryCall(REQUEST_MESSAGE)).isEqualTo(RESPONSE_MESSAGE); } finally { channel.shutdownNow(); } }
@Test public void longMaxRequestLimit() { ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverWithLongMaxRequestLimit.httpPort()) .usePlaintext() .build(); try { UnitTestServiceBlockingStub stub = UnitTestServiceGrpc.newBlockingStub(channel); assertThat(stub.staticUnaryCall(REQUEST_MESSAGE)).isEqualTo(RESPONSE_MESSAGE); } finally { channel.shutdownNow(); } }
@Test public void uncompressedClient_compressedEndpoint() throws Exception { final ManagedChannel nonDecompressingChannel = ManagedChannelBuilder.forAddress("127.0.0.1", server.httpPort()) .decompressorRegistry( DecompressorRegistry.emptyInstance() .with(Codec.Identity.NONE, false)) .usePlaintext() .build(); final UnitTestServiceBlockingStub client = UnitTestServiceGrpc.newBlockingStub(nonDecompressingChannel); assertThat(client.staticUnaryCallSetsMessageCompression(REQUEST_MESSAGE)) .isEqualTo(RESPONSE_MESSAGE); nonDecompressingChannel.shutdownNow(); checkRequestLog((rpcReq, rpcRes, grpcStatus) -> { assertThat(rpcReq.method()).isEqualTo( "armeria.grpc.testing.UnitTestService/StaticUnaryCallSetsMessageCompression"); assertThat(rpcReq.params()).containsExactly(REQUEST_MESSAGE); assertThat(rpcRes.get()).isEqualTo(RESPONSE_MESSAGE); }); }
private void reconnect() throws EventHubException { final ManagedChannel lmanagedChannel = managedChannel; if (lmanagedChannel != null) { managedChannel = null; lmanagedChannel.shutdownNow(); } EventHubDisconnected ldisconnectedHandler = disconnectedHandler; if (!shutdown && null != ldisconnectedHandler) { ++reconnectCount; ldisconnectedHandler.disconnected(this); } }
public synchronized void shutdown() { if (shutdown) { return; } logger.trace(toString() + " being shutdown."); shutdown = true; lastBlockEvent = null; lastBlockNumber = 0; connected = false; disconnectedHandler = null; eventStream = null; final ManagedChannel lmanagedChannel = managedChannel; managedChannel = null; if (lmanagedChannel != null) { lmanagedChannel.shutdownNow(); } }
lchannel.shutdownNow(); } else { boolean isTerminated = false; lchannel.shutdownNow();
@Override public void onError(Throwable t) { ManagedChannel llmanagedChannel = managedChannel; if (llmanagedChannel != null) { try { llmanagedChannel.shutdownNow(); } catch (Exception e) { logger.warn(format("Received error on %s, attempts %d. %s shut down of grpc channel.", PeerEventServiceClient.this.toString(), peer == null ? -1 : peer.getReconnectCount(), e.getMessage()), e); } managedChannel = null; } if (!shutdown) { final long reconnectCount = peer.getReconnectCount(); if (PEER_EVENT_RECONNECTION_WARNING_RATE > 1 && reconnectCount % PEER_EVENT_RECONNECTION_WARNING_RATE == 1) { logger.warn(format("Received error on %s, attempts %d. %s", PeerEventServiceClient.this.toString(), reconnectCount, t.getMessage())); } else { logger.trace(format("Received error on %s, attempts %d. %s", PeerEventServiceClient.this.toString(), reconnectCount, t.getMessage())); } if (retry.getAndSet(false)) { peer.reconnectPeerEventServiceClient(PeerEventServiceClient.this, t); } } finishLatch.countDown(); }
@Override public void close() { loadContext.getPendingTaskRunner().shutdown(); for(ManagedChannel channel : loadContext.getChannels()) { channel.shutdownNow(); } }
lchannel.shutdownNow(); } catch (Exception e) { logger.warn(e); lchannel.shutdownNow(); } catch (Exception e) { logger.warn(toString(), e);
lchannel.shutdownNow(); } catch (Exception e) { logger.warn(e); lchannel.shutdownNow(); } catch (Exception e) { logger.warn(toString(), e);
ManagedChannel llmanagedChannel = managedChannel; if (llmanagedChannel != null) { llmanagedChannel.shutdownNow(); managedChannel = null; ManagedChannel llmanagedChannel = managedChannel; if (llmanagedChannel != null) { llmanagedChannel.shutdownNow(); managedChannel = null;
/** {@inheritDoc} */ @Override public ManagedChannel shutdownNow() { for (ManagedChannel channel : channels) { channel.shutdownNow(); } return this; }
@Override public void close() { if (!closed.getAndSet(true)) { this.channel.shutdownNow(); // Initiates a shutdown of channel. } }