runzhiwang commented on a change in pull request #1185:
URL: https://github.com/apache/hadoop-ozone/pull/1185#discussion_r454194380



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/datanode/RunningDatanodeState.java
##########
@@ -200,22 +203,31 @@ public void execute(ExecutorService executor) {
   @Override
   public DatanodeStateMachine.DatanodeStates
       await(long duration, TimeUnit timeUnit)
-      throws InterruptedException, ExecutionException, TimeoutException {
+      throws InterruptedException {
     int count = connectionManager.getValues().size();
     int returned = 0;
-    long timeLeft = timeUnit.toMillis(duration);
+    long durationMS = timeUnit.toMillis(duration);
     long startTime = Time.monotonicNow();
-    List<Future<EndPointStates>> results = new LinkedList<>();
-
-    while (returned < count && timeLeft > 0) {
-      Future<EndPointStates> result =
-          ecs.poll(timeLeft, TimeUnit.MILLISECONDS);
-      if (result != null) {
-        results.add(result);
-        returned++;
+    Set<Future<EndPointStates>> results = new HashSet<>();
+
+    while (returned < count
+        && (durationMS - (Time.monotonicNow() - startTime))> 0) {
+      for (Future<EndPointStates> future : futures) {
+        if (future != null && future.isDone() && !results.contains(future)) {
+          results.add(future);
+          returned++;
+        }
       }
-      timeLeft = timeLeft - (Time.monotonicNow() - startTime);
+
+      Thread.sleep(durationMS / 10);
     }
+
+    for (Future<EndPointStates> future : futures) {
+      if (future != null && !future.isDone()) {
+        future.cancel(true);

Review comment:
       Maybe the future can not finish forever, because the rpc call blocked 
forever, as we found in production cluster.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to