diff options
author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-07-06 14:29:37 +0100 |
---|---|---|
committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-07-06 14:29:37 +0100 |
commit | 5057478f59d7e8e1a65d902799aaab69d557aa93 (patch) | |
tree | 0fc7be2f2054db64ae8e5d421a9a9bd3c0c13cc7 | |
parent | fdae93a3c133ef71c9e098b5b0f9bfb7589e5970 (diff) | |
download | rabbitmq-server-5057478f59d7e8e1a65d902799aaab69d557aa93.tar.gz |
changed cluster -f to force_cluster
-rw-r--r-- | docs/rabbitmqctl.1.xml | 23 | ||||
-rw-r--r-- | src/rabbit_control.erl | 15 | ||||
-rw-r--r-- | src/rabbit_mnesia.erl | 11 |
3 files changed, 35 insertions, 14 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml index 7b023bb0..06648838 100644 --- a/docs/rabbitmqctl.1.xml +++ b/docs/rabbitmqctl.1.xml @@ -271,13 +271,26 @@ <variablelist> <varlistentry> - <term><cmdsynopsis><command>cluster</command><arg choice="opt">-f</arg><arg choice="req" role="usage-option-list"><replaceable>clusternode</replaceable> ...</arg></cmdsynopsis></term> + <term><cmdsynopsis><command>force_cluster</command><arg choice="req" role="usage-option-list"><replaceable>clusternode</replaceable> ...</arg></cmdsynopsis></term> <listitem> <variablelist> <varlistentry> - <term>-f</term> - <listitem><para>Allow clustering with offline nodes.</para></listitem> + <term>clusternode</term> + <listitem><para>Subset of the nodes of the cluster to which this node should be connected.</para></listitem> </varlistentry> + </variablelist> + <para> + Instruct the node to become member of a cluster with the + specified nodes. This will succeed even if the specified nodes + are offline. For a more detailed description, see + <command>cluster</command>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><cmdsynopsis><command>cluster</command><arg choice="req" role="usage-option-list"><replaceable>clusternode</replaceable> ...</arg></cmdsynopsis></term> + <listitem> + <variablelist> <varlistentry> <term>clusternode</term> <listitem><para>Subset of the nodes of the cluster to which this node should be connected.</para></listitem> @@ -285,8 +298,8 @@ </variablelist> <para> Instruct the node to become member of a cluster with the - specified nodes. Unless -f is used, all of the nodes - must be online. + specified nodes. To cluster with currently offline nodes, + use <command>force_cluster</command>. </para> <para> Cluster nodes can be of two types: disk or ram. Disk nodes diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index a498a68a..76ac8ce2 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -154,16 +154,17 @@ action(force_reset, Node, [], Inform) -> Inform("Forcefully resetting node ~p", [Node]), call(Node, {rabbit_mnesia, force_reset, []}); -action(cluster, Node, Args, Inform) -> - {Force, ClusterNodeSs} = - case Args of - ["-f" | Rest] -> {true, Rest}; - _ -> {false, Args} - end, +action(cluster, Node, ClusterNodeSs, Inform) -> ClusterNodes = lists:map(fun list_to_atom/1, ClusterNodeSs), Inform("Clustering node ~p with ~p", [Node, ClusterNodes]), - rpc_call(Node, rabbit_mnesia, cluster, [ClusterNodes, Force]); + rpc_call(Node, rabbit_mnesia, cluster, [ClusterNodes]); + +action(force_cluster, Node, ClusterNodeSs, Inform) -> + ClusterNodes = lists:map(fun list_to_atom/1, ClusterNodeSs), + Inform("Forcefully clustering node ~p with ~p (ignoring offline nodes)", + [Node, ClusterNodes]), + rpc_call(Node, rabbit_mnesia, force_cluster, [ClusterNodes]); action(status, Node, [], Inform) -> Inform("Status of node ~p", [Node]), diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 53028c2b..83390c41 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -32,8 +32,8 @@ -module(rabbit_mnesia). -export([ensure_mnesia_dir/0, dir/0, status/0, init/0, is_db_empty/0, - cluster/2, reset/0, force_reset/0, is_clustered/0, - empty_ram_only_tables/0]). + cluster/1, force_cluster/1, reset/0, force_reset/0, + is_clustered/0, empty_ram_only_tables/0]). -export([table_names/0]). @@ -53,6 +53,8 @@ -spec(ensure_mnesia_dir/0 :: () -> 'ok'). -spec(init/0 :: () -> 'ok'). -spec(is_db_empty/0 :: () -> boolean()). +-spec(cluster/1 :: ([erlang_node()]) -> 'ok'). +-spec(force_cluster/1 :: ([erlang_node()]) -> 'ok'). -spec(cluster/2 :: ([erlang_node()], boolean()) -> 'ok'). -spec(reset/0 :: () -> 'ok'). -spec(force_reset/0 :: () -> 'ok'). @@ -92,6 +94,11 @@ is_db_empty() -> lists:all(fun (Tab) -> mnesia:dirty_first(Tab) == '$end_of_table' end, table_names()). +cluster(ClusterNodes) -> + cluster(ClusterNodes, false). +force_cluster(ClusterNodes) -> + cluster(ClusterNodes, true). + %% Alter which disk nodes this node is clustered with. This can be a %% subset of all the disk nodes in the cluster but can (and should) %% include the node itself if it is to be a disk rather than a ram |