ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-17816 Rebalance HDFS failed with "float division by zero" (dlysnichenko)
Date Wed, 20 Jul 2016 16:48:54 GMT
AMBARI-17816 Rebalance HDFS failed with "float division by zero" (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3e636b5c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3e636b5c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3e636b5c

Branch: refs/heads/branch-2.4
Commit: 3e636b5cf081485ee9ea8b6a2a1767bfa030d177
Parents: 0b29e1f
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Wed Jul 20 19:47:53 2016 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Wed Jul 20 19:48:28 2016 +0300

----------------------------------------------------------------------
 .../HDFS/2.1.0.2.0/package/scripts/namenode.py            | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3e636b5c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
index b37f413..17d8107 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
@@ -303,7 +303,13 @@ class NameNodeDefault(NameNode):
         Execute(kinit_cmd, user=params.hdfs_user)
 
     def calculateCompletePercent(first, current):
-      return 1.0 - current.bytesLeftToMove/first.bytesLeftToMove
+      # avoid division by zero
+      try:
+        division_result = current.bytesLeftToMove/first.bytesLeftToMove
+      except ZeroDivisionError:
+        Logger.warning("Division by zero. Bytes Left To Move = {0}. Return 1.0".format(first.bytesLeftToMove))
+        return 1.0
+      return 1.0 - division_result
 
 
     def startRebalancingProcess(threshold, rebalance_env):
@@ -324,7 +330,7 @@ class NameNodeDefault(NameNode):
     def handle_new_line(line, is_stderr):
       if is_stderr:
         return
-      
+
       _print('[balancer] %s' % (line))
       pl = parser.parseLine(line)
       if pl:


Mime
View raw message