Navigation Menu

Skip to content

Commit

Permalink
Output tags to the list of live nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jun 26, 2014
1 parent 38485c1 commit 62841ce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/droonga/command/serf_event_handler.rb
Expand Up @@ -54,15 +54,27 @@ def parse_event
end
end

def parse_tags(tags)
parsed = {}
return parsed unless tags

tags.split(",").each do |tag|
key, value = tag.split("=")
parsed[key] = value
end
parsed
end

def live_nodes
nodes = {}
members = `#{@serf} members -rpc-addr #{@serf_rpc_address}`
members.each_line do |member|
name, address, status, = member.strip.split(/\s+/)
name, address, status, tags, = member.strip.split(/\s+/)
next unless status == "alive"

nodes[name] = {
"serfAddress" => address,
"tags" => parse_tags(tags),
}
end
nodes
Expand Down

0 comments on commit 62841ce

Please sign in to comment.