Navigation Menu

Skip to content

Commit

Permalink
cache node names for more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 6, 2015
1 parent 236a1c2 commit 9ea6830
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/droonga/cluster.rb
Expand Up @@ -115,27 +115,21 @@ def absorb_destination_nodes
end

def same_role_nodes
engine_nodes.select do |node|
@same_role_nodes ||= engine_nodes.select do |node|
node.role == node_metadata.role
end.collect do |node|
node.name
end
end.collect(&:name)
end

def forwardable_nodes
engine_nodes.select do |node|
@forwardable_nodes ||= engine_nodes.select do |node|
node.live? and node.role == node_metadata.role
end.collect do |node|
node.name
end
end.collect(&:name)
end

def writable_nodes
engine_nodes.select do |node|
@writable_nodes ||= engine_nodes.select do |node|
node.writable_by?(node_metadata.role)
end.collect do |node|
node.name
end
end.collect(&:name)
end

def on_change
Expand All @@ -149,6 +143,9 @@ def clear_cache
@service_provider_nodes = nil
@absorb_source_nodes = nil
@absorb_destination_nodes = nil
@same_role_nodes = nil
@forwardable_nodes = nil
@writable_nodes = nil
end

def load_state_file
Expand Down

0 comments on commit 9ea6830

Please sign in to comment.