         code_skipped: 1
       , (err, stopped) ->
         callback err, stopped
+  nn_restart: (ctx, callback) ->
+    ctx.log "NameNode restart"
+    lifecyle.nn_stop ctx, (err) ->
+      return callback err if err
+      lifecyle.nn_start ctx, callback
   zkfc_status: (ctx, callback) ->
     {hdfs_user, hdfs_pid_dir} = ctx.config.hdp
     ctx.log "ZKFC status"

        code_skipped: 1
      , (err, stopped) ->
        callback err, stopped
  zookeeper_status: (ctx, callback) ->
    {zookeeper_pid_dir} = ctx.config.hdp
    ctx.log "Zookeeper status"
    {oozie_pid_dir} = ctx.config.hdp
    lifecyle.is_pidfile_running ctx, "#{zookeeper_pid_dir}/zookeeper_server.pid", (err, running) ->
      ctx.log "Zookeeper status: #{if running then 'RUNNING' else 'STOPED'}"
      callback err, running
  zookeeper_start: (ctx, callback) ->
    {zookeeper_user, zookeeper_conf_dir, zookeeper_port} = ctx.config.hdp
    lifecyle.zookeeper_status ctx, (err, running) ->
      return callback err, false if err or running
      ctx.log "Zookeeper start"
      ctx.execute
        # su -l zookeeper -c "/usr/lib/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zoo.cfg"
        cmd: "su -l #{zookeeper_user.name} -c \"/usr/lib/zookeeper/bin/zkServer.sh start #{zookeeper_conf_dir}/zoo.cfg\""
      , (err, started) ->
        return callback err if err
        ctx.waitIsOpen ctx.config.host, zookeeper_port, timeout: 2000000, (err) ->
          callback err, started
  zookeeper_stop: (ctx, callback) ->
    {zookeeper_user, zookeeper_conf_dir} = ctx.config.hdp
    lifecyle.zookeeper_status ctx, (err, running) ->
      return callback err, false if err or not running
      ctx.log "Zookeeper stop"
      ctx.execute
        # su -l zookeeper -c "/usr/lib/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zoo.cfg"
        cmd: "su -l #{zookeeper_user.name} -c \"/usr/lib/zookeeper/bin/zkServer.sh stop #{zookeeper_conf_dir}/zoo.cfg\""
      , (err, stopped) ->
        callback err, stopped
  hbase_master_status: (ctx, callback) ->
    {hbase_pid_dir, hbase_user} = ctx.config.hdp
    ctx.log "HBase Master status"

      ctx.log "Hue stop"
      ctx.execute
        cmd: "service hue stop"
      , (err, stopped) ->
        callback err, stopped
  zookeeper_status: (ctx, callback) ->
    {zookeeper_pid_dir} = ctx.config.hdp
    ctx.log "Zookeeper status"
    {oozie_pid_dir} = ctx.config.hdp
    lifecyle.is_pidfile_running ctx, "#{zookeeper_pid_dir}/zookeeper_server.pid", (err, running) ->
      ctx.log "Zookeeper status: #{if running then 'RUNNING' else 'STOPED'}"
      callback err, running
  zookeeper_start: (ctx, callback) ->
    {zookeeper_user, zookeeper_conf_dir, zookeeper_port} = ctx.config.hdp
    lifecyle.zookeeper_status ctx, (err, running) ->
      return callback err, false if err or running
      ctx.log "Zookeeper start"
      ctx.execute
        # su -l zookeeper -c "/usr/lib/zookeeper/bin/zkServer.sh start /etc/zookeeper/conf/zoo.cfg"
        cmd: "su -l #{zookeeper_user.name} -c \"/usr/lib/zookeeper/bin/zkServer.sh start #{zookeeper_conf_dir}/zoo.cfg\""
      , (err, started) ->
        return callback err if err
        ctx.waitIsOpen ctx.config.host, zookeeper_port, timeout: 2000000, (err) ->
          callback err, started
  zookeeper_stop: (ctx, callback) ->
    {zookeeper_user, zookeeper_conf_dir} = ctx.config.hdp
    lifecyle.zookeeper_status ctx, (err, running) ->
      return callback err, false if err or not running
      ctx.log "Zookeeper stop"
      ctx.execute
        # su -l zookeeper -c "/usr/lib/zookeeper/bin/zkServer.sh stop /etc/zookeeper/conf/zoo.cfg"
        cmd: "su -l #{zookeeper_user.name} -c \"/usr/lib/zookeeper/bin/zkServer.sh stop #{zookeeper_conf_dir}/zoo.cfg\""
      , (err, stopped) ->
        callback err, stopped

