Permalink
Browse files

Report tasks done back to the Server

  • Loading branch information...
1 parent 9b49f54 commit 241b58bc898e710077bac024417a11d82b67a001 @krakatoa krakatoa committed Feb 19, 2013
Showing with 13 additions and 1 deletion.
  1. +3 −0 lib/actor.rb
  2. +9 −1 lib/reporting.rb
  3. +1 −0 lib/vm.rb
View
3 lib/actor.rb
@@ -34,6 +34,9 @@ def set_fiber
def process(msg)
message = read_message(msg)
play message
+
+ # TODO use msg.uuid instead
+ Cucub::VM.instance.reporting.task_done(msg.serialize)
end
def read_message(message)
View
10 lib/reporting.rb
@@ -18,6 +18,7 @@ def task_done(msg)
# send all when no activity is registered
# differentiate classes and uids in the messages
#
+ puts "Task Done: #{msg}"
@messages << msg
if (Time.now - @last_send) > @max_elapsed_time
self.bulk_send
@@ -26,7 +27,14 @@ def task_done(msg)
def bulk_send
puts "ready #{@vm_uid} engine #{@messages.join(",")}"
- Cucub::Channel.vm_inner_outbound.send_string "ready #{@vm_uid} engine #{@messages.join(",")}"
+
+ vm_ref = Cucub::Reference.new(:layer => :vm, :object_uuid => @vm_uid)
+ server_ref = Cucub::Reference.new(:layer => :server)
+ message = Cucub::Message.new("from" => vm_ref, "to" => server_ref, "action" => "ready", "additionals" => @messages)
+
+ Cucub::Channel.vm_inner_outbound.send_string message.serialize
+
+ # Cucub::Channel.vm_inner_outbound.send_string "ready #{@vm_uid} engine #{@messages.join(",")}"
@last_send = Time.now
@messages = []
end
View
1 lib/vm.rb
@@ -26,6 +26,7 @@ def register
def set_reporting
@reporting = Cucub::Reporting.new(@uid)
+ trap("INT") { @reporting.bulk_send }
end
def boot(vm_opts={})

0 comments on commit 241b58b

Please sign in to comment.