From eb84783d4a9be713b2225bc19a4ec1259c1dff46 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Mon, 27 Apr 2015 09:14:04 +0800 Subject: [PATCH] sync with imac --- apps/emqtt/src/emqtt_topic.erl | 13 +++++++++++++ apps/emqttd/src/emqttd_stats.erl | 5 +---- quickstart.md | 8 ++++++++ rel/files/app.config | 11 ++++++----- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/emqtt/src/emqtt_topic.erl b/apps/emqtt/src/emqtt_topic.erl index 697fe5d9a..d04da09ce 100644 --- a/apps/emqtt/src/emqtt_topic.erl +++ b/apps/emqtt/src/emqtt_topic.erl @@ -32,6 +32,8 @@ -export([match/2, validate/1, triples/1, words/1, wildcard/1]). +-export([systop/1]). + %-type type() :: static | dynamic. -type word() :: '' | '+' | '#' | binary(). @@ -164,3 +166,14 @@ word(<<"+">>) -> '+'; word(<<"#">>) -> '#'; word(Bin) -> Bin. +%%------------------------------------------------------------------------------ +%% @doc '$SYS' Topic. +%% @end +%%------------------------------------------------------------------------------ + +systop(Name) when is_atom(Name) -> + list_to_binary(lists:concat(["$SYS/brokers/", node(), "/", Name])); + +systop(Name) when is_binary(Name) -> + list_to_binary(["$SYS/brokers/", atom_to_list(node()), "/", Name]). + diff --git a/apps/emqttd/src/emqttd_stats.erl b/apps/emqttd/src/emqttd_stats.erl index 9a2933f92..c48d7da0e 100644 --- a/apps/emqttd/src/emqttd_stats.erl +++ b/apps/emqttd/src/emqttd_stats.erl @@ -122,7 +122,7 @@ init([]) -> Topics = ?SYSTOP_CLIENTS ++ ?SYSTOP_SESSIONS ++ ?SYSTOP_PUBSUB, [ets:insert(?STATS_TAB, {Topic, 0}) || Topic <- Topics], % Create $SYS Topics - [ok = emqttd_pubsub:create(systop(Topic)) || Topic <- Topics], + [ok = emqttd_pubsub:create(emqtt_topic:systop(Topic)) || Topic <- Topics], SysInterval = proplists:get_value(sys_interval, Options, 60), {ok, #state{}}. @@ -150,6 +150,3 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%============================================================================= -systop(Name) when is_atom(Name) -> - list_to_binary(lists:concat(["$SYS/brokers/", node(), "/", Name])). - diff --git a/quickstart.md b/quickstart.md index c7d8ede56..ffab18d36 100644 --- a/quickstart.md +++ b/quickstart.md @@ -123,3 +123,11 @@ retain | Retain(0, 1) topic | Topic message | Message + +## Contributors + +@hejin1026 <260495915 at qq.com> + +@desoulter + +@turtleDeng diff --git a/rel/files/app.config b/rel/files/app.config index 269dc5078..01cb541e2 100644 --- a/rel/files/app.config +++ b/rel/files/app.config @@ -66,17 +66,18 @@ {max_queue, 1000}, {store_qos0, false} ]}, + %% MQTT Broker + {mqtt_broker, [ + %% System interval of publishing broker $SYS messages + {sys_interval, 60} + ]}, %% Retain messages {retained, [ {max_message_num, 100000}, {max_playload_size, 4096} ]}, %% PubSub - {pubsub, []}, - %% Broker - {broker, [ - {sys_interval, 60} - ]}, + {mqtt_pubsub, []}, %% Metrics {metrics, [ {pub_interval, 60}