Class: Houdah::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/houdah/job.rb

Constant Summary collapse

STATES =
[ :running, :succeeded, :failed, :prep, :killed ]

Instance Method Summary collapse

Constructor Details

#initialize(client, thrift_job) ⇒ Job

Returns a new instance of Job.



8
9
10
11
12
# File 'lib/houdah/job.rb', line 8

def initialize(client, thrift_job)
  @client = client
  @thrift_job = thrift_job
  @parsed_config = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



51
52
53
# File 'lib/houdah/job.rb', line 51

def method_missing(method, *args)
  @thrift_job.send method, *args
end

Instance Method Details

#call(method, *args) ⇒ Object



59
60
61
# File 'lib/houdah/job.rb', line 59

def call(method, *args)
  @client.call method, @thrift_job.jobID, *args
end

#configObject

Get the job’s config, as a Hash



20
21
22
23
24
25
# File 'lib/houdah/job.rb', line 20

def config
  @parsed_config ||= Nokogiri::XML(config_xml).xpath("//property").inject({}) { |props, xprop|
    props[xprop.xpath("./name").text] = xprop.xpath("./value").text
    props
  }
end

#config_xmlObject

Get the job’s config XML



15
16
17
# File 'lib/houdah/job.rb', line 15

def config_xml
  call :getJobConfXML
end

#kill!Object



55
56
57
# File 'lib/houdah/job.rb', line 55

def kill!
  call :killJob
end

#percent_cleaned_upObject



39
40
41
# File 'lib/houdah/job.rb', line 39

def percent_cleaned_up
  @thrift_job.status.cleanupProgress
end

#percent_doneObject



47
48
49
# File 'lib/houdah/job.rb', line 47

def percent_done
  (percent_mapped + percent_reduced) / 2.0
end

#percent_mappedObject



31
32
33
# File 'lib/houdah/job.rb', line 31

def percent_mapped
  @thrift_job.status.mapProgress
end

#percent_reducedObject



35
36
37
# File 'lib/houdah/job.rb', line 35

def percent_reduced
  @thrift_job.status.reduceProgress
end

#percent_set_upObject



43
44
45
# File 'lib/houdah/job.rb', line 43

def percent_set_up
  @thrift_job.status.setupProgress
end

#stateObject



27
28
29
# File 'lib/houdah/job.rb', line 27

def state
  STATES[@thrift_job.status.runState - 1]
end