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 | 2a788ef664e63abafd2cab640ba9c3efa7942bde (patch) | |
| tree | bbbb38f47de721f7a0304d1ca1d1acff1ee855d9 | |
| parent | ee0f509c662ddb5978d96ad9186a1af2807b8313 (diff) | |
| download | rabbitmq-server-git-2a788ef664e63abafd2cab640ba9c3efa7942bde.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 dc27e58bdb..ea2cbc1e4c 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(), |
