Commit Graph

290 Commits

Author SHA1 Message Date
spring2maz
a6f138b55c Improve shared sub dispatch implementation. (#2144)
Before this change, when shared dispatch ack is enabled (in config)
in case all subscribers are offline (all sessions gave negative ack)
the message is simply discarded.
In this change, it is ensured to have one session picked according to
configured dispatch strategy when no subscriber is online.
The messages dispatched in such scenario are then queued in session state.
2019-01-22 09:57:37 +08:00
Shawn
b8929a46c1 Fix the EXIT outputs in Travis CI (#2154)
* Fix the Exit in testcases

* Fix Exit in emqx_mod_sup_SUITE

* Update testcases for log_tracer

* Fix Exit in emqx_protocol_SUITE

* Add will_acl_check

* Fix more Exits
2019-01-17 17:14:51 +08:00
tigercl
bc31faac6b Fix will msg (#2156)
* Remove will_msg and will_topic from protocol state

* Modify try_open_session/1
2019-01-17 13:57:42 +08:00
YoukiLin
3748cd434d Add test case for emqx_sys_mon (#2150) 2019-01-12 23:09:39 +08:00
Gilbert Wong
7aa46896df Fix typo 2019-01-11 16:41:20 +08:00
Gilbert Wong
ec03f8e1fa Fix the deliver packet bug and add test case 2019-01-11 16:41:20 +08:00
turtleDeng
a5f9466040 QoS0 msg support msgid (#2145)
* QoS0 msg support msgid

* Fix testcase
2019-01-11 11:47:10 +08:00
Feng Lee
fe0f5333b3 Improve the pool design
- Move 'emqx_pool:start_link/0' to emqx_pool_sup module
- Use the new log macros
- Add more test cases
2019-01-10 08:49:58 +08:00
Feng Lee
36a4eaec02 Fix the test case for 'emqx_router:print_routes/1' 2019-01-09 12:10:54 +08:00
Feng Lee
52241a7804 Add more test cases for code coverage 2019-01-09 11:57:22 +08:00
Feng Lee
d27c824ed8 Add test case for emqx_trie:empty/0 2019-01-09 11:57:22 +08:00
Gilbert
9f83544fce
Fix failed testcase (#2127)
* Fix failed test case
Prior to this change, terry-xiaoyu enhanced the cuttlefish to
support emqx enterprise edtion configuration entries. But it cause 6
test case failed.

* Fix dep-vsn-check
2019-01-06 19:53:01 +08:00
YoukiLin
78b3c375d8
Improving 'emqx_ws_connection' coverage (#2107) 2019-01-03 12:59:39 +08:00
turtleDeng
6a1ebe299a
Merge emqx32 to emqx30 (#2112) 2018-12-28 19:44:41 +08:00
Gilbert
1797aadbe7 Fix unsuback compat (#2102) 2018-12-22 18:47:38 +08:00
turtled
7d3357e0f3 Merge emqx32 2018-12-21 16:01:32 +08:00
Feng Lee
10e5210581 Workaround ssl:setopts(SslSock, [{active, N}]) (#2095)
* Set '{active, true}' for SSL socket
2018-12-21 15:39:24 +08:00
tigercl
31bf01fd7a Fix bug in topic alias maximum (#2074)
* Fix bug in topic alias maximum
2018-12-21 14:01:21 +08:00
Gilbert
bf7f10ecd1 Add will topic validation and acl check (#2075)
* Add will topic validation and acl check
2018-12-21 10:49:03 +08:00
Feng Lee
c93d0fb174 Add test cases for emqx_gc module 2018-12-21 10:28:33 +08:00
Gilbert Wong
1007105b57 Delete metrics test in session test suite 2018-12-20 22:31:19 +08:00
turtled
b4833d6973 Fixed conflicts 2018-12-20 22:23:20 +08:00
YoukiLin
6b538d2363 Add test cases for 'emqx_cm' and 'emqx_sm' (#2073)
Add test cases for 'emqx_cm' and 'emqx_cn'
2018-12-20 21:03:40 +08:00
Feng Lee
14cffcf7fb Add the 'emqx_pd' module
Add utility functions for erlang process dictionary
Add test cases for emqx_pd
2018-12-20 16:45:25 +08:00
tigercl
97474171d0 Better report errors in acl.conf (#2065) 2018-12-19 23:06:48 +08:00
turtled
7a1ec580b0 Update broker test cases 2018-12-19 17:18:26 +08:00
Gilbert
7d9e350bbe Add option to disconnect client in case acl deny (#2059)
* Add option to disconnect client in case acl deny
2018-12-19 10:34:06 +08:00
turtled
666d9706a3 Fixed conflicts 2018-12-18 16:41:10 +08:00
Feng Lee
721b72b96a Add 'active_n' option to optimize the CPU usage of emqx_connection (#2060)
* Add 'active_n' option to optimize the CPU usage of emqx_connection

* Supports batch processing 'DOWN' events
2018-12-17 19:53:29 +08:00
turtled
34370ef622 Merge branch 'issue#1983' into emqx30 2018-12-14 17:55:36 +08:00
Feng Lee
2a747c9d53 Improve the subscription sharding. 2018-12-12 13:40:01 +08:00
Feng Lee
b279eff181 Add t_mnesia/1 test case 2018-12-12 13:40:01 +08:00
Feng Lee
33830d8120 Improve the design of trie, router and broker modules
1. Add do_add_route/1 do_add_route/2, do_delete_route/1,
do_delete_route/2 APIs in emqx_router module
2. Improve the code of emqx_trie module
3. Update the emqx_broker module to call the new APIs of emqx_router
2018-12-12 13:40:01 +08:00
周子博
ec2e289776 Fix crash in emqx_acl_internal:filter/2 2018-12-10 11:13:25 +08:00
Feng Lee
faac09eac9 Merge subscription sharding 2018-12-10 10:28:01 +08:00
Gilbert Wong
e0eb76afa6 Fix subscription 2018-12-08 16:09:54 +08:00
Feng Lee
bce1ddc5c4 Implement a hash-based subscription sharding 2018-12-06 18:45:07 +08:00
Feng Lee
b4d981daf2 Add a sequence module to generate index for subscription sharding 2018-12-04 15:59:24 +08:00
Gilbert Wong
61030c8d10 Add eunit tests to increase coverage. 2018-12-03 09:15:10 +08:00
Gilbert
295a9d692e
Fix the coverage shaky (#2010) 2018-11-30 19:16:48 +08:00
周子博
ddb9eaef7b Improve test coverage of emqx_metrics 2018-11-30 17:44:29 +08:00
周子博
ea62b15c87 Alter apis provided by emqx_metrics, and use existing timer to commit metrics 2018-11-30 17:44:29 +08:00
周子博
194dbc02c8 Add batch commit for metrics 2018-11-30 17:44:29 +08:00
Feng Lee
21ed012a0c Add an elegant batch module 2018-11-29 10:13:09 +08:00
周子博
5c291ff23e Fix the 'route_batch_delete' config 2018-11-28 16:04:04 +08:00
tigercl
14b8036576 Use username replace id(issue#1737) (#1961)
* Use username replace id(issue#1737)

* Add test case for issue#1737

* Make with_connection/2 support batch connect
2018-11-21 22:51:33 +08:00
spring2maz
a2c658ba19 Add acking mechamism for shared dispatch (#1872)
* Add acking mechamism for shared dispatch

For QoS0 messages, no acking
For QoS1/2 messages, 'ACK' at any of events below:
 - ACK when QoS is downgraded to 0
 - Message is sent to connection process
'NACK' at any of events below:
 - Message queue is full and the receiving session starts to drop old messages
 - The receiving session crash
Upon 'NACK', messages are dispatched to the 'next' subscriber in the group,
depending on the shared subscription dispatch strategy.
2018-11-21 22:49:45 +08:00
Gilbert
16821490ce Fix issue#1874 (#1964)
* Fix issue#1874
Prior to this change, if user use one client connect emqx with mqtt
v3.1.1, the client subscribe the topic and publish message to this
topic, it would receive this message itself published, this commit
provide a configure option to let user ignore the message itself published.

This change fix issue 1874.

* Small Fix

* Fix bug

* Better design

* Fix compile warning and improve coverage

* Better design to solve the performance issue

* Fix typo

* Fix typo

* Delete spaces in end of lines.

* Do not use anonymous function

* Better performance
2018-11-19 13:34:03 +08:00
turtled
faeda253e1 Fix conflicts 2018-11-10 11:44:55 +08:00
terry-xiaoyu
997958aed1 Change the start_link API for emqx_client
Prior to this change, emqx_client:start_link does 2 works in one call:
- init an erlang process for emqx_client
- send MQTT CONNECT to remote broker

But this solution have some drawbacks:

- the return value of `start_link` compiles the return values of the 2
 works: {ok, Pid, MqttResult}. It is inconsistent with the return value
 of `gen_statem:start_link`, may causes confusions.

- the return mode of the 2 works are different:
  `start_link` should always return {ok, Pid} or {error, Reason}, but
 connecting to mqtt may throw out exceptions as it handles the
 socket. But the caller couldn't have thought of the exception, he would
 pattern match on the result of `emqx_client:start_link`, but it crashed!

- If the init work succeed but the connection failed, the caller couldn't
get a Pid from the return value, but indeed it was created inside the
emqx_client. This hides the fact that the Pid was created, and when the
Pid dies, the caller would receive an message from a Pid it doesn' know about.

This change divived these 2 work into 2 APIs:
- `start_link/1` is to build and verify the options, and returns {ok,Pid}
 (on success) or {error, Reason} (on failure).
- `connect/1` is to send MQTT CONNECT, and returns {ok, MQTTResult::properties()} or
 {error, MQTTReason}. MQTT reason codes will contains in the `MQTTReason`.
2018-11-09 17:43:04 +08:00