Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed May 8, 2014
1 parent ebf75b8 commit b4ad2a8
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions src/leo_manager_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1351,26 +1351,32 @@ recover_node_2(false,_,_) ->
compact(Mode, Node) when is_list(Node) ->
compact(Mode, list_to_atom(Node));
compact(Mode, Node) ->
ModeAtom = case Mode of
?COMPACT_SUSPEND -> suspend;
?COMPACT_RESUME -> resume;
?COMPACT_STATUS -> status;
_ -> {error, ?ERROR_INVALID_ARGS}
end,

case ModeAtom of
{error, Cause} ->
{error, Cause};
case leo_redundant_manager_api:get_member_by_node(Node) of
{ok, #member{state = ?STATE_RUNNING}} ->
ModeAtom = case Mode of
?COMPACT_SUSPEND -> suspend;
?COMPACT_RESUME -> resume;
?COMPACT_STATUS -> status;
_ -> {error, ?ERROR_INVALID_ARGS}
end,
case ModeAtom of
{error, Cause} ->
{error, Cause};
_ ->
case rpc:call(Node, ?API_STORAGE, compact, [ModeAtom], ?DEF_TIMEOUT) of
ok ->
ok;
{ok, Status} ->
{ok, Status};
{_, 'not_running'} ->
{error, ?ERROR_TARGET_NODE_NOT_RUNNING};
{_, Cause} ->
?warn("compact/2", "cause:~p", [Cause]),
{error, ?ERROR_FAILED_COMPACTION}
end
end;
_ ->
case rpc:call(Node, ?API_STORAGE, compact, [ModeAtom], ?DEF_TIMEOUT) of
ok ->
ok;
{ok, Status} ->
{ok, Status};
{_, Cause} ->
?warn("compact/2", "cause:~p", [Cause]),
{error, ?ERROR_FAILED_COMPACTION}
end
{error, ?ERROR_TARGET_NODE_NOT_RUNNING}
end.


Expand All @@ -1383,13 +1389,20 @@ compact(?COMPACT_START, Node, NumOfTargets, MaxProc) when is_list(Node) ->
compact(?COMPACT_START, Node, NumOfTargets, MaxProc) ->
case leo_misc:node_existence(Node) of
true ->
case rpc:call(Node, ?API_STORAGE, compact,
[start, NumOfTargets, MaxProc], ?DEF_TIMEOUT) of
ok ->
ok;
{_, Cause} ->
?warn("compact/4", "cause:~p", [Cause]),
{error, ?ERROR_FAILED_COMPACTION}
case leo_redundant_manager_api:get_member_by_node(Node) of
{ok, #member{state = ?STATE_RUNNING}} ->
case rpc:call(Node, ?API_STORAGE, compact,
[start, NumOfTargets, MaxProc], ?DEF_TIMEOUT) of
ok ->
ok;
{_, 'not_running'} ->
{error, ?ERROR_TARGET_NODE_NOT_RUNNING};
{_, Cause} ->
?warn("compact/4", "cause:~p", [Cause]),
{error, ?ERROR_FAILED_COMPACTION}
end;
_ ->
{error, ?ERROR_TARGET_NODE_NOT_RUNNING}
end;
false ->
{error, ?ERR_TYPE_NODE_DOWN}
Expand Down

0 comments on commit b4ad2a8

Please sign in to comment.