Navigation Menu

Skip to content

Commit

Permalink
Use more meaningful name
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 21, 2015
1 parent be1e3b5 commit b390114
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/droonga/command/remote.rb
Expand Up @@ -119,7 +119,7 @@ class ChangeRole < Base
def process
log("old role: #{@serf.role}")
@serf.role = @params["role"]
NodeRole.my_role = @serf.role
NodeRole.mine = @serf.role
log("new role: #{@serf.role}")
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/droonga/dispatcher.rb
Expand Up @@ -233,15 +233,15 @@ def dispatch_steps(steps)
target_nodes = @cluster.writable_nodes
if target_nodes.empty?
logger.error("there is no node to dispath a write step!",
:my_role => NodeRole.my_role,
:my_role => NodeRole.mine,
:all_nodes => @cluster.engine_nodes.collect(&:to_json),
:step => step)
end
else
target_nodes = @cluster.readable_nodes
if target_nodes.empty?
logger.error("there is no node to dispath a read step!",
:my_role => NodeRole.my_role,
:my_role => NodeRole.mine,
:all_nodes => @cluster.engine_nodes.collect(&:to_json),
:step => step)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/droonga/engine_node.rb
Expand Up @@ -85,7 +85,7 @@ def forward(message, destination)

def forwardable?
return false unless live?
role == NodeRole.my_role
role == NodeRole.mine
end

def readable?
Expand All @@ -94,7 +94,7 @@ def readable?
end

def writable?
case NodeRole.my_role
case NodeRole.mine
when NodeRole::SERVICE_PROVIDER
true
when NodeRole::ABSORB_SOURCE
Expand Down Expand Up @@ -200,7 +200,7 @@ def complete_service_provider?

def really_writable?
return false unless writable?
case NodeRole.my_role
case NodeRole.mine
when NodeRole::SERVICE_PROVIDER
service_provider?
when NodeRole::ABSORB_SOURCE
Expand Down
12 changes: 6 additions & 6 deletions lib/droonga/node_role.rb
Expand Up @@ -30,17 +30,17 @@ def valid?(role)
ROLES.include?(role)
end

def my_role
if @my_role
@my_role.to_s
def mine
if @mine
@mine.to_s
else
SERVICE_PROVIDER
end
end

def my_role=(new_role)
@my_role = new(new_role)
@my_role.to_s
def mine=(new_role)
@mine = new(new_role)
@mine.to_s
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/droonga/serf.rb
Expand Up @@ -75,7 +75,7 @@ def initialize_tags
set_tag("cluster_id", cluster_id)
current_role = role
set_tag("role", current_role)
NodeRole.my_role = current_role
NodeRole.mine = current_role
end

def leave
Expand Down

0 comments on commit b390114

Please sign in to comment.