Class: Commands::LogsCommand

Inherits:
AbstractSSHCommand show all
Defined in:
lib/commands.rb

Constant Summary collapse

INTERESTING_STEP_STATES =
['RUNNING', 'COMPLETED', 'FAILED']

Constants inherited from AbstractSSHCommand

AbstractSSHCommand::CLOSED_DOWN_STATES, AbstractSSHCommand::WAITING_OR_RUNNING_STATES

Instance Attribute Summary collapse

Attributes inherited from AbstractSSHCommand

#dest, #hostname, #jobflow_detail, #jobflow_id, #key_pair_file, #no_wait

Attributes inherited from Command

#arg, #commands, #description, #logger, #name

Instance Method Summary collapse

Methods inherited from AbstractSSHCommand

#exec, #wait_for_jobflow

Methods inherited from Command

#get_field, #has_value, #have, #initialize, #option, #require, #require_single_jobflow, #resolve, #validate

Constructor Details

This class inherits a constructor from Commands::Command

Instance Attribute Details

#step_indexObject

Returns the value of attribute step_index.



667
668
669
# File 'lib/commands.rb', line 667

def step_index
  @step_index
end

Instance Method Details

#enact(client) ⇒ Object



671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/commands.rb', line 671

def enact(client)
  super(client)

  # find the last interesting step if that exists
  if get_field(:step_index) == nil then
    steps = resolve(jobflow_detail, "Steps")
    self.step_index = (0 ... steps.size).select { |index| 
      INTERESTING_STEP_STATES.include?(resolve(steps, index, 'ExecutionStatusDetail', 'State'))
    }.last + 1
  end

  if get_field(:step_index) then
    logger.puts "Listing steps for step #{get_field(:step_index)}"
    exec "ssh -i #{key_pair_file} hadoop@#{hostname} cat /mnt/var/log/hadoop/steps/#{get_field(:step_index)}/{syslog,stderr,stdout}"
  else
    raise RuntimeError, "No steps that could have logs found in jobflow"
  end
end