Class: Chimp::Executor
- Inherits:
-
Object
- Object
- Chimp::Executor
- Defined in:
- lib/right_chimp/exec/executor.rb
Direct Known Subclasses
ExecArray, ExecCallback, ExecNoop, ExecReport, ExecRightScript, ExecSSH
Constant Summary collapse
- STATUS_NONE =
:none
- STATUS_HOLDING =
:holding
- STATUS_RUNNING =
:running
- STATUS_RETRYING =
:retrying
- STATUS_ERROR =
:error
- STATUS_DONE =
:done
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#concurrency ⇒ Object
Returns the value of attribute concurrency.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#error ⇒ Object
Returns the value of attribute error.
-
#exec ⇒ Object
Returns the value of attribute exec.
-
#group ⇒ Object
Returns the value of attribute group.
-
#inputs ⇒ Object
Returns the value of attribute inputs.
-
#job_id ⇒ Object
Returns the value of attribute job_id.
-
#job_notes ⇒ Object
Returns the value of attribute job_notes.
-
#job_uuid ⇒ Object
Returns the value of attribute job_uuid.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#retry_count ⇒ Object
Returns the value of attribute retry_count.
-
#retry_sleep ⇒ Object
Returns the value of attribute retry_sleep.
-
#server ⇒ Object
Returns the value of attribute server.
-
#status ⇒ Object
Returns the value of attribute status.
-
#template ⇒ Object
Returns the value of attribute template.
-
#time_end ⇒ Object
Returns the value of attribute time_end.
-
#time_start ⇒ Object
Returns the value of attribute time_start.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#cancel ⇒ Object
Convenience method to cancel.
-
#get_total_exec_time ⇒ Object
Return total execution time (real) of a job.
-
#info ⇒ Object
return info on what this executor does – eg name of script or command.
-
#initialize(h = {}) ⇒ Executor
constructor
A new instance of Executor.
-
#queue ⇒ Object
Convenience method to queue a held job.
-
#requeue ⇒ Object
Convenience method to requeue.
- #run ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(h = {}) ⇒ Executor
Returns a new instance of Executor.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/right_chimp/exec/executor.rb', line 20 def initialize(h={}) @server = h[:server] || nil @array = h[:array] || nil @template = h[:template] || nil @job_id = h[:job_id] || nil @job_uuid = h[:job_uuid] || nil @job_notes = h[:job_notes] || nil @group = h[:group] || nil @exec = h[:exec] || nil @inputs = h[:inputs] || nil @verbose = h[:verbose] || false @retry_count = h[:retry_count].to_i || 0 @retry_sleep = h[:retry_sleep].to_i || 30 @timeout = h[:timeout].to_i || 3600 @delay = h[:delay].to_i || 0 @concurrency = h[:concurrency].to_i @error = nil @status = STATUS_NONE @owner = nil @dry_run = false @quiet = false @time_start = nil @time_end = nil end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def array @array end |
#concurrency ⇒ Object
Returns the value of attribute concurrency.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def concurrency @concurrency end |
#delay ⇒ Object
Returns the value of attribute delay.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def delay @delay end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def dry_run @dry_run end |
#error ⇒ Object
Returns the value of attribute error.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def error @error end |
#exec ⇒ Object
Returns the value of attribute exec.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def exec @exec end |
#group ⇒ Object
Returns the value of attribute group.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def group @group end |
#inputs ⇒ Object
Returns the value of attribute inputs.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def inputs @inputs end |
#job_id ⇒ Object
Returns the value of attribute job_id.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def job_id @job_id end |
#job_notes ⇒ Object
Returns the value of attribute job_notes.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def job_notes @job_notes end |
#job_uuid ⇒ Object
Returns the value of attribute job_uuid.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def job_uuid @job_uuid end |
#owner ⇒ Object
Returns the value of attribute owner.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def owner @owner end |
#quiet ⇒ Object
Returns the value of attribute quiet.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def quiet @quiet end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
11 12 13 |
# File 'lib/right_chimp/exec/executor.rb', line 11 def results @results end |
#retry_count ⇒ Object
Returns the value of attribute retry_count.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def retry_count @retry_count end |
#retry_sleep ⇒ Object
Returns the value of attribute retry_sleep.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def retry_sleep @retry_sleep end |
#server ⇒ Object
Returns the value of attribute server.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def server @server end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def status @status end |
#template ⇒ Object
Returns the value of attribute template.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def template @template end |
#time_end ⇒ Object
Returns the value of attribute time_end.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def time_end @time_end end |
#time_start ⇒ Object
Returns the value of attribute time_start.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def time_start @time_start end |
#timeout ⇒ Object
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def timeout @timeout end |
#verbose ⇒ Object
Returns the value of attribute verbose.
7 8 9 |
# File 'lib/right_chimp/exec/executor.rb', line 7 def verbose @verbose end |
Instance Method Details
#cancel ⇒ Object
Convenience method to cancel
82 83 84 |
# File 'lib/right_chimp/exec/executor.rb', line 82 def cancel @group.cancel(self.job_id) end |
#get_total_exec_time ⇒ Object
Return total execution time (real) of a job
55 56 57 58 59 60 61 62 63 |
# File 'lib/right_chimp/exec/executor.rb', line 55 def get_total_exec_time if @time_start == nil return 0 elsif @time_end == nil return Time.now.to_i - @time_start.to_i else return @time_end.to_i- @time_start.to_i end end |
#info ⇒ Object
return info on what this executor does – eg name of script or command
93 94 95 |
# File 'lib/right_chimp/exec/executor.rb', line 93 def info raise "unimplemented" end |
#queue ⇒ Object
Convenience method to queue a held job
68 69 70 |
# File 'lib/right_chimp/exec/executor.rb', line 68 def queue @group.queue(self.job_id) end |
#requeue ⇒ Object
Convenience method to requeue
75 76 77 |
# File 'lib/right_chimp/exec/executor.rb', line 75 def requeue @group.requeue(self.job_id) end |
#run ⇒ Object
86 87 88 |
# File 'lib/right_chimp/exec/executor.rb', line 86 def run raise "run method must be overridden" end |
#target ⇒ Object
97 98 99 |
# File 'lib/right_chimp/exec/executor.rb', line 97 def target return "UNKNOWN" end |