chore: reorganize shards position

This commit is contained in:
zhongwencool 2021-09-30 15:05:23 +08:00 committed by Rory Z
parent 45ca168216
commit 44a6f04a45
9 changed files with 44 additions and 31 deletions

View File

@ -17,25 +17,8 @@
-ifndef(EMQ_X_HRL).
-define(EMQ_X_HRL, true).
%%--------------------------------------------------------------------
%% Common
%%--------------------------------------------------------------------
-include_lib("emqx_machine/include/emqx_machine.hrl").
-define(Otherwise, true).
-define(COMMON_SHARD, emqx_common_shard).
-define(SHARED_SUB_SHARD, emqx_shared_sub_shard).
-define(MOD_DELAYED_SHARD, emqx_delayed_shard).
-define(CM_SHARD, emqx_cm_shard).
-define(EMQX_SHARDS, [ ?ROUTE_SHARD
, ?COMMON_SHARD
, ?SHARED_SUB_SHARD
, ?RULE_ENGINE_SHARD
, ?MOD_DELAYED_SHARD
]).
%%--------------------------------------------------------------------
%% Banner
%%--------------------------------------------------------------------
@ -90,11 +73,6 @@
%% Route
%%--------------------------------------------------------------------
-define(ROUTE_SHARD, route_shard).
-define(RULE_ENGINE_SHARD, emqx_rule_engine_shard).
-record(route, {
topic :: binary(),
dest :: node() | {binary(), node()}
@ -140,8 +118,6 @@
until :: integer()
}).
-endif.
%%--------------------------------------------------------------------
%% Authentication
%%--------------------------------------------------------------------
@ -157,3 +133,5 @@
{ name :: atom()
, authenticators :: [#authenticator{}]
}).
-endif.

View File

@ -29,6 +29,7 @@
]).
-include("emqx.hrl").
-include_lib("emqx_machine/include/emqx_machine.hrl").
-include("emqx_release.hrl").
-include("logger.hrl").
@ -84,7 +85,7 @@ maybe_load_config() ->
%% we already start ekka in emqx_machine
start_ekka() ->
ekka:start(),
ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity).
ok = ekka_rlog:wait_for_shards(?BOOT_SHARDS, infinity).
maybe_start_listeners() ->
case emqx_boot:is_enabled(listeners) of

View File

@ -0,0 +1,30 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2017-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%--------------------------------------------------------------------
-ifndef(EMQ_MACHINE_X_HRL).
-define(EMQ_MACHINE_X_HRL, true).
-define(COMMON_SHARD, emqx_common_shard).
-define(SHARED_SUB_SHARD, emqx_shared_sub_shard).
-define(CM_SHARD, emqx_cm_shard).
-define(ROUTE_SHARD, route_shard).
-define(BOOT_SHARDS, [ ?ROUTE_SHARD
, ?COMMON_SHARD
, ?SHARED_SUB_SHARD
]).
-endif.

View File

@ -32,7 +32,7 @@
-boot_mnesia({mnesia, [boot]}).
-copy_mnesia({mnesia, [copy]}).
-include_lib("emqx/include/emqx.hrl").
-include("emqx_machine.hrl").
-include_lib("emqx/include/logger.hrl").
-include("emqx_cluster_rpc.hrl").

View File

@ -17,9 +17,9 @@
-behaviour(gen_server).
-include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl").
-include("emqx_cluster_rpc.hrl").
-include("emqx_machine.hrl").
-export([start_link/0, start_link/2]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,

View File

@ -23,6 +23,7 @@
-include_lib("emqx/include/logger.hrl").
-include_lib("emqx/include/emqx.hrl").
-include("emqx_machine.hrl").
%% @doc EMQ X boot entrypoint.
start() ->
@ -38,7 +39,7 @@ start() ->
ok = load_config_files(),
%% Load application first for ekka_mnesia scanner
ekka:start(),
ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity),
ok = ekka_rlog:wait_for_shards(?BOOT_SHARDS, infinity),
ok.
graceful_shutdown() ->

View File

@ -94,3 +94,5 @@
%% Tables
-define(RULE_TAB, emqx_rule).
-define(RULE_ENGINE_SHARD, emqx_rule_engine_shard).

View File

@ -16,6 +16,8 @@
-module(emqx_rule_engine_app).
-include("rule_engine.hrl").
-behaviour(application).
-export([start/2]).
@ -23,6 +25,7 @@
-export([stop/1]).
start(_Type, _Args) ->
ok = ekka_rlog:wait_for_shards([?RULE_ENGINE_SHARD], infinity),
ok = emqx_rule_events:reload(),
emqx_rule_engine_sup:start_link().

View File

@ -19,7 +19,6 @@
-behaviour(gen_server).
-include("rule_engine.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl").
-include_lib("stdlib/include/qlc.hrl").
@ -81,7 +80,6 @@ mnesia(boot) ->
{storage_properties, StoreProps}]);
mnesia(copy) ->
%% Copy rule table
ok = ekka_mnesia:copy_table(?RULE_TAB, disc_copies).
dump() ->