You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vi...@apache.org on 2012/06/06 23:32:32 UTC

svn commit: r1347145 - in /incubator/ambari/branches/ambari-186: ./ hmc/puppet/modules/hdp-ganglia/manifests/ hmc/puppet/modules/hdp-hadoop/files/ hmc/puppet/modules/hdp-hadoop/manifests/ hmc/puppet/modules/hdp-hadoop/manifests/namenode/

Author: vikram
Date: Wed Jun  6 21:32:31 2012
New Revision: 1347145

URL: http://svn.apache.org/viewvc?rev=1347145&view=rev
Log:
AMBARI-382. Make sure install/uninstall/reinstall preserves data on HDFS/ZK/others. (Contributed by Ramya)

Added:
    incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/
    incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/checkForFormat.sh
Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-ganglia/manifests/monitor_and_server.pp
    incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode.pp
    incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode/format.pp

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347145&r1=1347144&r2=1347145&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Wed Jun  6 21:32:31 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-382. Make sure install/uninstall/reinstall preserves data on HDFS/ZK/others. (Ramya via Vikram)
+
   AMBARI-377. Uninstall does not handle component dependencies. (Jitendra via Vikram)
 
   AMBARI-380. Clean up messages for Add Nodes and Deploy progress result (Yusaku via Vikram)

Modified: incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-ganglia/manifests/monitor_and_server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-ganglia/manifests/monitor_and_server.pp?rev=1347145&r1=1347144&r2=1347145&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-ganglia/manifests/monitor_and_server.pp (original)
+++ incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-ganglia/manifests/monitor_and_server.pp Wed Jun  6 21:32:31 2012
@@ -13,7 +13,7 @@ class hdp-ganglia::monitor_and_server(
       ensure => 'uninstalled'
       }
 
-    hdp::directory { [$ganglia_shell_cmds_dir,$ganglia_conf_dir,$ganglia_runtime_dir]:
+    hdp::directory { [$ganglia_conf_dir,$ganglia_runtime_dir]:
       service_state => $service_state,
       force => true
     }
@@ -23,7 +23,7 @@ class hdp-ganglia::monitor_and_server(
     }
 
     Class['hdp-ganglia::server::packages'] -> 
-      Hdp::Directory[$ganglia_shell_cmds_dir] ->  Hdp::Directory[$ganglia_conf_dir] -> Hdp::Directory[$ganglia_runtime_dir] ->
+      Hdp::Directory[$ganglia_conf_dir] -> Hdp::Directory[$ganglia_runtime_dir] ->
       Class['hdp-ganglia::config']
   } elsif ($service_state in ['running','stopped','installed_and_configured']) {
     class { 'hdp-ganglia': }

Added: incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/checkForFormat.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/checkForFormat.sh?rev=1347145&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/checkForFormat.sh (added)
+++ incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/files/checkForFormat.sh Wed Jun  6 21:32:31 2012
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+export hdfs_user=$1
+shift
+export conf_dir=$1
+shift
+export mark_file=$1
+shift
+export name_dirs=$*
+
+export EXIT_CODE=0
+export command="namenode -format"
+export list_of_non_empty_dirs=""
+
+if [[ ! -f $mark_file ]] ; then 
+  for dir in `echo $name_dirs | tr ',' ' '` ; do
+    echo "DIrname = $dir"
+    cmd="ls $dir | wc -l  | grep -q ^0$"
+    eval $cmd
+    if [[ $? -ne 0 ]] ; then
+      (( EXIT_CODE = $EXIT_CODE + 1 ))
+      list_of_non_empty_dirs="$list_of_non_empty_dirs $dir"
+    fi
+  done
+
+  if [[ $EXIT_CODE == 0 ]] ; then 
+    su - ${hdfs_user} -c "yes Y | hadoop --config ${conf_dir} ${command}"
+  else
+    echo "ERROR: Namenode directory(s) is non empty. Will not format the namenode. List of non-empty namenode dirs ${list_of_non_empty_dirs}"
+  fi
+fi
+
+exit $EXIT_CODE
+

Modified: incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode.pp?rev=1347145&r1=1347144&r2=1347145&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode.pp (original)
+++ incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode.pp Wed Jun  6 21:32:31 2012
@@ -1,7 +1,7 @@
 class hdp-hadoop::namenode(
   $service_state = $hdp::params::cluster_service_state,
   $slave_hosts = [],
-  $format = false,
+  $format = true,
   $opts = {}
 ) inherits hdp-hadoop::params
 {

Modified: incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode/format.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode/format.pp?rev=1347145&r1=1347144&r2=1347145&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode/format.pp (original)
+++ incubator/ambari/branches/ambari-186/hmc/puppet/modules/hdp-hadoop/manifests/namenode/format.pp Wed Jun  6 21:32:31 2012
@@ -3,16 +3,28 @@ class hdp-hadoop::namenode::format(
 )
 {
   $mark_file = $hdp-hadoop::params::namenode_formatted_mark_file
+  $dfs_name_dir = $hdp-hadoop::params::dfs_name_dir
+  $hdfs_user = $hdp::params::hdfs_user
+  $hadoop_conf_dir = $hdp-hadoop::params::conf_dir
+
   if ($force == true) {
       hdp-hadoop::exec-hadoop { 'namenode -format' :
       command => 'namenode -format',
       notify  => Hdp::Exec['set namenode mark']
     }
   } else {
-    hdp-hadoop::exec-hadoop { 'namenode -format' :
-      command  => 'namenode -format',
-      echo_yes => true,
+      file { '/tmp/checkForFormat.sh':
+      ensure => present,
+      source => "puppet:///modules/hdp-hadoop/checkForFormat.sh",
+      mode => '0755'
+    }
+
+    exec { '/tmp/checkForFormat.sh':
+      command   => "sh /tmp/checkForFormat.sh ${hdfs_user} ${hadoop_conf_dir} ${mark_file} ${dfs_name_dir} ",
       unless   => "test -f ${mark_file}",
+      require   => File['/tmp/checkForFormat.sh'],
+      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+      logoutput => "true",
       notify   => Hdp::Exec['set namenode mark']
     }
   }