You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/04/09 15:07:22 UTC
[2/2] ambari git commit: AMBARI-15789. If initial NN start runs into
problem while communicating with JN, restart does not work (aonishuk)
AMBARI-15789. If initial NN start runs into problem while communicating with JN, restart does not work (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0c270f9d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0c270f9d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0c270f9d
Branch: refs/heads/branch-2.2
Commit: 0c270f9d1a8fbff4c1d496864b64b479671c2566
Parents: 8fd4397
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Sat Apr 9 16:07:11 2016 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Sat Apr 9 16:07:11 2016 +0300
----------------------------------------------------------------------
.../2.1.0.2.0/package/scripts/hdfs_namenode.py | 23 ++++++++++++++------
1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0c270f9d/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
index 5f7d1a0..b62c3c5 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
@@ -325,11 +325,20 @@ def format_namenode(force=None):
bin_dir=params.hadoop_bin_dir,
conf_dir=hadoop_conf_dir)
else:
+ nn_name_dirs = params.dfs_name_dir.split(',')
if not is_namenode_formatted(params):
- Execute(format("yes Y | hdfs --config {hadoop_conf_dir} namenode -format"),
- user = params.hdfs_user,
- path = [params.hadoop_bin_dir]
- )
+ try:
+ Execute(format("yes Y | hdfs --config {hadoop_conf_dir} namenode -format"),
+ user = params.hdfs_user,
+ path = [params.hadoop_bin_dir]
+ )
+ except Fail:
+ # We need to clean-up mark directories, so we can re-run format next time.
+ for nn_name_dir in nn_name_dirs:
+ Execute(format("rm -rf {nn_name_dir}/*"),
+ user = params.hdfs_user,
+ )
+ raise
for m_dir in mark_dir:
Directory(m_dir,
recursive = True
@@ -344,7 +353,7 @@ def is_namenode_formatted(params):
for mark_dir in mark_dirs:
if os.path.isdir(mark_dir):
marked = True
- print format("{mark_dir} exists. Namenode DFS already formatted")
+ Logger.info(format("{mark_dir} exists. Namenode DFS already formatted"))
# Ensure that all mark dirs created for all name directories
if marked:
@@ -381,9 +390,9 @@ def is_namenode_formatted(params):
Execute(format("ls {name_dir} | wc -l | grep -q ^0$"),
)
marked = False
- except Exception:
+ except Fail:
marked = True
- print format("ERROR: Namenode directory(s) is non empty. Will not format the namenode. List of non-empty namenode dirs {nn_name_dirs}")
+ Logger.info(format("ERROR: Namenode directory(s) is non empty. Will not format the namenode. List of non-empty namenode dirs {nn_name_dirs}"))
break
return marked