Navigation Menu

Skip to content

Commit

Permalink
Report error if there is no node to dispatch a message
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 15, 2015
1 parent 5b06f3f commit 0043b62
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/droonga/dispatcher.rb
Expand Up @@ -203,8 +203,18 @@ def dispatch_steps(steps)
if dataset
if write_step?(step)
target_nodes = @cluster.writable_nodes
if target_nodes.empty?
logger.error("there is no node to dispath a write message!",
:my_role => @engine_state.role,
:all_nodes => @cluster.engine_nodes(&:to_json))
end
else
target_nodes = @cluster.forwardable_nodes
if target_nodes.empty?
logger.error("there is no node to dispath a read message!",
:my_role => @engine_state.role,
:all_nodes => @cluster.engine_nodes(&:to_json))
end
end
routes = dataset.compute_routes(step, target_nodes)
step["routes"] = routes
Expand Down
8 changes: 8 additions & 0 deletions lib/droonga/engine_node.rb
Expand Up @@ -91,6 +91,14 @@ def status
end
end

def to_json
{
"name" => name,
"role" => role,
"status" => status
}
end

def on_change
@sender.resume
end
Expand Down
9 changes: 9 additions & 0 deletions lib/droonga/engine_state.rb
Expand Up @@ -21,6 +21,7 @@
require "droonga/event_loop"
require "droonga/forwarder"
require "droonga/replier"
require "droonga/node_metadata"

module Droonga
class EngineState
Expand Down Expand Up @@ -104,11 +105,19 @@ def have_session?
not @sessions.empty?
end

def role
node_metadata.role
end

def on_ready
@on_ready.call if @on_ready
end

private
def node_metadata
@node_metadata ||= NodeMetadata.new
end

def log_tag
"engine_state"
end
Expand Down

0 comments on commit 0043b62

Please sign in to comment.