You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by sh...@apache.org on 2020/07/29 16:43:04 UTC

[hadoop-ozone] branch master updated: HDDS-4024. Avoid while loop too soon when exception happen (#1253)

This is an automated email from the ASF dual-hosted git repository.

shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new a96553e  HDDS-4024. Avoid while loop too soon when exception happen (#1253)
a96553e is described below

commit a96553e139642c1fa6d0344dc0b61d8324aa1d73
Author: runzhiwang <51...@users.noreply.github.com>
AuthorDate: Thu Jul 30 00:42:49 2020 +0800

    HDDS-4024. Avoid while loop too soon when exception happen (#1253)
---
 .../common/statemachine/DatanodeStateMachine.java     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
index 1f61f15..425074d 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
@@ -226,19 +226,26 @@ public class DatanodeStateMachine implements Closeable {
         nextHB.set(Time.monotonicNow() + heartbeatFrequency);
         context.execute(executorService, heartbeatFrequency,
             TimeUnit.MILLISECONDS);
-        now = Time.monotonicNow();
-        if (now < nextHB.get()) {
-          if(!Thread.interrupted()) {
-            Thread.sleep(nextHB.get() - now);
-          }
-        }
       } catch (InterruptedException e) {
         // Some one has sent interrupt signal, this could be because
         // 1. Trigger heartbeat immediately
         // 2. Shutdown has be initiated.
+        LOG.warn("Interrupt the execution.", e);
+        Thread.currentThread().interrupt();
       } catch (Exception e) {
         LOG.error("Unable to finish the execution.", e);
       }
+
+      now = Time.monotonicNow();
+      if (now < nextHB.get()) {
+        if(!Thread.interrupted()) {
+          try {
+            Thread.sleep(nextHB.get() - now);
+          } catch (InterruptedException e) {
+            LOG.warn("Interrupt the execution.", e);
+          }
+        }
+      }
     }
 
     // If we have got some exception in stateMachine we set the state to


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org