Class: Patriot::JobStore::Base
- Inherits:
-
Object
- Object
- Patriot::JobStore::Base
- Includes:
- Util::Logger
- Defined in:
- lib/patriot/job_store/base.rb
Overview
base class of JobStore
Direct Known Subclasses
Constant Summary
Constants included from Util::Config
Util::Config::ADMIN_USER_KEY, Util::Config::DEFAULT_CONFIG, Util::Config::DEFAULT_PLUGIN_DIR, Util::Config::INFO_SERVER_PORT_KEY, Util::Config::PASSWORD_KEY, Util::Config::PLUGIN_DIR_KEY, Util::Config::PLUGIN_INIT_SCRIPT, Util::Config::PLUGIN_KEY, Util::Config::PLUGIN_LIB_DIR, Util::Config::USERNAME_KEY, Util::Config::WORKER_HOST_KEY, Util::Config::WORKER_USER_KEY
Instance Method Summary collapse
-
#acceptable?(command) ⇒ Boolean
check whether the command can be stored as a job to this job_store.
-
#delete_job(job_id) ⇒ Object
delete the job from this job_store.
-
#find_jobs_by_state(state, opts = {}) ⇒ Array
An array of job_id which is in the given state.
-
#get(job_id, opts = {}) ⇒ Patrio::JobStore::Job
get a job jobs in dependency set to :consumers/:producers as a hash from job_id to state.
-
#get_consumers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) ⇒ Hash
get consumers of products.
-
#get_execution_history(job_id, opts = {}) ⇒ Object
get execution histories of the specified job.
-
#get_graph(job_id, opts = {}) ⇒ Array
get nodes and edges information to render graph.
-
#get_job(job_id) ⇒ Patriot::JobStore::Job
get a job data.
-
#get_job_size(opts = {}) ⇒ Hash<Patriot::JobStore::JobState, Integer>
A hash from job state to the number of jobs in the state.
-
#get_job_tickets(host, nodes, opts = {}) ⇒ Object
get job tickets for jobs which are ready to execute.
-
#get_producers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) ⇒ Hash
get producers of products.
-
#initialize(store_id, config) ⇒ Base
constructor
A new instance of Base.
-
#offer_to_execute(job_ticket) ⇒ Hash
offer to execute a job specified with a job_ticket If the job is ready to execute, the state of job is set to JobState::RUNNING.
-
#process_subsequent(job_ids) {|job_store, jobs| ... } ⇒ Object
Process subsequent jobs with a given block.
-
#register(update_id, jobs) ⇒ Object
register the given jobs with the given update_id.
-
#report_completion_status(job_ticket) ⇒ Boolean
report completion status a job specified with a job_ticket The state of the job should be changed according to the completion status.
-
#set_state(update_id, job_ids, new_state) ⇒ Object
set jobs state.
Methods included from Util::Logger
Methods included from Util::Config
Constructor Details
#initialize(store_id, config) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/patriot/job_store/base.rb', line 11 def initialize(store_id, config) raise NotImplementedError end |
Instance Method Details
#acceptable?(command) ⇒ Boolean
check whether the command can be stored as a job to this job_store
25 26 27 |
# File 'lib/patriot/job_store/base.rb', line 25 def acceptable?(command) raise NotImplementedError end |
#delete_job(job_id) ⇒ Object
delete the job from this job_store
143 144 145 |
# File 'lib/patriot/job_store/base.rb', line 143 def delete_job(job_id) raise NotImplementedError end |
#find_jobs_by_state(state, opts = {}) ⇒ Array
Returns an array of job_id which is in the given state.
130 131 132 |
# File 'lib/patriot/job_store/base.rb', line 130 def find_jobs_by_state(state, opts = {}) raise NotImplementedError end |
#get(job_id, opts = {}) ⇒ Patrio::JobStore::Job
get a job jobs in dependency set to :consumers/:producers as a hash from job_id to state
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/patriot/job_store/base.rb', line 71 def get(job_id, opts={}) return nil if job_id.nil? job = get_job(job_id) return if job.nil? if opts[:include_dependency] == true job[:consumers] = get_consumers(job[Patriot::Command::PRODUCTS_ATTR]) || [] job[:producers] = get_producers(job[Patriot::Command::REQUISITES_ATTR]) || [] end return job end |
#get_consumers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) ⇒ Hash
get consumers of products
103 104 105 |
# File 'lib/patriot/job_store/base.rb', line 103 def get_consumers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) raise NotImplementedError end |
#get_execution_history(job_id, opts = {}) ⇒ Object
get execution histories of the specified job
112 113 114 |
# File 'lib/patriot/job_store/base.rb', line 112 def get_execution_history(job_id, opts = {}) raise NotImplementedError end |
#get_graph(job_id, opts = {}) ⇒ Array
get nodes and edges information to render graph
120 121 122 |
# File 'lib/patriot/job_store/base.rb', line 120 def get_graph(job_id, opts = {}) raise NotImplementedError end |
#get_job(job_id) ⇒ Patriot::JobStore::Job
get a job data
85 86 87 |
# File 'lib/patriot/job_store/base.rb', line 85 def get_job(job_id) raise NotImplementedError end |
#get_job_size(opts = {}) ⇒ Hash<Patriot::JobStore::JobState, Integer>
Returns a hash from job state to the number of jobs in the state.
137 138 139 |
# File 'lib/patriot/job_store/base.rb', line 137 def get_job_size(opts = {}) raise NotImplementedError end |
#get_job_tickets(host, nodes, opts = {}) ⇒ Object
get job tickets for jobs which are ready to execute
34 35 36 |
# File 'lib/patriot/job_store/base.rb', line 34 def get_job_tickets(host, nodes, opts = {}) raise NotImplementedError end |
#get_producers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) ⇒ Hash
get producers of products
94 95 96 |
# File 'lib/patriot/job_store/base.rb', line 94 def get_producers(products, opts = {:include_attrs => [Patriot::Command::STATE_ATTR]}) raise NotImplementedError end |
#offer_to_execute(job_ticket) ⇒ Hash
offer to execute a job specified with a job_ticket If the job is ready to execute, the state of job is set to JobState::RUNNING. A response of this method is a Hash including
-
:execution_id the identifier of the execution (used to identify history record)
-
:command an instance of command for the offered job
45 46 47 |
# File 'lib/patriot/job_store/base.rb', line 45 def offer_to_execute(job_ticket) raise NotImplementedError end |
#process_subsequent(job_ids) {|job_store, jobs| ... } ⇒ Object
Process subsequent jobs with a given block. The block is called for each dependency depth.
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/patriot/job_store/base.rb', line 152 def process_subsequent(job_ids, &blk) products = job_ids.map{|jid| job = get_job(jid) job.nil? ? nil : job[Patriot::Command::PRODUCTS_ATTR] }.compact.flatten consumers = get_consumers(products) while !consumers.empty? jobs = consumers.map{|job| get_job(job[:job_id])}.compact yield self, jobs products = jobs.map{|j| j[Patriot::Command::PRODUCTS_ATTR]}.compact.flatten consumers = get_consumers(products) end end |
#register(update_id, jobs) ⇒ Object
register the given jobs with the given update_id
18 19 20 |
# File 'lib/patriot/job_store/base.rb', line 18 def register(update_id, jobs) raise NotImplementedError end |
#report_completion_status(job_ticket) ⇒ Boolean
report completion status a job specified with a job_ticket The state of the job should be changed according to the completion status.
53 54 55 |
# File 'lib/patriot/job_store/base.rb', line 53 def report_completion_status(job_ticket) raise NotImplementedError end |
#set_state(update_id, job_ids, new_state) ⇒ Object
set jobs state
61 62 63 |
# File 'lib/patriot/job_store/base.rb', line 61 def set_state(update_id, job_ids, new_state) raise NotImplementedError end |