Permalink
Browse files

Implemented Server::InnerOutboundRouting for handling VM notification…

…s and outgoing messages
  • Loading branch information...
1 parent 2978c21 commit 91652f5901093f80c133508bd1fa6933bee1acfe @krakatoa krakatoa committed Feb 20, 2013
Showing with 32 additions and 22 deletions.
  1. +1 −0 lib/cucub-server.rb
  2. +1 −0 lib/dispatcher.rb
  3. +0 −22 lib/server/channel.rb
  4. +30 −0 lib/server/inner_outbound_routing.rb
View
@@ -4,6 +4,7 @@
require_relative './server/channel'
require_relative './server/outer_inbound_routing'
+require_relative './server/inner_outbound_routing'
require_relative './stats_collector'
require_relative './router'
View
@@ -80,6 +80,7 @@ def start(block=nil)
def init_inner_channels
@inner_inbound = Cucub::Server::Channel.inner_inbound
@inner_outbound = Cucub::Server::Channel.inner_outbound
+ Cucub::Server::InnerOutboundRouting.handle(@inner_outbound)
end
def stop
View
@@ -48,28 +48,6 @@ def inner_outbound_start
@socket = PanZMQ::Pull.new
@socket.bind "ipc:///tmp/cucub-inner-outbound.sock"
@socket.register
- @socket.on_receive {|msg|
- message = Cucub::Message.parse(msg)
- puts "Received @inner_outbound@server: #{message.inspect}"
- case message.header.to.layer
- when :server
- message.unlock(:inner_outbound)
- case message.body.action
- when "register"
- Cucub::Server.instance.register_vm(message.body.additionals)
- when "ready"
- puts "READY: #{message.inspect}"
-
- message.body.additionals.each do |done_uuid|
- Cucub::Server.instance.stats_collector.mark_done(message.header.from.object_uuid, Cucub::Server.instance.stats_collector.class_for_msg(done_uuid), done_uuid)
- end
-
- puts "STATS: #{Cucub::Server.instance.stats_collector.vm_stats}"
- end
- end
-
- # Cucub::Server.instance.register_vm()
- }
@socket
end
@@ -0,0 +1,30 @@
+module Cucub
+ class Server
+ class InnerOutboundRouting
+ def self.handle(socket)
+ socket.on_receive do |msg|
+ message = Cucub::Message.parse(msg)
+ puts "Received @inner_outbound@server: #{message.inspect}"
+ case message.header.to.layer
+ when :server
+ message.unlock(:inner_outbound)
+ case message.body.action
+ when "register"
+ Cucub::Server.instance.register_vm(message.body.additionals)
+ when "ready"
+ puts "READY: #{message.inspect}"
+
+ message.body.additionals.each do |done_uuid|
+ Cucub::Server.instance.stats_collector.mark_done(message.header.from.object_uuid, Cucub::Server.instance.stats_collector.class_for_msg(done_uuid), done_uuid)
+ end
+
+ puts "STATS: #{Cucub::Server.instance.stats_collector.vm_stats}"
+ end
+ end
+
+ # Cucub::Server.instance.register_vm()
+ end
+ end
+ end
+ end
+end

0 comments on commit 91652f5

Please sign in to comment.