summaryrefslogtreecommitdiff
path: root/src/mem3.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-06-10 09:22:01 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-08-12 00:59:22 -0400
commitcd25fee1bfd046afe92c83df243ac69dfca2bffe (patch)
tree28604217cffaac6e2f3ac4cfb0ab06943ece0870 /src/mem3.erl
parent05332b0749393e7e644e5f7f76500b57bb70f7e3 (diff)
more detailed report for mem3:states()
Diffstat (limited to 'src/mem3.erl')
-rw-r--r--src/mem3.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mem3.erl b/src/mem3.erl
index 29140471..55a8a541 100644
--- a/src/mem3.erl
+++ b/src/mem3.erl
@@ -77,14 +77,20 @@ state() ->
gen_server:call(?SERVER, state).
--spec states() -> {ok, [mem_state()]}.
+%% @doc Detailed report of cluster-wide membership state. Queries the state
+%% on all member nodes and builds a dictionary with unique states as the
+%% key and the nodes holding that state as the value. Also reports member
+%% nodes which fail to respond and nodes which are connected but are not
+%% cluster members. Useful for debugging.
+-spec states() -> [{mem_state() | bad_nodes | non_member_nodes, [node()]}].
states() ->
{ok, Nodes} = mem3:nodes(),
- case rpc:multicall(Nodes, ?MODULE, state, []) of
- {States, []} -> {ok, lists:map(fun({ok,S}) -> S end, States)};
- {Good, Bad} -> {error, {[{good,Good},{bad,Bad}]}}
- end.
-
+ AllNodes = [node()|erlang:nodes()],
+ {Replies, BadNodes} = gen_server:multi_call(Nodes, ?SERVER, state),
+ Dict = lists:foldl(fun({Node, {ok,State}}, D) ->
+ orddict:append(State, Node, D)
+ end, orddict:new(), Replies),
+ [{non_member_nodes, AllNodes -- Nodes}, {bad_nodes, BadNodes} | Dict].
-spec start_gossip() -> ok.
start_gossip() ->