Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (100 sloc) 3.642 kb
%% @doc Interface for riak_searchng-admin commands.
-module({{appid}}_console).
-export([join/1,
leave/1,
remove/1,
ringready/1]).
join([NodeStr]) ->
try
case riak_core:join(NodeStr) of
ok ->
io:format("Sent join request to ~s~n", [NodeStr]),
ok;
{error, not_reachable} ->
io:format("Node ~s is not reachable!~n", [NodeStr]),
error;
{error, different_ring_sizes} ->
io:format("Failed: ~s has a different ring_creation_size~n",
[NodeStr]),
error;
{error, unable_to_get_join_ring} ->
io:format("Failed: Unable to get ring from ~s~n", [NodeStr]),
error;
{error, not_single_node} ->
io:format("Failed: This node is already a member of a "
"cluster~n"),
error;
{error, _} ->
io:format("Join failed. Try again in a few moments.~n", []),
error
end
catch
Exception:Reason ->
lager:error("Join failed ~p:~p", [Exception, Reason]),
io:format("Join failed, see log for details~n"),
error
end.
leave([]) ->
try
case riak_core:leave() of
ok ->
io:format("Success: ~p will shutdown after handing off "
"its data~n", [node()]),
ok;
{error, already_leaving} ->
io:format("~p is already in the process of leaving the "
"cluster.~n", [node()]),
ok;
{error, not_member} ->
io:format("Failed: ~p is not a member of the cluster.~n",
[node()]),
error;
{error, only_member} ->
io:format("Failed: ~p is the only member.~n", [node()]),
error
end
catch
Exception:Reason ->
lager:error("Leave failed ~p:~p", [Exception, Reason]),
io:format("Leave failed, see log for details~n"),
error
end.
remove([Node]) ->
try
case riak_core:remove(list_to_atom(Node)) of
ok ->
io:format("Success: ~p removed from the cluster~n", [Node]),
ok;
{error, not_member} ->
io:format("Failed: ~p is not a member of the cluster.~n",
[Node]),
error;
{error, only_member} ->
io:format("Failed: ~p is the only member.~n", [Node]),
error
end
catch
Exception:Reason ->
lager:error("Remove failed ~p:~p", [Exception, Reason]),
io:format("Remove failed, see log for details~n"),
error
end.
ringready([]) ->
try
case riak_core_status:ringready() of
{ok, Nodes} ->
io:format("TRUE All nodes agree on the ring ~p\n", [Nodes]);
{error, {different_owners, N1, N2}} ->
io:format("FALSE Node ~p and ~p list different partition owners\n", [N1, N2]),
error;
{error, {nodes_down, Down}} ->
io:format("FALSE ~p down. All nodes need to be up to check.\n", [Down]),
error
end
catch
Exception:Reason ->
lager:error("Ringready failed ~p:~p", [Exception,
Reason]),
io:format("Ringready failed, see log for details~n"),
error
end.
Jump to Line
Something went wrong with that request. Please try again.