diff options
author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-09-03 17:13:04 +0100 |
---|---|---|
committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-09-03 17:13:04 +0100 |
commit | e41f42aee9a6b95ca95c6dc63d2310c336f7d51f (patch) | |
tree | bbbb38f47de721f7a0304d1ca1d1acff1ee855d9 | |
parent | e7051a1a9eb68e6180e340c4f0c5740ba83d2162 (diff) | |
download | rabbitmq-server-e41f42aee9a6b95ca95c6dc63d2310c336f7d51f.tar.gz |
reset and join when changing node type
-rw-r--r-- | src/rabbit_mnesia.erl | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index dc27e58b..ea2cbc1e 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -266,9 +266,8 @@ change_cluster_node_type(Type) -> "Non-clustered nodes can only be disc nodes"}}); true -> ok end, - DiscoveryNodes = all_clustered_nodes(), - {AllNodes, DiscNodes, _} = - case discover_cluster(DiscoveryNodes) of + {_, _, RunningNodes} = + case discover_cluster(all_clustered_nodes()) of {ok, Status} -> Status; {error, _Reason} -> @@ -279,19 +278,21 @@ change_cluster_node_type(Type) -> "you can use the \"update_cluster_nodes\" command to " "point to the new cluster nodes"}}) end, - WantDiscNode = case Type of - ram -> false; - disc -> true - end, - case not WantDiscNode andalso [node()] =:= DiscNodes of - true -> throw({error, - {standalone_ram_node, - "You can't change the node type to ram if the node is " - "the only disc node in its cluster. Please add more " - "disc nodes to the cluster first."}}); - false -> ok - end, - ok = init_db_with_mnesia(AllNodes, WantDiscNode, false). + Node = case RunningNodes of + [] -> + throw({error, + {no_online_cluster_nodes, + "Could not find any online cluster nodes. If the " + "cluster has changed, you can use the 'recluster' " + "command."}}); + [Node0|_] -> + Node0 + end, + ok = reset(false), + ok = join_cluster(Node, case Type of + ram -> false; + disc -> true + end). update_cluster_nodes(DiscoveryNode) -> ensure_mnesia_not_running(), |