Skip to content

Commit

Permalink
Store node's name as a NodeName for serf
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 17, 2015
1 parent c79b86f commit 8885e81
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/droonga/serf.rb
Expand Up @@ -39,7 +39,7 @@ def path

def initialize(name, options={})
@serf = nil
@name = name
@name = NodeName.new(name)
@verbose = options[:verbose] || false
@service_installation = ServiceInstallation.new
@node_metadata = NodeMetadata.new
Expand All @@ -54,8 +54,8 @@ def run_agent(loop)
retry_joins.push("-retry-join", other_host)
end
agent = Agent.new(loop, @serf,
extract_host(@name), agent_port, rpc_port,
"-node", @name,
@name.host, agent_port, rpc_port,
"-node", @name.to_s,
"-event-handler", "droonga-engine-serf-event-handler",
"-tag", "type=engine",
"-tag", "role=#{role}",
Expand Down Expand Up @@ -242,11 +242,11 @@ def additional_options_from_payload(payload)
end

def extract_host(node_name)
node_name.split(":").first
node_name.to_s.split(":").first
end

def rpc_address
"#{extract_host(@name)}:#{rpc_port}"
"#{@name.host}:#{rpc_port}"
end

def rpc_port
Expand All @@ -261,10 +261,10 @@ def detect_other_hosts
loader = Catalog::Loader.new(Path.catalog.to_s)
catalog = loader.load
other_nodes = catalog.all_nodes.reject do |node|
node == @name
node == @name.to_s
end
other_nodes.collect do |node|
extract_host(node)
NodeName.new(node).host
end
end

Expand Down

0 comments on commit 8885e81

Please sign in to comment.