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 27e814b30c3d..a191bcbdf2a8 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 @@ -224,19 +224,26 @@ private void start() throws IOException { 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