25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-05 14:51:05 +02:00

increase rehash timeout to 30 seconds; increase hashing points

This commit is contained in:
Evgeniy Khramtsov 2010-10-13 15:44:18 +10:00
parent bde3bce1e7
commit 4a6fc46713
2 changed files with 26 additions and 6 deletions

View File

@ -21,8 +21,8 @@
-define(HASHTBL, nodes_hash).
-define(HASHTBL_NEW, nodes_hash_new).
-define(POINTS, 16).
-define(REHASH_TIMEOUT, 5000).
-define(POINTS, 64).
-define(REHASH_TIMEOUT, 30000).
-record(state, {}).

View File

@ -555,7 +555,15 @@ handle_msg(Msg, Parent, Name, StateName, StateData, Mod, _Time,
loop(Parent, Name, NStateName, NStateData, Mod, Time1, [],
Limits, Queue, QueueLen);
{migrate, NStateData, {Node, M, F, A}, Time1} ->
Reason = case catch rpc:call(Node, M, F, A, 5000) of
RPCTimeout = if Time1 == 0 ->
%% We don't care about a delay,
%% so we set it one minute
60000;
true ->
Time1
end,
Now = now(),
Reason = case catch rpc:call(Node, M, F, A, RPCTimeout) of
{badrpc, _} = Err ->
{migration_error, Err};
{'EXIT', _} = Err ->
@ -565,7 +573,9 @@ handle_msg(Msg, Parent, Name, StateName, StateData, Mod, _Time,
{ok, Clone} ->
process_flag(trap_exit, true),
MRef = erlang:monitor(process, Clone),
TRef = erlang:start_timer(Time1, self(), timeout),
NowDiff = timer:now_diff(now(), Now),
TimeLeft = lists:max([Time1 - NowDiff, 0]) div 1000,
TRef = erlang:start_timer(TimeLeft, self(), timeout),
relay_messages(MRef, TRef, Clone, Queue);
Reply ->
{migration_error, {bad_reply, Reply}}
@ -608,7 +618,15 @@ handle_msg(Msg, Parent, Name, StateName, StateData,
loop(Parent, Name, NStateName, NStateData,
Mod, Time1, Debug1, Limits, Queue, QueueLen);
{migrate, NStateData, {Node, M, F, A}, Time1} ->
Reason = case catch rpc:call(Node, M, F, A, Time1) of
RPCTimeout = if Time1 == 0 ->
%% We don't care about a delay,
%% so we set it one minute
60000;
true ->
Time1
end,
Now = now(),
Reason = case catch rpc:call(Node, M, F, A, RPCTimeout) of
{badrpc, R} ->
{migration_error, R};
{'EXIT', R} ->
@ -618,7 +636,9 @@ handle_msg(Msg, Parent, Name, StateName, StateData,
{ok, Clone} ->
process_flag(trap_exit, true),
MRef = erlang:monitor(process, Clone),
TRef = erlang:start_timer(Time1, self(), timeout),
NowDiff = timer:now_diff(now(), Now),
TimeLeft = lists:max([Time1 - NowDiff, 0]) div 1000,
TRef = erlang:start_timer(TimeLeft, self(), timeout),
relay_messages(MRef, TRef, Clone, Queue);
Reply ->
{migration_error, {bad_reply, Reply}}