Navigation Menu

Skip to content

Commit

Permalink
Use dispatcher's fowarder for direct routing
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 1, 2015
1 parent eaf564a commit 839c329
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/droonga/dispatcher.rb
Expand Up @@ -117,7 +117,7 @@ def process_message(message)

def forward(message, destination)
logger.trace("forward start")
if local?(destination)
if local_route?(destination) or direct_route?(destination)
@forwarder.forward(message, destination)
else
@cluster.forward(message, destination)
Expand Down Expand Up @@ -195,7 +195,10 @@ def dispatch(message, destination)
"type" => "dispatcher",
"to" => destination,
}
@cluster.forward(forward_message, forward_destination)
if direct_route?(forward_destination)
@fowrarder.forward(forward_message, forward_destination)
else
@cluster.forward(forward_message, forward_destination)
end
logger.trace("dispatch: done")
end
Expand Down Expand Up @@ -262,10 +265,15 @@ def process_local_message(local_message)
logger.trace("process_local_message: done")
end

def local?(route)
def local_route?(route)
@engine_state.local_route?(route)
end

def direct_route?(route)
receiver = destination["to"]
not @cluster.engine_nodes.key?(receiver)
end

def write_step?(step)
return false unless step["dataset"]

Expand Down

0 comments on commit 839c329

Please sign in to comment.