Merge pull request #504 from emqtt/0.17

1.0 - Changes, Issue #500, #503
This commit is contained in:
Feng Lee 2016-04-12 20:41:28 +08:00
commit d902a1843d
8 changed files with 384 additions and 189 deletions

1
CHANGES Normal file
View File

@ -0,0 +1 @@
Move to docs/source/changes.rst

View File

@ -1,23 +1,34 @@
emqttd ChangeLog
================
.. _changes:
0.17.1-beta(2016-03-22)
------------------------
=======
Changes
=======
### Enhancements
-------------------
Version 0.17.1-beta
-------------------
*Release Date: 2016-03-22*
Enhancements
------------
Time unit of session 'expired_after' changed to minute. (#479)
### Dashboard
Dashboard
---------
Code Review and improve the design of Dashboard.
-------------------
Version 0.17.0-beta
-------------------
0.17.0-beta(2016-03-15)
------------------------
*Release Date: 2016-03-15*
#### Highlights
Highlights
----------
Installation and Configuration Guide released on http://docs.emqtt.com
@ -27,16 +38,15 @@ Upgrade the [Web Dashboard](https://github.com/emqtt/emqttd_dashboard) to suppor
Bridge emqttd broker to another emqttd broker & emqttd to mosquitto bridge (#438)
#### Enhancements
Enhancements
------------
emqttd_ctl: better error message (#450)
./bin/emqttd_ctl: add 'routes' command
./bin/emqttd_ctl: add 'routes' command::
```
routes list # List all routes
routes show <Topic> # Show a route
```
Add 'backend_subscription' table and support static subscriptions (emqttd_backend)
@ -48,57 +58,64 @@ Add PubSub, Hooks APIs to emqttd module (emqttd)
Move start_listeners/0, stop_listeners/0 APIs to emqttd_app module (emqttd_app)
#### BugFix
#### Tests
Tests
-----
Add 100+ common test cases.
#### Plugins
Plugins
-------
Upgrade Dashboard, Redis, Stomp and Template Plugins
-------------------
Version 0.16.0-beta
-------------------
0.16.0-beta(2016-02-16)
------------------------
*Release Date: 2016-02-16*
#### Highlights
Highlights
----------
Licensed under the Apache License, Version 2.0 Now.
Improve the design of cluster, support to join or leave the cluster (#449):
Improve the design of cluster, support to join or leave the cluster (#449)::
```
$ ./bin/emqttd_ctl cluster
cluster join <Node> #Join the cluster
cluster leave #Leave the cluster
cluster remove <Node> #Remove the node from cluster
cluster status #Cluster status
```
Improve the design of Trie and Route, only the wildcard topics stored in Trie.
Common Test to replace EUnit.
#### Enhancements
Enhancements
------------
mqtt_message record: add 'sender' field (#440)
refactor the emqttd, emqttd_time, emqttd_opts, emqttd_node modules.
#### BugFix
Bugfix
------
noproc error when call to gen_server2:call(false, {add_route,Topic,<0.685.0>}, infinity) (#446)
#### Plugins
Plugins
-------
Changed the license of all plugins.
-------------------
Version 0.15.0-beta
-------------------
0.15.0-beta (2016-01-31)
------------------------
*Release Date: 2016-01-31*
#### Highlights
Highlights
----------
Optimize for Push Application, 500K+ Subscribers to a Topic.
@ -108,7 +125,8 @@ Priority Message Queue for Persistent Session (#432)
Add Redis, MongoDB Plugins (#417)
#### Enhancements
Enhancements
------------
Username/Password Authentication: Support to configure default users (#428)
@ -120,13 +138,15 @@ emqttd_auth_mod: add passwd_hash/2 function
priority_queue: add plen/2, out/2 functions
#### BugFix
Bugfix
------
Fix dequeue/1 of emqttd_bridge...
Add emqttd:seed_now/0 function
#### Plugins
Plugins
-------
emqttd_plubin_mysql: Changed mysql driver to mysql-otp
@ -136,25 +156,31 @@ emqttd_plugin_redis: First release
emqttd_plugin_mongo: First release
-------------------
Version 0.14.1-beta
-------------------
0.14.1-beta(2015-12-28)
-------------------------
*Release Date: 2015-12-28*
Bugfix: emqttd_ws_client.erl: Unexpected Info: {'EXIT',<0.27792.18>,{shutdown,destroy}} (#413)
Improve: fix spec errors found by dialyzer
-------------------
Version 0.14.0-beta
-------------------
0.14.0-beta(2015-12-18)
-------------------------
*Release Date: 2015-12-18*
#### Highlights
Highlights
----------
Scaling to 1.3 Million Concurrent MQTT Connections on a 12 Core, 32G CentOS server.
New PubSub, Router Design (#402). Prepare for scaling to 10 millions on one cluster.
#### Enhancements
Enhancements
------------
Improve the gproc_pool usage with a general emqttd_pool_sup
@ -178,19 +204,23 @@ Subscriptions persistence (#344)
emqttd_ctl: 'subscriptions' command to force clients to subscribe some topics (#361)
#### Bugfix
Bugfix
------
emqttd_sm: spec of lookup_session/1 is not right BUG (#411)
Observer application should be removed from reltool.config for 'wx' app is not available (#410)
#### Benchmark
Benchmark
---------
1.3 million concurrent MQTT connections on a 12 Core, 32G CentOS Server, consume about 15G Memory and 200% CPU.
-------------------
Version 0.13.1-beta
-------------------
0.13.1-beta(2015-11-28)
-------------------------
*Release Date: 2015-11-28*
Bugfix: Plugin pathes error under windows (#387)
@ -202,11 +232,14 @@ Improve: High CPU load when 400K unstable mobile connections (#377)
BugFix: emqttd_plugin_pgsql - error using same query with latest update plugin (pgsql#5)
-------------------
Version 0.13.0-beta
-------------------
0.13.0-beta(2015-11-08)
-------------------------
*Release Date: 2015-11-08*
#### Highlights
Highlights
----------
Rate Limiting based on [Token Bucket](https://en.wikipedia.org/wiki/Token_bucket) and [Leaky Bucket](https://en.wikipedia.org/wiki/Leaky_bucket#The_Leaky_Bucket_Algorithm_as_a_Meter) Algorithm
@ -214,7 +247,8 @@ Upgrade eSockd and MochiWeb libraries to support Parameterized Connection Module
Improve emqttd_client to support fully asynchronous socket networking
#### Enhancements
Enhancements
------------
Protocol Compliant - Session Present Flag (#163)
@ -228,7 +262,8 @@ emqttd_client.erl to handle 'inet_async', 'inet_reply' properly (#360)
Refator the [client/session management design](https://github.com/emqtt/emqttd/blob/master/doc/design/ClientSession.md)
#### Bugfix
Bugfix
------
Cannot kick transient client out when clientId collision (#357)
@ -236,13 +271,15 @@ Fix the order of emqttd_app:start_server/1 (#367)
emqttd_session:subscribe/2 will crash (#374)
#### Benchmark
Benchmark
---------
[benchmark for 0.13.0 release](https://github.com/emqtt/emqttd/wiki/benchmark-for-0.13.0-release)
3.1G memory and 50+ CPU/core:
```
.. code:: console
Connections: 250K
Subscribers: 250K
Topics: 50K
@ -250,25 +287,30 @@ Qos1 Messages/Sec In: 4K
Qos1 Messages/Sec Out: 20K
Traffic In(bps): 12M+
Traffic Out(bps): 56M+
```
-------------------
Version 0.12.3-beta
-------------------
0.12.3-beta (2015-10-22)
-------------------------
*Release Date: 2015-10-22*
Bugfix: emqttd_sysmon crasher for 'undefined' process_info (#350)
Bugfix: emqttd_client: catch parser exception (#353)
-------------------
Version 0.12.2-beta
-------------------
0.12.2-beta (2015-10-16)
-------------------------
*Release Date: 2015-10-16*
Bugfix: Retained messages should not be expired if 'broker.retained.expired_after = 0' (#346)
-------------------
Version 0.12.1-beta
-------------------
0.12.1-beta (2015-10-15)
-------------------------
*Release Date: 2015-10-15*
Highlight: Release for Bugfix and Code Refactor.
@ -286,11 +328,14 @@ Task: benchmark for 0.12.0 release (#225)
Benchmark: About 900K concurrent connections established on a 20Core, 32G CentOS server.
-------------------
Version 0.12.0-beta
-------------------
0.12.0-beta (2015-10-08)
-------------------------
*Release Date: 2015-10-08*
#### Highlights
Highlights
----------
Enhance the **emqttd_ctl** module to allow plugins to register new commands (#256)
@ -304,7 +349,8 @@ Add **'./bin/emqttd_top'** command(like etop) to show the top 'msg_q', 'reductio
'rel/files/emqttd.config.development' for development deployment
#### Enhancements
Enhancements
------------
Qos1/2 messages will not be dropped under unstable mobile network (#264)
@ -316,11 +362,13 @@ Qos1/2 messages will not be dropped under unstable mobile network (#264)
How to monitor large 'message_queue_len' (#283)
#### Bugfix
Bugfix
------
Behaviour emqttd_auth_mod is missing init callback (#318)
#### Benchmark
Benchmark
---------
Write a new [benchmark tool](https://github.com/emqtt/emqtt_benchmark) to benchmark this release
@ -328,9 +376,11 @@ Hw requirements - 5K users, 25-50 msgs/sec, QoS=1 (#209)
Supported Number of Connections Greatly Reduced When Clients are Subscribing (#324)
-------------------
Version 0.11.0-beta
-------------------
0.11.0-beta (2015-09-25)
-------------------------
*Release Date: 2015-09-25*
Highlight: Rebar to manage plugin dependencies.
@ -354,9 +404,11 @@ Bugfix: issue#311 - './bin/emqttd_ctl sessions list' error
Bugfix: issue#312 - unsubcribe will lead to crash if emqttd_plugin_template plugin loaded
-------------------
Version 0.10.4-beta
-------------------
0.10.4-beta (2015-09-18)
-------------------------
*Release Date: 2015-09-18*
Optimize session management and upgrade eSockd library to 2.7.1
@ -370,9 +422,11 @@ Bugfix: issue#291 - "./bin/emqttd attach ..." cannot work
Bugfix: issue#284 - Should not use erlang:list_to_atom/1 in emqttd_vm.erl
-------------------
Version 0.10.3-beta
-------------------
0.10.3-beta (2015-08-30)
-------------------------
*Release Date: 2015-08-30*
Bugfix: issue#271 - add emqttd_ws_client:subscribe/2 function
@ -380,23 +434,29 @@ Bugfix: issue#269 - bin/emqttd Syntax error on ubuntu
Improve: issue#265 - client under unstable mobile network generate a lot of logs
-------------------
Version 0.10.2-beta
-------------------
0.10.2-beta (2015-08-26)
-------------------------
*Release Date: 2015-08-26*
Improve: issue#257 - After the node name changed, the broker cannot restart for mnesia schema error.
-------------------
Version 0.10.1-beta
-------------------
0.10.1-beta (2015-08-25)
-------------------------
*Release Date: 2015-08-25*
Bugfix: issue#259 - when clustered the emqttd_dashboard port is close, and the 'emqttd' application cannot stop normally.
Feature: issue#262 - Add 'http://host:8083/mqtt/status' Page for health check
-------------------
Version 0.10.0-beta
-------------------
0.10.0-beta (2015-08-20)
-------------------------
*Release Date: 2015-08-20*
[Web Dashboard](https://github.com/emqtt/emqttd_dashboard) and [MySQL](https://github.com/emqtt/emqttd_plugin_mysql), [PostgreSQL](https://github.com/emqtt/emqttd_plugin_pgsql) Authentication/ACL Plugins!
@ -440,9 +500,11 @@ Bugfix: Too many 'Session ~s cannot find PUBACK' logs (#212)
Bugfix: emqttd_pooler cannot work
-------------------
Version 0.9.3-alpha
-------------------
0.9.3-alpha (2015-07-25)
-------------------------
*Release Date: 2015-07-25*
Wiki: [Bridge](https://github.com/emqtt/emqttd/wiki/Bridge)
@ -454,23 +516,29 @@ Improve: ./bin/emqttd_ctl to support new bridges command
Bugfix: issue #206 - Cannot bridge two nodes
-------------------
Version 0.9.2-alpha
-------------------
0.9.2-alpha (2015-07-18)
-------------------------
*Release Date: 2015-07-18*
Improve: issue #196 - Add New Hook 'client.subscribe.after'
-------------------
Version 0.9.1-alpha
-------------------
0.9.1-alpha (2015-07-10)
-------------------------
*Release Date: 2015-07-10*
Bugfix: issue #189 - MQTT over WebSocket(SSL) cannot work?
Bugfix: issue #193 - 'client.ack' hook should be renamed to 'message.acked', and called by emqttd_broker:foreach_hooks
-------------------
Version 0.9.0-alpha
-------------------
0.9.0-alpha (2015-07-09)
-------------------------
*Release Date: 2015-07-09*
[Session, Queue, Inflight Window, Hooks, Global MessageId and More Protocol Compliant](https://github.com/emqtt/emqttd/releases/tag/0.9.0-alpha) Now!
@ -526,27 +594,35 @@ Bugfix: Closed issues #181, #119.
Tests: fix the parser, acl test cases.
------------------
Version 0.8.6-beta
------------------
0.8.6-beta (2015-06-17)
-------------------------
*Release Date: 2015-06-17*
Bugfix: issue #175 - publish Will message when websocket is closed without 'DISCONNECT' packet
------------------
Version 0.8.5-beta
------------------
0.8.5-beta (2015-06-10)
-------------------------
*Release Date: 2015-06-10*
Bugfix: issue #53 - client will receive duplicate messages when overlapping subscription
------------------
Version 0.8.4-beta
------------------
0.8.4-beta (2015-06-08)
-------------------------
*Release Date: 2015-06-08*
Bugfix: issue #165 - duplicated message when publish 'retained' message to persistent client
------------------
Version 0.8.3-beta
------------------
0.8.3-beta (2015-06-05)
-------------------------
*Release Date: 2015-06-05*
Bugfix: issue #158 - should queue:in new message after old one dropped
@ -554,17 +630,21 @@ Bugfix: issue #155 - emqtt_parser.erl: parse_topics/3 should reverse topics
Bugfix: issue #149 - Forget to merge plugins/emqttd_auth_mysql from 'dev' branch to 'master' in 0.8.x release
-------------------
Version 0.8.2-alpha
-------------------
0.8.2-alpha (2015-06-01)
-------------------------
*Release Date: 2015-06-01*
Bugfix: issue #147 - WebSocket client cannot subscribe queue '$Q/queue/${clientId}'
Bugfix: issue #146 - emqttd_auth_ldap: fill(Username, UserDn) is not right
-------------------
Version 0.8.1-alpha
-------------------
0.8.1-alpha (2015-05-28)
-------------------------
*Release Date: 2015-05-28*
Client [Presence](https://github.com/emqtt/emqttd/wiki/Presence) Support and [$SYS Topics](https://github.com/emqtt/emqttd/wiki/$SYS-Topics) Redesigned!
@ -576,9 +656,11 @@ Improve: etc/emqttd.config to allow websocket connections from any hosts
Improve: rel/reltool.config to exclude unnecessary apps.
-------------------
Version 0.8.0-alpha
-------------------
0.8.0-alpha (2015-05-25)
-------------------------
*Release Date: 2015-05-25*
[Hooks](https://github.com/emqtt/emqttd/wiki/Hooks%20Design), Modules and [Plugins](https://github.com/emqtt/emqttd/wiki/Plugin%20Design) to extend the broker Now!
@ -606,9 +688,11 @@ Improve: add emqttd_sm_sup module, and use 'hash' gproc_pool to manage sessions
Tests: add more test cases for 'emqttd' app
-------------------
Version 0.7.1-alpha
-------------------
0.7.1-alpha (2015-05-04)
-------------------------
*Release Date: 2015-05-04*
Add doc/design/* and merge doc/* to github Wiki
@ -618,9 +702,11 @@ Bugfix: issue #123 - emqttd:unload_all_plugins/0 cannot unload any plugin
Bugfix: fix errors found by dialyzer
-------------------
Version 0.7.0-alpha
-------------------
0.7.0-alpha (2015-05-02)
-------------------------
*Release Date: 2015-05-02*
[MQTT over WebSocket(SSL)](https://github.com/emqtt/emqttd/wiki/MQTT-Over-WebSocket) Now!
@ -652,9 +738,11 @@ Bugfix: issue #112 - Makefile to support build plugins
Bugfix: issue #96 - "make clean" cannot work
-------------------
Version 0.6.2-alpha
-------------------
0.6.2-alpha (2015-04-24)
-------------------------
*Release Date: 2015-04-24*
Bugfix: critical issue #54, #104, #106 - error when resume session
@ -664,9 +752,11 @@ Improve: kick old client out when session is duplicated.
Improve: move mnesia dir config from etc/app.config to etc/vm.args
-------------------
Version 0.6.1-alpha
-------------------
0.6.1-alpha (2015-04-20)
-------------------------
*Release Date: 2015-04-20*
Integrate with [gproc library](https://github.com/uwiger/gproc) to support pool
@ -678,9 +768,11 @@ Improve: issues#84 - emqttd_pubsub is redesigned again to protect mnesia transac
Improve: issues#74 - ACL Support and update [ACL Design Wiki](https://github.com/emqtt/emqttd/wiki/ACL-Design)
-------------------
Version 0.6.0-alpha
-------------------
0.6.0-alpha (2015-04-17)
-------------------------
*Release Date: 2015-04-17*
ACL Support Now: [ACL-Design Wiki](https://github.com/emqtt/emqttd/wiki/ACL-Design)
@ -720,21 +812,24 @@ Bugfix: issues#83 - emqttd_broker stats cannot work
Bugfix: issues#75 - careless about function name when emqttd_pubsub handle getstats message
------------------
Version 0.5.5-beta
------------------
0.5.5-beta (2015-04-09)
-------------------------
*Release Date: 2015-04-09*
Bugfix: issue #75 - careless about function name when emqttd_pubsub handle getstats message.
Bugfix: issue #79 - cannot find topic_subscriber table after cluster with other nodes.
-------------------
Version 0.5.4-alpha
-------------------
0.5.4-alpha (2015-03-22)
-------------------------
*Release Date: 2015-03-22*
Benchmark this release on a ubuntu/14.04 server with 8 cores, 32G memory from QingCloud.com:
Benchmark this release on a ubuntu/14.04 server with 8 cores, 32G memory from QingCloud.com::
```
200K Connections,
30K Messages/Sec,
20Mbps In/Out Traffic,
@ -742,7 +837,6 @@ Benchmark this release on a ubuntu/14.04 server with 8 cores, 32G memory from Qi
200K Subscribers,
Consumed 7G memory, 40% CPU/core
```
Benchmark code: https://github.com/emqtt/emqttd_benchmark
@ -752,27 +846,35 @@ Change: ./bin/emqttd_ctl add 'stats', 'metrics' commands.
Bugfix: issue #71, #72
-------------------
Version 0.5.3-alpha
-------------------
0.5.3-alpha (2015-03-19)
-------------------------
*Release Date: 2015-03-19*
Bugfix: issues#72 - emqttd_cm, emqtt_sm ets:match_delete/2 with wrong pattern
-------------------
Version 0.5.2-alpha
-------------------
0.5.2-alpha (2015-03-18)
-------------------------
*Release Date: 2015-03-18*
Change: upgrade esockd to 2.1.0-alpha, do not tune socket buffer for mqtt connection.
-------------------
Version 0.5.1-alpha
-------------------
v0.5.1-alpha (2015-03-13)
-------------------------
*Release Date: 2015-03-13*
Change: upgrade esockd to v1.2.0-beta, rename 'acceptor_pool' to 'acceptors'
-------------------
Version 0.5.0-alpha
-------------------
v0.5.0-alpha (2015-03-12)
-------------------------
*Release Date: 2015-03-12*
RENAME 'emqtt' to 'emqttd'!
@ -798,9 +900,11 @@ Bugfix: issue#64 - emqtt_app start/2: should wait_for_databases
Test: emqttd_topic_tests add more '_match_test'
-------------------
Version 0.4.0-alpha
-------------------
v0.4.0-alpha (2015-03-10)
-------------------------
*Release Date: 2015-03-10*
Support [$SYS Topics of Broker](https://github.com/emqtt/emqttd/wiki/$SYS-Topics-of-Broker) Now!
@ -828,29 +932,37 @@ Change: emqtt_opts to add merge/2 function
Test: add emqtt_serialiser_tests.erl
------------------
Version 0.3.4-beta
------------------
v0.3.4-beta (2015-03-08)
------------------------
*Release Date: 2015-03-08*
Bugfix: emqtt_serialiser.erl cannot serialise UNSUBACK packets
------------------
Version 0.3.3-beta
------------------
v0.3.3-beta (2015-03-07)
------------------------
*Release Date: 2015-03-07*
Bugfix: emqtt_serialiser.erl cannot serialise PINGRESP issue#60
------------------
Version 0.3.2-beta
------------------
v0.3.2-beta (2015-03-05)
------------------------
*Release Date: 2015-03-05*
Improve: merge emqttc serialiser, parser, packet
Add: emqtt_opts to merge socket options
------------------
Version 0.3.1-beta
------------------
v0.3.1-beta (2015-03-02)
------------------------
*Release Date: 2015-03-02*
Feature: SSL Socket Support
@ -864,9 +976,11 @@ Upgrade: esockd to v0.2.0
Upgrade: mochiweb to v3.0.0
------------------
Version 0.3.0-beta
------------------
v0.3.0-beta (2015-01-19)
------------------------
*Release Date: 2015-01-19*
Feature: HTTP POST API to support 'qos', 'retain' parameters
@ -878,9 +992,11 @@ Change: fix emqtt_pubsub.erl to match '#', '+'
Tests: emqtt_topic_tests.erl add more test cases
-------------------
Version 0.3.0-alpha
-------------------
v0.3.0-alpha (2015-01-18)
------------------------
*Release Date: 2015-01-08*
NOTICE: Full MQTT 3.1.1 support now!
@ -908,9 +1024,11 @@ Test: simple cluster test
Closed Issues: #22, #24, #27, #28, #29, #30, #31, #32, #33, #34, #36, #37, #38, #39, #41, #42, #43
------------------
Version 0.2.1-beta
------------------
v0.2.1-beta (2015-01-08)
------------------------
*Release Date: 2015-01-08*
pull request 26: Use binaries for topic paths and fix wildcard topics
@ -924,8 +1042,11 @@ tag emqtt release accoding to [Semantic Versioning](http://semver.org/)
max clientId length is 1024 now.
0.2.0 (2014-12-07)
-------------------
-------------
Version 0.2.0
-------------
*Release Date: 2014-12-07*
rewrite the project, integrate with esockd, mochiweb
@ -933,38 +1054,51 @@ support MQTT 3.1.1
support HTTP to publish message
0.1.5 (2013-01-05)
-------------------
-------------
Version 0.1.5
-------------
*Release Date: 2013-01-05*
Bugfix: remove QOS_1 match when handle PUBREL request
Bugfix: reverse word in emqtt_topic:words/1 function
0.1.4 (2013-01-04)
-------------------
-------------
Version 0.1.4
-------------
*Release Date: 2013-01-04*
Bugfix: fix "mosquitto_sub -q 2 ......" bug
Bugfix: fix keep alive bug
0.1.3 (2013-01-04)
-------------------
-------------
Version 0.1.3
-------------
Feature: support QOS2 PUBREC, PUBREL,PUBCOMP messages
*Release Date: 2013-01-04*
Feature: Support QOS2 PUBREC, PUBREL, PUBCOMP messages
Bugfix: fix emqtt_frame to encode/decoe PUBREC/PUBREL messages
-------------
Version 0.1.2
-------------
0.1.2 (2012-12-27)
-------------------
*Release Date: 2012-12-27*
Feature: release support like riak
Bugfix: use ?INFO/?ERROR to print log in tcp_listener.erl
-------------
Version 0.1.1
-------------
0.1.1 (2012-09-24)
-------------------
*Release Date: 2012-09-24*
Feature: use rebar to generate release
@ -972,8 +1106,11 @@ Feature: support retained messages
Bugfix: send will msg when network error
0.1.0 (2012-09-21)
-------------------
-------------
Version 0.1.0
-------------
*Release Date: 2012-09-21*
The first public release.

View File

@ -1,9 +1,9 @@
.. _design:
============
Design Guide
============
======
Design
======
.. _design_architecture:

View File

@ -52,6 +52,7 @@ Contents:
commands
plugins
tune
changes
-------
License

View File

@ -96,7 +96,9 @@ expire_messages(Time) when is_integer(Time) ->
when Time > (MegaSecs * 1000000 + Secs) -> Topic
end),
Topics = mnesia:select(retained_message, Match, write),
lists:foreach(fun(Topic) -> mnesia:delete({retained_message, Topic}) end, Topics)
lists:foreach(fun(<<"$SYS/", _/binary>>) -> ok; %% ignore $SYS/# messages
(Topic) -> mnesia:delete({retained_message, Topic})
end, Topics)
end).
-spec(retained_count() -> non_neg_integer()).

View File

@ -61,8 +61,10 @@ parse_remaining_len(_Bin, _Header, _Multiplier, Length, #mqtt_packet_limit{max_p
{error, invalid_mqtt_frame_len};
parse_remaining_len(<<>>, Header, Multiplier, Length, Limit) ->
{more, fun(Bin) -> parse_remaining_len(Bin, Header, Multiplier, Length, Limit) end};
%% optimize: match PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK...
parse_remaining_len(<<0:1, 2:7, Rest/binary>>, Header, 1, 0, _Limit) ->
parse_frame(Rest, Header, 2);
%% optimize: match PINGREQ...
parse_remaining_len(<<0:8, Rest/binary>>, Header, 1, 0, _Limit) ->
parse_frame(Rest, Header, 0);
parse_remaining_len(<<1:1, Len:7, Rest/binary>>, Header, Multiplier, Value, Limit) ->

View File

@ -95,12 +95,16 @@ init([]) ->
StatsFun = emqttd_stats:statsfun('retained/count', 'retained/max'),
%% One second
{ok, StatsTimer} = timer:send_interval(timer:seconds(1), stats),
%% Five minutes
{ok, ExpireTimer} = timer:send_interval(timer:minutes(5), expire),
{ok, #state{stats_fun = StatsFun,
expired_after = env(expired_after),
stats_timer = StatsTimer,
expire_timer = ExpireTimer}}.
State = #state{stats_fun = StatsFun, stats_timer = StatsTimer},
{ok, init_expire_timer(env(expired_after), State)}.
init_expire_timer(0, State) ->
State;
init_expire_timer(undefined, State) ->
State;
init_expire_timer(Secs, State) ->
{ok, Timer} = timer:send_interval(timer:seconds(Secs), expire),
State#state{expired_after = Secs, expire_timer = Timer}.
handle_call(Req, _From, State) ->
?UNEXPECTED_REQ(Req, State).

View File

@ -36,7 +36,11 @@ groups() ->
parse_bridge,
parse_publish,
parse_puback,
parse_pubrec,
parse_pubrel,
parse_pubcomp,
parse_subscribe,
parse_unsubscribe,
parse_pingreq,
parse_disconnect]},
{serializer, [],
@ -173,17 +177,61 @@ parse_publish(_) ->
parse_puback(_) ->
Parser = emqttd_parser:new([]),
%%PUBACK(Qos=0, Retain=false, Dup=false, PacketId=1)
PubAckBin = <<64,2,0,1>>,
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?PUBACK,
dup = false,
qos = 0,
retain = false}}, <<>>} = Parser(PubAckBin).
retain = false}}, <<>>} = Parser(<<64,2,0,1>>).
parse_pubrec(_) ->
Parser = emqttd_parser:new([]),
%%PUBREC(Qos=0, Retain=false, Dup=false, PacketId=1)
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?PUBREC,
dup = false,
qos = 0,
retain = false}}, <<>>} = Parser(<<5:4,0:4,2,0,1>>).
parse_pubrel(_) ->
Parser = emqttd_parser:new([]),
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?PUBREL,
dup = false,
qos = 1,
retain = false}}, <<>>} = Parser(<<6:4,2:4,2,0,1>>).
parse_pubcomp(_) ->
Parser = emqttd_parser:new([]),
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?PUBCOMP,
dup = false,
qos = 0,
retain = false}}, <<>>} = Parser(<<7:4,0:4,2,0,1>>).
parse_subscribe(_) ->
ok.
Parser = emqttd_parser:new([]),
%% SUBSCRIBE(Q1, R0, D0, PacketId=2, TopicTable=[{<<"TopicA">>,2}])
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?SUBSCRIBE,
dup = false,
qos = 1,
retain = false},
variable = #mqtt_packet_subscribe{packet_id = 2,
topic_table = [{<<"TopicA">>,2}]} }, <<>>}
= Parser(<<130,11,0,2,0,6,84,111,112,105,99,65,2>>).
parse_unsubscribe(_) ->
Parser = emqttd_parser:new([]),
%% UNSUBSCRIBE(Q1, R0, D0, PacketId=2, TopicTable=[<<"TopicA">>])
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?UNSUBSCRIBE,
dup = false,
qos = 1,
retain = false},
variable = #mqtt_packet_unsubscribe{packet_id = 2,
topics = [<<"TopicA">>]}}, <<>>}
= Parser(<<162,10,0,2,0,6,84,111,112,105,99,65>>).
parse_pingreq(_) ->
ok.
Parser = emqttd_parser:new([]),
{ok, #mqtt_packet{header = #mqtt_packet_header{type = ?PINGREQ,
dup = false,
qos = 0,
retain = false}}, <<>>}
= Parser(<<?PINGREQ:4, 0:4, 0:8>>).
parse_disconnect(_) ->
Parser = emqttd_parser:new([]),