feat(dsrepl): reflect conflicts and inconsistencies in ds status
This commit is contained in:
parent
7e86e3e61c
commit
26c4a4f597
|
@ -171,32 +171,55 @@
|
||||||
|
|
||||||
-spec print_status() -> ok.
|
-spec print_status() -> ok.
|
||||||
print_status() ->
|
print_status() ->
|
||||||
io:format("THIS SITE:~n~s~n", [this_site()]),
|
io:format("THIS SITE:~n"),
|
||||||
|
try this_site() of
|
||||||
|
Site -> io:format("~s~n", [Site])
|
||||||
|
catch
|
||||||
|
error:badarg ->
|
||||||
|
io:format(
|
||||||
|
"(!) UNCLAIMED~n"
|
||||||
|
"(!) Likely this node's name is already known as another site in the cluster.~n"
|
||||||
|
"(!) Please resolve conflicts manually.~n"
|
||||||
|
)
|
||||||
|
end,
|
||||||
io:format("~nSITES:~n", []),
|
io:format("~nSITES:~n", []),
|
||||||
Nodes = [node() | nodes()],
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(#?NODE_TAB{site = Site, node = Node}) ->
|
fun(#?NODE_TAB{site = Site, node = Node}) ->
|
||||||
Status =
|
Status =
|
||||||
case lists:member(Node, Nodes) of
|
case mria:cluster_status(Node) of
|
||||||
true -> up;
|
running -> " up";
|
||||||
false -> down
|
stopped -> "(x) down";
|
||||||
|
false -> "(!) UNIDENTIFIED"
|
||||||
end,
|
end,
|
||||||
io:format("~s ~p ~p~n", [Site, Node, Status])
|
io:format("~s ~p ~s~n", [Site, Node, Status])
|
||||||
end,
|
end,
|
||||||
eval_qlc(mnesia:table(?NODE_TAB))
|
eval_qlc(mnesia:table(?NODE_TAB))
|
||||||
),
|
),
|
||||||
io:format(
|
io:format(
|
||||||
"~nSHARDS:~nId Replicas~n", []
|
"~nSHARDS:~n~s~s~n",
|
||||||
|
[string:pad("Id", 30), "Replicas"]
|
||||||
),
|
),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(#?SHARD_TAB{shard = {DB, Shard}, replica_set = RS}) ->
|
fun(#?SHARD_TAB{shard = {DB, Shard}, replica_set = RS}) ->
|
||||||
ShardStr = string:pad(io_lib:format("~p/~s", [DB, Shard]), 30),
|
ShardStr = io_lib:format("~p/~s", [DB, Shard]),
|
||||||
ReplicasStr = string:pad(io_lib:format("~p", [RS]), 40),
|
ReplicasStr = string:join([format_replica(R) || R <- RS], " "),
|
||||||
io:format("~s ~s~n", [ShardStr, ReplicasStr])
|
io:format(
|
||||||
|
"~s~s~n",
|
||||||
|
[string:pad(ShardStr, 30), ReplicasStr]
|
||||||
|
)
|
||||||
end,
|
end,
|
||||||
eval_qlc(mnesia:table(?SHARD_TAB))
|
eval_qlc(mnesia:table(?SHARD_TAB))
|
||||||
).
|
).
|
||||||
|
|
||||||
|
format_replica(Site) ->
|
||||||
|
Marker =
|
||||||
|
case mria:cluster_status(?MODULE:node(Site)) of
|
||||||
|
running -> " ";
|
||||||
|
stopped -> "(x)";
|
||||||
|
false -> "(!)"
|
||||||
|
end,
|
||||||
|
io_lib:format("~s ~s", [Marker, Site]).
|
||||||
|
|
||||||
-spec this_site() -> site().
|
-spec this_site() -> site().
|
||||||
this_site() ->
|
this_site() ->
|
||||||
persistent_term:get(?emqx_ds_builtin_site).
|
persistent_term:get(?emqx_ds_builtin_site).
|
||||||
|
|
Loading…
Reference in New Issue