 
+fs = require 'fs'
 lifecycle = require './lib/lifecycle'
 mkcmd = require './lib/mkcmd'
 each = require 'each'

module.exports.push 'phyla/hdp/hdfs'
module.exports.push 'phyla/core/nc'

module.exports.push (ctx) ->
  require('./hdfs').configure ctx
  require('../core/nc').configure ctx

      # TODO: There was a time when fencing wasnt ok the first time,
      # this is probably no longer the case, but we need to test before
      # removing the following command.
      # ctx.execute
      #   # hdfs haadmin -transitionToActive -forcemanual hadoop2
      #   cmd: "yes | hdfs haadmin -transitionToActive -forcemanual #{ctx.config.host}"
      #   if: formated
      # , (err, activated) ->
      #   return next err if err
      #   ctx.log "Was #{ctx.config.host} activated: #{activated}"
      #   # next null, if modified then ctx.OK else ctx.PASS
      #   lifecycle.zkfc_start ctx, (err, started) ->
      #     next null, if formated or started then ctx.OK else ctx.PASS
      lifecycle.zkfc_start ctx, (err, started) ->
        next null, if formated or started then ctx.OK else ctx.PASS
  do_zkfc_standby = ->
    ctx.log "Wait for active NameNode to take leadership"
    ctx.waitForExecution
