diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-01-29 10:53:19 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-01-29 10:53:19 +0000 |
commit | 55d011e343b94a74d782d6b1075b271c3889de93 (patch) | |
tree | 60f28f19e6ffaf83351449cb780e37544923fc0a | |
parent | 90ddce2d53a84bcddfad4c4ab7242e943ee518d2 (diff) | |
parent | 402ae3dd3aa0a66c898d6be34094606ef3966d48 (diff) | |
download | rabbitmq-server-55d011e343b94a74d782d6b1075b271c3889de93.tar.gz |
stable to default
-rw-r--r-- | src/rabbit_mnesia.erl | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index f22ee842..010fd9ac 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -275,16 +275,16 @@ forget_cluster_node(Node, RemoveWhenOffline) -> true -> ok; false -> e(not_a_cluster_node) end, - case {RemoveWhenOffline, mnesia:system_info(is_running)} of - {true, no} -> remove_node_offline_node(Node); - {true, yes} -> e(online_node_offline_flag); - {false, no} -> e(offline_node_no_offline_flag); - {false, yes} -> rabbit_misc:local_info_msg( - "Removing node ~p from cluster~n", [Node]), - case remove_node_if_mnesia_running(Node) of - ok -> ok; - {error, _} = Err -> throw(Err) - end + case {RemoveWhenOffline, is_running()} of + {true, false} -> remove_node_offline_node(Node); + {true, true} -> e(online_node_offline_flag); + {false, false} -> e(offline_node_no_offline_flag); + {false, true} -> rabbit_misc:local_info_msg( + "Removing node ~p from cluster~n", [Node]), + case remove_node_if_mnesia_running(Node) of + ok -> ok; + {error, _} = Err -> throw(Err) + end end. remove_node_offline_node(Node) -> @@ -331,11 +331,11 @@ status() -> end, [{nodes, (IfNonEmpty(disc, cluster_nodes(disc)) ++ IfNonEmpty(ram, cluster_nodes(ram)))}] ++ - case mnesia:system_info(is_running) of - yes -> RunningNodes = cluster_nodes(running), - [{running_nodes, RunningNodes}, - {partitions, mnesia_partitions(RunningNodes)}]; - no -> [] + case is_running() of + true -> RunningNodes = cluster_nodes(running), + [{running_nodes, RunningNodes}, + {partitions, mnesia_partitions(RunningNodes)}]; + false -> [] end. mnesia_partitions(Nodes) -> @@ -343,6 +343,8 @@ mnesia_partitions(Nodes) -> Nodes, rabbit_node_monitor, partitions, []), [Reply || Reply = {_, R} <- Replies, R =/= []]. +is_running() -> mnesia:system_info(is_running) =:= yes. + is_clustered() -> AllNodes = cluster_nodes(all), AllNodes =/= [] andalso AllNodes =/= [node()]. @@ -352,10 +354,10 @@ cluster_nodes(WhichNodes) -> cluster_status(WhichNodes). %% the data from mnesia. Obviously it'll work only when mnesia is %% running. cluster_status_from_mnesia() -> - case mnesia:system_info(is_running) of - no -> + case is_running() of + false -> {error, mnesia_not_running}; - yes -> + true -> %% If the tables are not present, it means that %% `init_db/3' hasn't been run yet. In other words, either %% we are a virgin node or a restarted RAM node. In both @@ -666,8 +668,10 @@ move_db() -> ok. remove_node_if_mnesia_running(Node) -> - case mnesia:system_info(is_running) of - yes -> + case is_running() of + false -> + {error, mnesia_not_running}; + true -> %% Deleting the the schema copy of the node will result in %% the node being removed from the cluster, with that %% change being propagated to all nodes @@ -677,9 +681,7 @@ remove_node_if_mnesia_running(Node) -> ok; {aborted, Reason} -> {error, {failed_to_remove_node, Node, Reason}} - end; - no -> - {error, mnesia_not_running} + end end. leave_cluster() -> |