Class: RemoteJob

Inherits:
OpenShift::Model
  • Object
show all
Defined in:
app/models/remote_job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, action, args) ⇒ RemoteJob

Returns a new instance of RemoteJob.



5
6
7
8
9
# File 'app/models/remote_job.rb', line 5

def initialize(target, action, args)
  self.cartridge = target
  self.action = action
  self.args = args
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'app/models/remote_job.rb', line 3

def action
  @action
end

#argsObject

Returns the value of attribute args.



3
4
5
# File 'app/models/remote_job.rb', line 3

def args
  @args
end

#cartridgeObject

Returns the value of attribute cartridge.



3
4
5
# File 'app/models/remote_job.rb', line 3

def cartridge
  @cartridge
end

Class Method Details

.add_parallel_job(handle, tag, gear, rjob) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/remote_job.rb', line 35

def self.add_parallel_job(handle, tag, gear, rjob)
  parallel_job = { 
                   :tag => tag,
                   :gear => gear.uuid,
                   :job => { :cartridge => rjob.cartridge, :action => rjob.action, :args => rjob.args },
                   :result_stdout => "",
                   :result_stderr => "",
                   :result_exit_code => ""
                 }
  job_list = handle[gear.get_proxy.id] || []
  job_list << parallel_job
  handle[gear.get_proxy.id] = job_list
end

.create_parallel_jobObject



12
13
14
# File 'app/models/remote_job.rb', line 12

def self.create_parallel_job
  return { }
end

.get_parallel_run_results(handle, &block) ⇒ Object



49
50
51
52
53
54
55
# File 'app/models/remote_job.rb', line 49

def self.get_parallel_run_results(handle, &block)
  handle.each { |id, job_list|
    job_list.each { |parallel_job|
      block.call(parallel_job[:tag], parallel_job[:gear], parallel_job[:result_stdout], parallel_job[:result_exit_code])
    }
  }
end

.has_jobs(handle) ⇒ Object



16
17
18
# File 'app/models/remote_job.rb', line 16

def self.has_jobs(handle)
  !handle.empty?
end

.run_parallel_on_gears(gears, handle, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/remote_job.rb', line 20

def self.run_parallel_on_gears(gears, handle, &block)
  gears.each { |gear|
    block.call(handle, gear)
  }
  # now execute
  begin
    OpenShift::ApplicationContainerProxy.execute_parallel_jobs(handle)
  rescue Exception=>e
    Rails.logger.error e.message
    Rails.logger.error e.inspect
    Rails.logger.error e.backtrace.inspect        
    raise e
  end
end