Send running status for task when it has started to process

Also after this change Astute does not need task in
orchestrator mechanism.

Related-Bug: #1621003

Change-Id: Iefacf88a652c476618df13412816cacbd15eb5c2
This commit is contained in:
Vladimir Sharshov (warpc) 2016-09-08 17:44:43 +03:00
parent c33fe77e77
commit b8dc94c6ca
1 changed files with 5 additions and 16 deletions

View File

@ -95,21 +95,6 @@ module Astute
end
end
def send_message_task_in_orchestrator(data)
data.each do |message|
begin
task_uuid = message['args']['task_uuid']
Astute.logger.debug "Sending message: task #{task_uuid} in orchestrator"
return_results({
'respond_to' => 'task_in_orchestrator',
'args' => {'task_uuid' => task_uuid}})
rescue => ex
Astute.logger.error "Error on sending message 'task in orchestrator': #{ex.message}"\
"trace: #{ex.format_backtrace}"
end
end
end
def perform_main_job(payload, properties)
@main_work_thread = Thread.new do
data = parse_data(payload, properties)
@ -118,7 +103,6 @@ module Astute
@tasks_queue = Astute::Server::TaskQueue.new
@tasks_queue.add_task(data)
send_message_task_in_orchestrator(data)
dispatch(@tasks_queue)
# Clean up tasks queue to prevent wrong service job work flow for
@ -144,6 +128,7 @@ module Astute
def dispatch(data, service_data=nil)
data.each_with_index do |message, i|
begin
send_running_task_status(message)
dispatch_message message, service_data
rescue StopIteration
Astute.logger.debug "Dispatching aborted by #{message['method']}"
@ -191,6 +176,10 @@ module Astute
end
end
def send_running_task_status(message)
return_results(message, {'status' => 'running'})
end
def return_results(message, results={})
if results.is_a?(Hash) && message['respond_to']
reporter = Astute::Server::Reporter.new(