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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java:
##########
@@ -299,13 +299,42 @@ public void shutdown() {
     for (Map.Entry<String, ManagedChannel> entry : channels.entrySet()) {
       ManagedChannel channel = entry.getValue();
       channel.shutdown();
+    }
+
+    final long maxWaitMillis = TimeUnit.SECONDS.toMillis(5);
+    long startDeadline = System.currentTimeMillis();
+    long elapsed = 0;
+    boolean allTerminated = false;
+
+    while (elapsed < maxWaitMillis) {
+      allTerminated = true;
+      for (Map.Entry<String, ManagedChannel> entry : channels.entrySet()) {
+        ManagedChannel channel = entry.getValue();
+        if (!channel.isTerminated()) {
+          allTerminated = false;
+          break;
+        }
+      }
+      if (allTerminated) {
+        break;
+      }
       try {
-        channel.awaitTermination(5, TimeUnit.SECONDS);
-      } catch (Exception e) {
-        LOG.error("failed to shutdown OzoneManagerServiceGrpc channel {} : {}",
-            entry.getKey(), e);
+        Thread.sleep(100);

Review Comment:
   use named constant



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