perf(mgmt): optimize clientid lookup when registry is enabled
This commit is contained in:
parent
7b7f44b9ac
commit
c49900af50
|
@ -691,10 +691,21 @@ delete_banned(Who) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
lookup_running_client(ClientId, FormatFun) ->
|
lookup_running_client(ClientId, FormatFun) ->
|
||||||
lists:append([
|
case emqx_cm_registry:is_enabled() of
|
||||||
lookup_client(Node, {clientid, ClientId}, FormatFun)
|
false ->
|
||||||
|| Node <- emqx:running_nodes()
|
lists:append([
|
||||||
]).
|
lookup_client(Node, {clientid, ClientId}, FormatFun)
|
||||||
|
|| Node <- emqx:running_nodes()
|
||||||
|
]);
|
||||||
|
true ->
|
||||||
|
case emqx_cm_registry:lookup_channels(ClientId) of
|
||||||
|
[ChanPid | _] ->
|
||||||
|
Node = node(ChanPid),
|
||||||
|
lookup_client(Node, {clientid, ClientId}, FormatFun);
|
||||||
|
[] ->
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal Functions.
|
%% Internal Functions.
|
||||||
|
|
|
@ -180,9 +180,14 @@ t_lookup_client(_Config) ->
|
||||||
),
|
),
|
||||||
?assertEqual([], emqx_mgmt:lookup_client({clientid, <<"notfound">>}, ?FORMATFUN)),
|
?assertEqual([], emqx_mgmt:lookup_client({clientid, <<"notfound">>}, ?FORMATFUN)),
|
||||||
meck:expect(emqx, running_nodes, 0, [node(), 'fake@nonode']),
|
meck:expect(emqx, running_nodes, 0, [node(), 'fake@nonode']),
|
||||||
?assertMatch(
|
try
|
||||||
[_ | {error, nodedown}], emqx_mgmt:lookup_client({clientid, <<"client1">>}, ?FORMATFUN)
|
emqx:update_config([broker, enable_session_registry], false),
|
||||||
).
|
?assertMatch(
|
||||||
|
[_ | {error, nodedown}], emqx_mgmt:lookup_client({clientid, <<"client1">>}, ?FORMATFUN)
|
||||||
|
)
|
||||||
|
after
|
||||||
|
emqx:update_config([broker, enable_session_registry], true)
|
||||||
|
end.
|
||||||
|
|
||||||
t_kickout_client(init, Config) ->
|
t_kickout_client(init, Config) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
|
|
Loading…
Reference in New Issue