diff options
| author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-04 18:18:55 +0100 |
|---|---|---|
| committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-04 18:18:55 +0100 |
| commit | 86a0d47e60de626a01212e259c811d1a97832307 (patch) | |
| tree | cafae9941e7526a848ae561dfe6642193a68cddb /src | |
| parent | 10a91e93d2733347251c5b3bf6968696f305bd6d (diff) | |
| download | rabbitmq-server-git-86a0d47e60de626a01212e259c811d1a97832307.tar.gz | |
check if the node is the only disc one in `change_node_type/1'
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_mnesia.erl | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 9ef2f30213..18e2edbebe 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -240,12 +240,11 @@ change_node_type(Type) -> "Non-clustered nodes can only be disc nodes"}}); true -> ok end, - DiscoveryNodes = all_clustered_nodes(), - ClusterNodes = + {AllNodes, DiscNodes, _} = case discover_cluster(DiscoveryNodes) of - {ok, {ClusterNodes0, _, _}} -> - ClusterNodes0; + {ok, Status} -> + Status; {error, _Reason} -> throw({error, {cannot_connect_to_cluster, @@ -254,15 +253,19 @@ change_node_type(Type) -> "you can use the \"recluster\" command to point to the " "new cluster nodes"}}) end, - WantDiscNode = case Type of ram -> false; disc -> true end, - - ok = init_db_with_mnesia(ClusterNodes, WantDiscNode, false), - - ok. + case not WantDiscNode andalso is_only_disc_node(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). recluster(DiscoveryNode) -> ensure_mnesia_not_running(), @@ -1032,8 +1035,11 @@ wait_for(Condition) -> error_logger:info_msg("Waiting for ~p...~n", [Condition]), timer:sleep(1000). +is_only_disc_node(Node, DiscNodes) -> + [Node] =:= DiscNodes. + is_only_disc_node(Node) -> - [Node] =:= clustered_disc_nodes(). + is_only_disc_node(Node, clustered_disc_nodes()). start_mnesia(CheckConsistency) -> case CheckConsistency of |
