amaliujia commented on code in PR #1665:
URL: https://github.com/apache/ratis/pull/1665#discussion_r4385123386
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcUtil.java:
##########
@@ -238,11 +238,23 @@ Metadata build() {
* graceful shutdown times out.
*/
static void shutdownManagedChannel(ManagedChannel managedChannel) {
+ shutdownManagedChannel(managedChannel,
GrpcConfigKeys.Client.CHANNEL_SHUTDOWN_GRACEFUL_TIMEOUT_DEFAULT,
+ GrpcConfigKeys.Client.CHANNEL_SHUTDOWN_FORCEFUL_TIMEOUT_DEFAULT);
+ }
+
+ /**
+ * Shut down the given channel gracefully, waiting up to the graceful
timeout for its calls to finish,
+ * and then forcefully, cancelling the remaining calls, if it has not
terminated.
+ *
+ * @param gracefulTimeout zero skips the graceful shutdown.
+ */
+ static void shutdownManagedChannel(ManagedChannel managedChannel,
+ TimeDuration gracefulTimeout, TimeDuration forcefulTimeout) {
// Close the gRPC managed-channel if not shut down already.
- if (!managedChannel.isShutdown()) {
+ if (!managedChannel.isShutdown() && gracefulTimeout.isPositive()) {
Review Comment:
NVM right now skipping when 0 is also `ShutdownNow`. They have the same
effect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]