yandrey321 commented on code in PR #9717:
URL: https://github.com/apache/ozone/pull/9717#discussion_r2771940990


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -235,24 +237,39 @@ private boolean isConnected(ManagedChannel channel) {
    * Closes all the communication channels of the client one-by-one.
    * When a channel is closed, no further requests can be sent via the channel,
    * and the method waits to finish all ongoing communication.
-   *
-   * Note: the method wait 1 hour per channel tops and if that is not enough
-   * to finish ongoing communication, then interrupts the connection anyway.
    */
   @Override
   public synchronized void close() {
     closed = true;
     for (ManagedChannel channel : channels.values()) {
-      channel.shutdownNow();
+      channel.shutdown();
+    }
+
+    final long maxWaitNanos = 
TimeUnit.SECONDS.toNanos(SHUTDOWN_WAIT_MAX_SECONDS);
+    long deadline = System.nanoTime() + maxWaitNanos;
+    List<ManagedChannel> nonTerminatedChannels = new 
ArrayList<>(channels.values());
+
+    while (!nonTerminatedChannels.isEmpty() && System.nanoTime() < deadline) {
+      nonTerminatedChannels.removeIf(ManagedChannel::isTerminated);
+
       try {
-        channel.awaitTermination(60, TimeUnit.MINUTES);
+        if (!nonTerminatedChannels.isEmpty()) {
+          ManagedChannel channel = nonTerminatedChannels.get(0);

Review Comment:
   why not just sleep?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to