From b5e9d1e8bd2aae2fb3bf60cda64c73910ea7da14 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 29 May 2014 21:02:31 +0000 Subject: [PATCH] HDFS-6461. Use Time#monotonicNow to compute duration in DataNode#shutDown. Contributed by James Thomas. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1598400 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index dd9fc310b13..44102c0d476 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -292,6 +292,9 @@ Release 2.5.0 - UNRELEASED HDFS-6453. Use Time#monotonicNow to avoid system clock reset. (Liang Xie via wang) + HDFS-6461. Use Time#monotonicNow to compute duration in DataNode#shutDown. + (James Thomas via wang) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 349225460fb..2e542dad4e5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -1228,7 +1228,7 @@ public void shutdown() { } // Record the time of initial notification - long timeNotified = Time.now(); + long timeNotified = Time.monotonicNow(); if (localDataXceiverServer != null) { ((DataXceiverServer) this.localDataXceiverServer.getRunnable()).kill(); @@ -1260,8 +1260,9 @@ public void shutdown() { while (true) { // When shutting down for restart, wait 2.5 seconds before forcing // termination of receiver threads. - if (!this.shutdownForUpgrade || - (this.shutdownForUpgrade && (Time.now() - timeNotified > 2500))) { + if (!this.shutdownForUpgrade || + (this.shutdownForUpgrade && (Time.monotonicNow() - timeNotified + > 2500))) { this.threadGroup.interrupt(); } LOG.info("Waiting for threadgroup to exit, active threads is " +