Merge branch 'dev' into dev-hd
This commit is contained in:
commit
ba811eb866
|
@ -5,6 +5,8 @@ emqttd ChangeLog
|
||||||
0.9.0-alpha (2015-07-xx)
|
0.9.0-alpha (2015-07-xx)
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
TODO:......
|
||||||
|
|
||||||
Session and Queue
|
Session and Queue
|
||||||
|
|
||||||
Merge emqtt, emqttd apps
|
Merge emqtt, emqttd apps
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
%%% 1. Timestamp: erlang:system_time if Erlang >= R18, otherwise os:timestamp
|
%%% 1. Timestamp: erlang:system_time if Erlang >= R18, otherwise os:timestamp
|
||||||
%%% 2. NodeId: encode node() to 2 bytes integer
|
%%% 2. NodeId: encode node() to 2 bytes integer
|
||||||
%%% 3. Pid: encode pid to 4 bytes integer
|
%%% 3. Pid: encode pid to 4 bytes integer
|
||||||
%%% 4. Sequence: 2 bytes sequence no per pid
|
%%% 4. Sequence: 2 bytes sequence per pid
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-----------------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------------
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
|
|
||||||
-type guid() :: <<_:128>>.
|
-type guid() :: <<_:128>>.
|
||||||
|
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
|
%% @doc Generate a global unique id.
|
||||||
|
%% @end
|
||||||
|
%%------------------------------------------------------------------------------
|
||||||
-spec gen() -> guid().
|
-spec gen() -> guid().
|
||||||
gen() ->
|
gen() ->
|
||||||
Guid = case get(guid) of
|
Guid = case get(guid) of
|
||||||
|
|
|
@ -159,7 +159,7 @@ destroy(Session, ClientId) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-spec subscribe(pid(), [{binary(), mqtt_qos()}]) -> {ok, [mqtt_qos()]}.
|
-spec subscribe(pid(), [{binary(), mqtt_qos()}]) -> {ok, [mqtt_qos()]}.
|
||||||
subscribe(Session, TopicTable) ->
|
subscribe(Session, TopicTable) ->
|
||||||
gen_server:call(Session, {subscribe, TopicTable}).
|
gen_server:call(Session, {subscribe, TopicTable}, infinity).
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% @doc Publish message
|
%% @doc Publish message
|
||||||
|
@ -204,7 +204,7 @@ pubcomp(Session, PktId) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-spec unsubscribe(pid(), [binary()]) -> ok.
|
-spec unsubscribe(pid(), [binary()]) -> ok.
|
||||||
unsubscribe(Session, Topics) ->
|
unsubscribe(Session, Topics) ->
|
||||||
gen_server:call(Session, {unsubscribe, Topics}).
|
gen_server:call(Session, {unsubscribe, Topics}, infinity).
|
||||||
|
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
%%% gen_server callbacks
|
%%% gen_server callbacks
|
||||||
|
|
|
@ -193,5 +193,5 @@ new_session(CleanSess, ClientId, ClientPid) ->
|
||||||
|
|
||||||
setstats(State = #state{statsfun = {CFun, SFun}}) ->
|
setstats(State = #state{statsfun = {CFun, SFun}}) ->
|
||||||
CFun(ets:info(?SESSION_TAB, size)),
|
CFun(ets:info(?SESSION_TAB, size)),
|
||||||
SFun(ets:select_count(?SESSION_TAB, [{{true, '_', '_', '_'}, [], [true]}])),
|
SFun(ets:select_count(?SESSION_TAB, [{{false, '_', '_', '_'}, [], [true]}])),
|
||||||
State.
|
State.
|
||||||
|
|
|
@ -27,6 +27,27 @@
|
||||||
|
|
||||||
-module(emqttd_vm).
|
-module(emqttd_vm).
|
||||||
|
|
||||||
|
-export([microsecs/0]).
|
||||||
|
|
||||||
|
-export([loads/0, scheduler_usage/1]).
|
||||||
|
|
||||||
|
-export([get_memory/0]).
|
||||||
|
|
||||||
|
-export([get_process_list/0,
|
||||||
|
get_process_info/0,
|
||||||
|
get_process_gc/0,
|
||||||
|
get_process_group_leader_info/1]).
|
||||||
|
|
||||||
|
-export([get_ets_list/0,
|
||||||
|
get_ets_info/0,
|
||||||
|
get_ets_info/1,
|
||||||
|
get_ets_object/0,
|
||||||
|
get_ets_object/1]).
|
||||||
|
|
||||||
|
-export([get_port_types/0,
|
||||||
|
get_port_info/0,
|
||||||
|
get_port_info/1]).
|
||||||
|
|
||||||
-define(UTIL_ALLOCATORS, [temp_alloc,
|
-define(UTIL_ALLOCATORS, [temp_alloc,
|
||||||
eheap_alloc,
|
eheap_alloc,
|
||||||
binary_alloc,
|
binary_alloc,
|
||||||
|
@ -65,15 +86,10 @@
|
||||||
total_heap_size,
|
total_heap_size,
|
||||||
heap_size,
|
heap_size,
|
||||||
stack_size,
|
stack_size,
|
||||||
min_heap_size]).%,
|
min_heap_size]).
|
||||||
%fullsweep_after]).
|
%fullsweep_after]).
|
||||||
|
|
||||||
-export([timestamp/0, microsecs/0]).
|
-define(SYSTEM_INFO, [allocated_areas,
|
||||||
|
|
||||||
-export([loads/0]).
|
|
||||||
|
|
||||||
-define(SYSTEM_INFO, [
|
|
||||||
allocated_areas,
|
|
||||||
allocator,
|
allocator,
|
||||||
alloc_util_allocators,
|
alloc_util_allocators,
|
||||||
build_type,
|
build_type,
|
||||||
|
@ -123,13 +139,9 @@
|
||||||
wordsize
|
wordsize
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-define(SOCKET_OPTS, [
|
-define(SOCKET_OPTS, [active,
|
||||||
active,
|
|
||||||
broadcast,
|
broadcast,
|
||||||
buffer,
|
buffer,
|
||||||
buffer,
|
|
||||||
buffer,
|
|
||||||
buffer,
|
|
||||||
delay_send,
|
delay_send,
|
||||||
dontroute,
|
dontroute,
|
||||||
exit_on_close,
|
exit_on_close,
|
||||||
|
@ -150,37 +162,7 @@
|
||||||
send_timeout,
|
send_timeout,
|
||||||
send_timeout_close,
|
send_timeout_close,
|
||||||
sndbuf,
|
sndbuf,
|
||||||
tos
|
tos]).
|
||||||
]).
|
|
||||||
|
|
||||||
|
|
||||||
-author("Feng Lee <feng@emqtt.io>").
|
|
||||||
|
|
||||||
-export([timestamp/0, microsecs/0]).
|
|
||||||
|
|
||||||
-export([loads/0,
|
|
||||||
scheduler_usage/1]).
|
|
||||||
|
|
||||||
-export([get_memory/0]).
|
|
||||||
|
|
||||||
-export([get_process_list/0,
|
|
||||||
get_process_info/0,
|
|
||||||
get_process_gc/0,
|
|
||||||
get_process_group_leader_info/1]).
|
|
||||||
|
|
||||||
-export([get_ets_list/0,
|
|
||||||
get_ets_info/0,
|
|
||||||
get_ets_info/1,
|
|
||||||
get_ets_object/0,
|
|
||||||
get_ets_object/1]).
|
|
||||||
|
|
||||||
-export([get_port_types/0,
|
|
||||||
get_port_info/0,
|
|
||||||
get_port_info/1]).
|
|
||||||
|
|
||||||
timestamp() ->
|
|
||||||
{MegaSecs, Secs, _MicroSecs} = os:timestamp(),
|
|
||||||
MegaSecs * 1000000 + Secs.
|
|
||||||
|
|
||||||
microsecs() ->
|
microsecs() ->
|
||||||
{Mega, Sec, Micro} = erlang:now(),
|
{Mega, Sec, Micro} = erlang:now(),
|
||||||
|
|
Loading…
Reference in New Issue