Class: Isono::NodeModules::JobCollector::Dispatch

Inherits:
Object
  • Object
show all
Defined in:
lib/isono/node_modules/job_collector.rb

Instance Method Summary collapse

Instance Method Details

#call(req, res) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/isono/node_modules/job_collector.rb', line 34

def call(req, res)
  @req, @res = req, res
  raise Rack::UnknownMethodError if @req.command == 'call'
  m = self.method(@req.command)
  raise Rack::UnknownMethodError if m.nil?

  ret = m.call
  @res.response(nil)  if @res.responded?
end

#registObject

Register new job



20
21
22
23
24
25
# File 'lib/isono/node_modules/job_collector.rb', line 20

def regist
  params = @req.args[0]
  params[:node_id]=@req.sender
  job =Models::JobState.new
  job.set_fields(params, [:job_id, :parent_job_id, :node_id, :state]).save
end

#updateObject



27
28
29
30
31
32
# File 'lib/isono/node_modules/job_collector.rb', line 27

def update
  params = @req.args[0]
  job = Models::JobState.find(:job_id=>params[:job_id])
  raise "Unknown or JOB ID: #{params[:job_id]}" if job.nil?
  job.set_fields(params, [:state, :started_at, :finished_at]).save
end