Class: Chimp::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/right_chimp/exec/Executor.rb

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

Instance Method Summary collapse

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

#arrayObject

Returns the value of attribute array.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def array
  @array
end

#dry_runObject

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

#errorObject

Returns the value of attribute error.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def error
  @error
end

#execObject

Returns the value of attribute exec.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def exec
  @exec
end

#groupObject

Returns the value of attribute group.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def group
  @group
end

#inputsObject

Returns the value of attribute inputs.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def inputs
  @inputs
end

#job_idObject

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

#ownerObject

Returns the value of attribute owner.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def owner
  @owner
end

#quietObject

Returns the value of attribute quiet.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def quiet
  @quiet
end

#resultsObject (readonly)

Returns the value of attribute results.



11
12
13
# File 'lib/right_chimp/exec/Executor.rb', line 11

def results
  @results
end

#retry_countObject

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_sleepObject

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

#serverObject

Returns the value of attribute server.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def server
  @server
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def status
  @status
end

#templateObject

Returns the value of attribute template.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def template
  @template
end

#time_endObject

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_startObject

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

#timeoutObject

Returns the value of attribute timeout.



7
8
9
# File 'lib/right_chimp/exec/Executor.rb', line 7

def timeout
  @timeout
end

#verboseObject

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

#cancelObject

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_timeObject

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

#infoObject

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

#queueObject

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

#requeueObject

Convenience method to requeue



70
71
72
# File 'lib/right_chimp/exec/Executor.rb', line 70

def requeue
  @group.requeue(self.job_id)
end

#runObject



81
82
83
# File 'lib/right_chimp/exec/Executor.rb', line 81

def run
  raise "run method must be overridden"
end

#targetObject



92
93
94
# File 'lib/right_chimp/exec/Executor.rb', line 92

def target
  return "UNKNOWN"
end