Module: OozieJobs
- Included in:
- OozieApi
- Defined in:
- lib/oozie_jobs.rb
Defined Under Namespace
Classes: ConfMaker
Instance Method Summary collapse
- #conf_xml_to_properties_hash(conf_xml) ⇒ Object
- #coordinators(params = {}) ⇒ Object
- #definition(job_id) ⇒ Object
- #info(job_id) ⇒ Object
- #kill_job(job_id) ⇒ Object
- #log(job_id) ⇒ Object
- #properties_hash_to_conf_xml(properties_hash) ⇒ Object
- #resume_job(job_id) ⇒ Object
- #start_job(job_id) ⇒ Object
-
#submit_job(properties, params = {}) ⇒ Object
submit a job given the properties, params optionsl properties is a hash of the form => value param example: => :start [starts the job on submission].
- #suspend_job(job_id) ⇒ Object
- #workflows(params = {}) ⇒ Object
Instance Method Details
#conf_xml_to_properties_hash(conf_xml) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/oozie_jobs.rb', line 80 def conf_xml_to_properties_hash(conf_xml) doc = REXML::Document.new(conf_xml) properties = {} doc.elements.each("//property") do |property| name = property.elements["name"].text value = property.elements["value"].text properties[name] = value end return properties end |
#coordinators(params = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/oozie_jobs.rb', line 12 def coordinators(params={}) # TODO: checking for filter/user, offset, len resource = "/jobs?jobtype=coord" results = oozie_get(resource, :json) results['coordinatorjobs'] ||= [] results['coordinatorjobs'].map{|wf| OozieJob.new(wf)} end |
#definition(job_id) ⇒ Object
27 28 29 30 31 |
# File 'lib/oozie_jobs.rb', line 27 def definition(job_id) resource = "/job/#{job_id}?show=definition" oozie_get(resource) end |
#info(job_id) ⇒ Object
33 34 35 36 37 |
# File 'lib/oozie_jobs.rb', line 33 def info(job_id) resource = "/job/#{job_id}?show=info" OozieJob.new oozie_get(resource, :json) end |
#kill_job(job_id) ⇒ Object
70 71 72 73 |
# File 'lib/oozie_jobs.rb', line 70 def kill_job(job_id) resource = "/job/#{job_id}?action=kill" oozie_put(resource) end |
#log(job_id) ⇒ Object
21 22 23 24 25 |
# File 'lib/oozie_jobs.rb', line 21 def log(job_id) resource = "/job/#{job_id}?show=log" oozie_get(resource) end |
#properties_hash_to_conf_xml(properties_hash) ⇒ Object
75 76 77 78 |
# File 'lib/oozie_jobs.rb', line 75 def properties_hash_to_conf_xml(properties_hash) conf_xml = ConfMaker.new(properties_hash).conf return conf_xml end |
#resume_job(job_id) ⇒ Object
65 66 67 68 |
# File 'lib/oozie_jobs.rb', line 65 def resume_job(job_id) resource = "/job/#{job_id}?action=resume" oozie_put(resource) end |
#start_job(job_id) ⇒ Object
55 56 57 58 |
# File 'lib/oozie_jobs.rb', line 55 def start_job(job_id) resource = "/job/#{job_id}?action=start" oozie_put(resource) end |
#submit_job(properties, params = {}) ⇒ Object
submit a job given the properties, params optionsl properties is a hash of the form => value param example: => :start [starts the job on submission]
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/oozie_jobs.rb', line 42 def submit_job(properties, params = {}) body = properties_hash_to_conf_xml(properties) start_now = params[:start_now] proper_params = params.map{|k,v| "#{k}=#{v}"}.join("&") resource = "/jobs?#{proper_params}" response = oozie_post(resource, :json, :body => body, :headers => {"Content-Type" => "application/xml"}) id = response['id'] info(id) end |
#suspend_job(job_id) ⇒ Object
60 61 62 63 |
# File 'lib/oozie_jobs.rb', line 60 def suspend_job(job_id) resource = "/job/#{job_id}?action=suspend" oozie_put(resource) end |
#workflows(params = {}) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/oozie_jobs.rb', line 4 def workflows(params={}) # TODO: checking for filter/user, offset, len resource = "/jobs?jobtype=wf" results = oozie_get(resource, :json) results['workflows'] ||= [] results['workflows'].map{|wf| OozieJob.new(wf)} end |