Merge "Sending confirmation to Nailgun on task dispatching"

This commit is contained in:
Jenkins 2015-11-03 16:32:22 +00:00 committed by Gerrit Code Review
commit 959b06c5ef
1 changed files with 19 additions and 2 deletions

View File

@ -80,12 +80,27 @@ 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}"
end
end
end
def perform_main_job(metadata, payload)
@main_work_thread = Thread.new do
data = parse_data(payload)
@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
@ -97,7 +112,9 @@ module Astute
def perform_service_job(metadata, payload)
Thread.new do
service_data = {:main_work_thread => @main_work_thread, :tasks_queue => @tasks_queue}
dispatch(parse_data(payload), service_data)
data = parse_data(payload)
send_message_task_in_orchestrator(data)
dispatch(data, service_data)
end
end
@ -149,7 +166,7 @@ module Astute
end
end
def return_results(message, results)
def return_results(message, results={})
if results.is_a?(Hash) && message['respond_to']
reporter = Astute::Server::Reporter.new(@producer, message['respond_to'], message['args']['task_uuid'])
reporter.report results