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.
-
#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.
-
#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 |
# 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 @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 @error = nil @status = STATUS_NONE @owner = nil @dry_run = false @quiet = false @time_start = nil @time_end = nil @results = 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 |
#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 |
#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
77 78 79 |
# File 'lib/right_chimp/exec/Executor.rb', line 77 def cancel @group.cancel(self.job_id) end |
#get_total_exec_time ⇒ Object
Return total execution time (real) of a job
50 51 52 53 54 55 56 57 58 |
# File 'lib/right_chimp/exec/Executor.rb', line 50 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
88 89 90 |
# File 'lib/right_chimp/exec/Executor.rb', line 88 def info raise "unimplemented" end |
#queue ⇒ Object
Convenience method to queue a held job
63 64 65 |
# File 'lib/right_chimp/exec/Executor.rb', line 63 def queue @group.queue(self.job_id) end |
#requeue ⇒ Object
Convenience method to requeue
70 71 72 |
# File 'lib/right_chimp/exec/Executor.rb', line 70 def requeue @group.requeue(self.job_id) end |
#run ⇒ Object
81 82 83 |
# File 'lib/right_chimp/exec/Executor.rb', line 81 def run raise "run method must be overridden" end |
#target ⇒ Object
92 93 94 |
# File 'lib/right_chimp/exec/Executor.rb', line 92 def target return "UNKNOWN" end |