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
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

#arrayObject

Returns the value of attribute array.



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

def array
  @array
end

#concurrencyObject

Returns the value of attribute concurrency.



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

def concurrency
  @concurrency
end

#delayObject

Returns the value of attribute delay.



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

def delay
  @delay
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

#job_notesObject

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_uuidObject

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

#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



82
83
84
# File 'lib/right_chimp/exec/executor.rb', line 82

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

#get_total_exec_timeObject

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

#infoObject

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

#queueObject

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

#requeueObject

Convenience method to requeue



75
76
77
# File 'lib/right_chimp/exec/executor.rb', line 75

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

#runObject



86
87
88
# File 'lib/right_chimp/exec/executor.rb', line 86

def run
  raise "run method must be overridden"
end

#targetObject



97
98
99
# File 'lib/right_chimp/exec/executor.rb', line 97

def target
  return "UNKNOWN"
end