Merge tag 'upstream/3.5.4'
Upstream version 3.5.4
James Page
8 years ago
95 | 95 | Authors and Copyright are as described below: |
96 | 96 | |
97 | 97 | The Initial Developer of the Original Code is GoPivotal, Inc. |
98 | Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
98 | Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
99 | 99 | |
100 | 100 | |
101 | 101 | MOZILLA PUBLIC LICENSE |
547 | 547 | The Original Code is RabbitMQ. |
548 | 548 | |
549 | 549 | The Initial Developer of the Original Code is GoPivotal, Inc. |
550 | Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.'' | |
550 | Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.'' | |
551 | 551 | |
552 | 552 | [NOTE: The text of this Exhibit A may differ slightly from the text of |
553 | 553 | the notices in the Source Code files of the Original Code. You should |
28 | 28 | ifeq ($(shell python -c 'import simplejson' 2>/dev/null && echo yes),yes) |
29 | 29 | PYTHON=python |
30 | 30 | else |
31 | ifeq ($(shell python2.7 -c 'import json' 2>/dev/null && echo yes),yes) | |
32 | PYTHON=python2.7 | |
33 | else | |
31 | 34 | ifeq ($(shell python2.6 -c 'import simplejson' 2>/dev/null && echo yes),yes) |
32 | 35 | PYTHON=python2.6 |
33 | 36 | else |
36 | 39 | else |
37 | 40 | # Hmm. Missing simplejson? |
38 | 41 | PYTHON=python |
42 | endif | |
39 | 43 | endif |
40 | 44 | endif |
41 | 45 | endif |
225 | 229 | $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \ |
226 | 230 | RABBITMQ_NODE_ONLY=true \ |
227 | 231 | RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \ |
228 | ./scripts/rabbitmq-server | |
232 | ./scripts/rabbitmq-server -detached | |
229 | 233 | |
230 | 234 | run-tests: all |
231 | 235 | echo 'code:add_path("$(TEST_EBIN_DIR)").' | $(ERL_CALL) |
241 | 245 | start-background-node: all |
242 | 246 | -rm -f $(RABBITMQ_MNESIA_DIR).pid |
243 | 247 | mkdir -p $(RABBITMQ_MNESIA_DIR) |
244 | nohup sh -c "$(MAKE) run-background-node > $(RABBITMQ_MNESIA_DIR)/startup_log 2> $(RABBITMQ_MNESIA_DIR)/startup_err" > /dev/null & | |
248 | $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \ | |
249 | RABBITMQ_NODE_ONLY=true \ | |
250 | RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \ | |
251 | ./scripts/rabbitmq-server \ | |
252 | > $(RABBITMQ_MNESIA_DIR)/startup_log \ | |
253 | 2> $(RABBITMQ_MNESIA_DIR)/startup_err & | |
245 | 254 | ./scripts/rabbitmqctl -n $(RABBITMQ_NODENAME) wait $(RABBITMQ_MNESIA_DIR).pid kernel |
246 | 255 | |
247 | 256 | start-rabbit-on-node: all |
10 | 10 | ## The Original Code is RabbitMQ. |
11 | 11 | ## |
12 | 12 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | ## |
15 | 15 | |
16 | 16 | from __future__ import nested_scopes |
105 | 105 | %% The Original Code is RabbitMQ. |
106 | 106 | %% |
107 | 107 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
108 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
108 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
109 | 109 | %%""" |
110 | 110 | |
111 | 111 | def genErl(spec): |
40 | 40 | <cmdsynopsis> |
41 | 41 | <command>rabbitmqctl</command> |
42 | 42 | <arg choice="opt">-n <replaceable>node</replaceable></arg> |
43 | <arg choice="opt">-t <replaceable>timeout</replaceable></arg> | |
43 | 44 | <arg choice="opt">-q</arg> |
44 | 45 | <arg choice="req"><replaceable>command</replaceable></arg> |
45 | 46 | <arg choice="opt" rep="repeat"><replaceable>command options</replaceable></arg> |
91 | 92 | </para> |
92 | 93 | </listitem> |
93 | 94 | </varlistentry> |
95 | <varlistentry> | |
96 | <term><cmdsynopsis><arg choice="opt">-t <replaceable>timeout</replaceable></arg></cmdsynopsis></term> | |
97 | <listitem> | |
98 | <para role="usage"> | |
99 | Operation timeout in seconds. Only applicable to "list" commands. | |
100 | Default is "infinity". | |
101 | </para> | |
102 | </listitem> | |
103 | </varlistentry> | |
94 | 104 | </variablelist> |
95 | 105 | </refsect1> |
96 | 106 | |
575 | 585 | <para> |
576 | 586 | Instructs a synchronising mirrored queue to stop |
577 | 587 | synchronising itself. |
588 | </para> | |
589 | </listitem> | |
590 | </varlistentry> | |
591 | <varlistentry> | |
592 | <term><cmdsynopsis><command>purge_queue</command> <arg choice="req">queue</arg></cmdsynopsis> | |
593 | </term> | |
594 | <listitem> | |
595 | <variablelist> | |
596 | <varlistentry> | |
597 | <term>queue</term> | |
598 | <listitem> | |
599 | <para> | |
600 | The name of the queue to purge. | |
601 | </para> | |
602 | </listitem> | |
603 | </varlistentry> | |
604 | </variablelist> | |
605 | <para> | |
606 | Purges a queue (removes all messages in it). | |
578 | 607 | </para> |
579 | 608 | </listitem> |
580 | 609 | </varlistentry> |
0 | 0 | {application, rabbit, %% -*- erlang -*- |
1 | 1 | [{description, "RabbitMQ"}, |
2 | 2 | {id, "RabbitMQ"}, |
3 | {vsn, "3.5.1"}, | |
3 | {vsn, "3.5.4"}, | |
4 | 4 | {modules, []}, |
5 | 5 | {registered, [rabbit_amqqueue_sup, |
6 | 6 | rabbit_log, |
78 | 78 | mnesia_lib, rpc, mnesia_tm, qlc, sofs, proplists, credit_flow, |
79 | 79 | pmon, ssl_connection, tls_connection, ssl_record, tls_record, |
80 | 80 | gen_fsm, ssl]}, |
81 | {ssl_apps, [asn1, crypto, public_key, ssl]} | |
81 | {ssl_apps, [asn1, crypto, public_key, ssl]}, | |
82 | %% see rabbitmq-server#114 | |
83 | {mirroring_flow_control, true} | |
82 | 84 | ]}]}. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -ifdef(use_specs). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% Passed around most places |
103 | 103 | |
104 | 104 | %%---------------------------------------------------------------------------- |
105 | 105 | |
106 | -define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2014 GoPivotal, Inc."). | |
106 | -define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2015 Pivotal Software, Inc."). | |
107 | 107 | -define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/"). |
108 | 108 | -define(ERTS_MINIMUM, "5.6.3"). |
109 | 109 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -define(NODE_OPT, "-n"). |
17 | 17 | -define(QUIET_OPT, "-q"). |
18 | 18 | -define(VHOST_OPT, "-p"). |
19 | -define(TIMEOUT_OPT, "-t"). | |
19 | 20 | |
20 | 21 | -define(VERBOSE_OPT, "-v"). |
21 | 22 | -define(MINIMAL_OPT, "-m"). |
32 | 33 | -define(NODE_DEF(Node), {?NODE_OPT, {option, Node}}). |
33 | 34 | -define(QUIET_DEF, {?QUIET_OPT, flag}). |
34 | 35 | -define(VHOST_DEF, {?VHOST_OPT, {option, "/"}}). |
36 | -define(TIMEOUT_DEF, {?TIMEOUT_OPT, {option, "infinity"}}). | |
35 | 37 | |
36 | 38 | -define(VERBOSE_DEF, {?VERBOSE_OPT, flag}). |
37 | 39 | -define(MINIMAL_DEF, {?MINIMAL_OPT, flag}). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -include("rabbit.hrl"). |
56 | 56 | |
57 | 57 | VERSION:=0.0.0 |
58 | 58 | |
59 | ifndef VERBOSE | |
60 | QUIET:=@ | |
61 | endif | |
62 | ||
59 | 63 | #---------------------------------- |
60 | 64 | |
61 | 65 | all: |
117 | 121 | #---------------------------------- |
118 | 122 | |
119 | 123 | $(REPOS): |
120 | retries=5; \ | |
121 | while ! git clone $(GIT_CORE_REPOBASE_FETCH)/$@$(GIT_CORE_SUFFIX_FETCH); do \ | |
124 | $(QUIET)retries=5; \ | |
125 | umbrella_branch="$$(git branch | awk '/^\* / { print $$2; }')"; \ | |
126 | if test "$$umbrella_branch" = "stable"; then \ | |
127 | branch_arg="-b $$umbrella_branch"; \ | |
128 | fi; \ | |
129 | while ! git clone $$branch_arg $(GIT_CORE_REPOBASE_FETCH)/$@$(GIT_CORE_SUFFIX_FETCH); do \ | |
122 | 130 | retries=$$((retries - 1)); \ |
123 | 131 | if test "$$retries" = 0; then break; fi; \ |
124 | 132 | sleep 1; \ |
125 | 133 | done |
126 | test -d $@ | |
127 | global_user_name="$$(git config --global user.name)"; \ | |
134 | $(QUIET)test -d $@ | |
135 | $(QUIET)global_user_name="$$(git config --global user.name)"; \ | |
128 | 136 | global_user_email="$$(git config --global user.email)"; \ |
129 | 137 | user_name="$$(git config user.name)"; \ |
130 | 138 | user_email="$$(git config user.email)"; \ |
159 | 167 | sync-gitremote: |
160 | 168 | @for repo in $(REPOS); do \ |
161 | 169 | cd $$repo && \ |
162 | git remote set-url --fetch origin $(GIT_CORE_REPOBASE_FETCH)/$$repo$(GIT_CORE_SUFFIX_FETCH) && \ | |
170 | git remote set-url origin $(GIT_CORE_REPOBASE_FETCH)/$$repo$(GIT_CORE_SUFFIX_FETCH) && \ | |
163 | 171 | git remote set-url --push origin $(GIT_CORE_REPOBASE_PUSH)/$$repo$(GIT_CORE_SUFFIX_PUSH) && \ |
164 | 172 | cd ..; done |
165 | 173 | |
199 | 207 | pull: $(foreach DIR,. $(REPOS),$(DIR)+pull) |
200 | 208 | |
201 | 209 | $(eval $(call repo_targets,. $(REPOS),pull,| %,\ |
202 | (cd % && git pull --ff-only))) | |
210 | (cd % && git fetch -p && \ | |
211 | (! git symbolic-ref -q HEAD || git pull --ff-only)))) | |
203 | 212 | |
204 | 213 | .PHONY: update |
205 | 214 | update: pull |
209 | 218 | |
210 | 219 | $(eval $(call repo_targets,. $(REPOS),named_update,| %,\ |
211 | 220 | (cd % && git fetch -p && git checkout $(BRANCH) && \ |
212 | (test "$$$$(git branch | grep '^*')" = "* (detached from $(BRANCH))" || \ | |
213 | git pull --ff-only)))) | |
221 | (! git symbolic-ref -q HEAD || git pull --ff-only)))) | |
214 | 222 | |
215 | 223 | .PHONY: tag |
216 | 224 | tag: $(foreach DIR,. $(REPOS),$(DIR)+tag) |
309 | 309 | set --offline $$$$(RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \ |
310 | 310 | RABBITMQ_ENABLED_PLUGINS_FILE=$(TEST_TMPDIR)/enabled_plugins \ |
311 | 311 | $(UMBRELLA_BASE_DIR)/rabbitmq-server/scripts/rabbitmq-plugins list -m | tr '\n' ' ') |
312 | RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \ | |
312 | MAKE="$(MAKE)" \ | |
313 | RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \ | |
313 | 314 | RABBITMQ_ENABLED_PLUGINS_FILE=$(TEST_TMPDIR)/enabled_plugins \ |
314 | 315 | RABBITMQ_LOG_BASE=$(TEST_TMPDIR)/log \ |
315 | 316 | RABBITMQ_MNESIA_BASE=$(TEST_TMPDIR)/$(NODENAME) \ |
338 | 339 | | $(ERL_CALL) $(ERL_CALL_OPTS) \ |
339 | 340 | | tee -a $(TEST_TMPDIR)/rabbit-test-output \ |
340 | 341 | | egrep "{ok, (ok|passed)}" >/dev/null &&) \ |
341 | $(foreach SCRIPT,$(WITH_BROKER_TEST_SCRIPTS),$(SCRIPT) &&) : ; \ | |
342 | MAKE="$(MAKE)" RABBITMQ_NODENAME="$(NODENAME)" \ | |
343 | $(foreach SCRIPT,$(WITH_BROKER_TEST_SCRIPTS),$(SCRIPT) &&) : ; \ | |
342 | 344 | then \ |
343 | 345 | touch $(TEST_TMPDIR)/.passed ; \ |
344 | echo "\nPASSED\n" ; \ | |
346 | printf "\nPASSED\n" ; \ | |
345 | 347 | else \ |
346 | 348 | cat $(TEST_TMPDIR)/rabbit-test-output ; \ |
347 | echo "\n\nFAILED\n" ; \ | |
349 | printf "\n\nFAILED\n" ; \ | |
348 | 350 | fi |
349 | 351 | sleep 1 |
350 | 352 | echo "rabbit_misc:report_cover(), init:stop()." | $(ERL_CALL) $(ERL_CALL_OPTS) |
0 | CLIENT_DIR=swiftmq_9_2_5_client | |
1 | CLIENT_PKG=$(CLIENT_DIR).zip | |
0 | CLIENT_DIR=swiftmq_9_7_1_client | |
1 | CLIENT_PKG=$(CLIENT_DIR).tar.gz | |
2 | 2 | |
3 | 3 | .PHONY: test |
4 | 4 | |
7 | 7 | |
8 | 8 | build/lib: $(CLIENT_PKG) |
9 | 9 | mkdir -p build/tmp |
10 | unzip -d build/tmp $(CLIENT_PKG) | |
10 | tar -zx -f $(CLIENT_PKG) -C build/tmp | |
11 | 11 | mkdir -p build/lib |
12 | 12 | mv build/tmp/$(CLIENT_DIR)/jars/*.jar build/lib |
13 | 13 | rm -rf build/tmp |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_ldap). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_ldap_app). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_ldap_util). |
10 | 10 | %% The Original Code is RabbitMQ |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_ldap_test). |
+1
-1
10 | 10 | %% The Original Code is RabbitMQ |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_ldap_unit_test). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_mechanism_ssl_app). |
10 | 10 | # The Original Code is RabbitMQ. |
11 | 11 | # |
12 | 12 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | # |
15 | 15 | |
16 | 16 | VERSION=0.0.0 |
10 | 10 | # The Original Code is RabbitMQ. |
11 | 11 | # |
12 | 12 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | # |
15 | 15 | |
16 | 16 | VERSION=%%VSN%% |
10 | 10 | # The Original Code is RabbitMQ. |
11 | 11 | # |
12 | 12 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | # |
15 | 15 | |
16 | 16 | # The client library can either be built from source control or by downloading |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -ifndef(AMQP_CLIENT_HRL). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -include("amqp_client.hrl"). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -include("amqp_client.hrl"). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -define(QUEUE_PREFIX, "/queue"). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @type close_reason(Type) = {shutdown, amqp_reason(Type)}. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @type close_reason(Type) = {shutdown, amqp_reason(Type)}. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
73 | 73 | {ok, State}; |
74 | 74 | handle_message(closing_timeout, State = #state{closing_reason = Reason}) -> |
75 | 75 | {stop, {closing_timeout, Reason}, State}; |
76 | handle_message({'DOWN', _MRef, process, _ConnSup, shutdown}, State) -> | |
77 | {stop, {shutdown, node_down}, State}; | |
76 | 78 | handle_message({'DOWN', _MRef, process, _ConnSup, Reason}, State) -> |
77 | 79 | {stop, {remote_node_down, Reason}, State}; |
78 | 80 | handle_message(Msg, State) -> |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @doc This module is an implementation of the amqp_gen_consumer |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @doc A behaviour module for implementing consumers for |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
303 | 303 | {<<"version">>, longstr, list_to_binary(Vsn)}, |
304 | 304 | {<<"platform">>, longstr, <<"Erlang">>}, |
305 | 305 | {<<"copyright">>, longstr, |
306 | <<"Copyright (c) 2007-2014 GoPivotal, Inc.">>}, | |
306 | <<"Copyright (c) 2007-2015 Pivotal Software, Inc.">>}, | |
307 | 307 | {<<"information">>, longstr, |
308 | 308 | <<"Licensed under the MPL. " |
309 | 309 | "See http://www.rabbitmq.com/">>}, |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @doc This module allows the simple execution of an asynchronous RPC over |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @doc This is a utility module that is used to expose an arbitrary function |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @doc This module is an implementation of the amqp_gen_consumer |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% @private |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(amqp_uri). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2013-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2013-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_routing_util). |
10 | 10 | # The Original Code is RabbitMQ. |
11 | 11 | # |
12 | 12 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | # |
15 | 15 | |
16 | 16 | TEST_SOURCES=$(wildcard *.erl) |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(amqp_client_SUITE). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(amqp_dbg). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(negative_test_util). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(test_util). |
10 | 10 | # The Original Code is RabbitMQ. |
11 | 11 | # |
12 | 12 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | # |
15 | 15 | |
16 | 16 | IS_SUCCESS:=egrep "(All .+ tests (successful|passed).|Test passed.)" |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -record(upstream, {uris, |
24 | 24 | trust_user_id, |
25 | 25 | ack_mode, |
26 | 26 | ha_policy, |
27 | name}). | |
27 | name, | |
28 | bind_nowait}). | |
28 | 29 | |
29 | 30 | -record(upstream_params, |
30 | 31 | {uri, |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_app). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_db). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_event). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% TODO rename this |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_exchange_link). |
273 | 273 | |
274 | 274 | bind_cmd(Type, #binding{key = Key, args = Args}, |
275 | 275 | State = #state{internal_exchange = IntXNameBin, |
276 | upstream_params = UpstreamParams}) -> | |
276 | upstream_params = UpstreamParams, | |
277 | upstream = Upstream}) -> | |
277 | 278 | #upstream_params{x_or_q = X} = UpstreamParams, |
279 | #upstream{bind_nowait = Nowait} = Upstream, | |
278 | 280 | case update_binding(Args, State) of |
279 | 281 | ignore -> ignore; |
280 | NewArgs -> bind_cmd0(Type, name(X), IntXNameBin, Key, NewArgs) | |
282 | NewArgs -> bind_cmd0(Type, name(X), IntXNameBin, Key, NewArgs, Nowait) | |
281 | 283 | end. |
282 | 284 | |
283 | bind_cmd0(bind, Source, Destination, RoutingKey, Arguments) -> | |
285 | bind_cmd0(bind, Source, Destination, RoutingKey, Arguments, Nowait) -> | |
284 | 286 | #'exchange.bind'{source = Source, |
285 | 287 | destination = Destination, |
286 | 288 | routing_key = RoutingKey, |
287 | arguments = Arguments}; | |
288 | ||
289 | bind_cmd0(unbind, Source, Destination, RoutingKey, Arguments) -> | |
289 | arguments = Arguments, | |
290 | nowait = Nowait}; | |
291 | ||
292 | bind_cmd0(unbind, Source, Destination, RoutingKey, Arguments, Nowait) -> | |
290 | 293 | #'exchange.unbind'{source = Source, |
291 | 294 | destination = Destination, |
292 | 295 | routing_key = RoutingKey, |
293 | arguments = Arguments}. | |
296 | arguments = Arguments, | |
297 | nowait = Nowait}. | |
294 | 298 | |
295 | 299 | %% This function adds information about the current node to the |
296 | 300 | %% binding arguments, or returns 'ignore' if it determines the binding |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_exchange_link_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_link_sup). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_link_util). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_parameters). |
90 | 90 | {<<"trust-user-id">>, fun rabbit_parameter_validation:boolean/2, optional}, |
91 | 91 | {<<"ack-mode">>, rabbit_parameter_validation:enum( |
92 | 92 | ['no-ack', 'on-publish', 'on-confirm']), optional}, |
93 | {<<"ha-policy">>, fun rabbit_parameter_validation:binary/2, optional}]. | |
93 | {<<"ha-policy">>, fun rabbit_parameter_validation:binary/2, optional}, | |
94 | {<<"bind-nowait">>, fun rabbit_parameter_validation:boolean/2, optional}]. | |
94 | 95 | |
95 | 96 | validate_uri(Name, Term) when is_binary(Term) -> |
96 | 97 | case rabbit_parameter_validation:binary(Name, Term) of |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_queue). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_queue_link). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_queue_link_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_status). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_sup). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_upstream). |
130 | 130 | binary_to_list( |
131 | 131 | bget('ack-mode', US, U, <<"on-confirm">>))), |
132 | 132 | ha_policy = bget('ha-policy', US, U, none), |
133 | name = Name}. | |
133 | name = Name, | |
134 | bind_nowait = bget('bind-nowait', US, U, false)}. | |
134 | 135 | |
135 | 136 | %%---------------------------------------------------------------------------- |
136 | 137 |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_upstream_exchange). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_util). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_exchange_test). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_queue_test). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_test_util). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_unit_test). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_federation_mgmt). |
446 | 446 | The Original Code is RabbitMQ Management Plugin. |
447 | 447 | |
448 | 448 | The Initial Developer of the Original Code is GoPivotal, Inc. |
449 | Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.'' | |
449 | Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.'' | |
450 | 450 | |
451 | 451 | [NOTE: The text of this Exhibit A may differ slightly from the text of |
452 | 452 | the notices in the Source Code files of the Original Code. You should |
12 | 12 | # The Original Code is RabbitMQ Management Plugin. |
13 | 13 | # |
14 | 14 | # The Initial Developer of the Original Code is GoPivotal, Inc. |
15 | # Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
15 | # Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
16 | 16 | |
17 | 17 | import sys |
18 | 18 | if sys.version_info[0] < 2 or (sys.version_info[0] == 2 and sys.version_info[1] < 6): |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -record(context, {user, password = none}). |
11 | 11 | %> |
12 | 12 | <p class="status-error"> |
13 | 13 | Network partition detected<br/><br/> |
14 | Mnesia reports that this RabbitMQ cluster has experienced a network partition. This is a dangerous situation. RabbitMQ clusters should not be installed on networks which can experience partitions. | |
14 | Mnesia reports that this RabbitMQ cluster has experienced a | |
15 | network partition. There is a risk of losing data. Please read | |
16 | <a href="http://www.rabbitmq.com/partitions.html">RabbitMQ | |
17 | documentation about network partitions and the possible solutions</a>. | |
15 | 18 | </p> |
16 | 19 | <p> |
17 | 20 | The nature of the partition is as follows: |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_app). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_db). |
743 | 743 | end. |
744 | 744 | |
745 | 745 | append_sample(Key, Val, NewMS, OldStats, Id, Agg, State) when is_number(Val) -> |
746 | record_sample( | |
747 | Id, {Key, Val - pget(Key, OldStats, 0), NewMS, State}, Agg, State); | |
748 | ||
746 | OldVal = case pget(Key, OldStats, 0) of | |
747 | N when is_number(N) -> N; | |
748 | _ -> 0 | |
749 | end, | |
750 | record_sample(Id, {Key, Val - OldVal, NewMS, State}, Agg, State), | |
751 | ok; | |
749 | 752 | append_sample(_Key, _Value, _NewMS, _OldStats, _Id, _Agg, _State) -> |
750 | 753 | ok. |
751 | 754 |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_dispatcher). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_extension). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_format). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_load_definitions). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2013 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% When management extensions are enabled and/or disabled at runtime, the |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_sup). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_util). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_aliveness_test). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_binding). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_bindings). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_channel). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_channels). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_cluster_name). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_connection). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_connection_channels). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_connections). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | |
15 | 15 | -module(rabbit_mgmt_wm_consumers). |
16 | 16 |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_definitions). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_exchange). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_exchange_publish). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_exchanges). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_extensions). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_node). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_nodes). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_overview). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_parameter). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_parameters). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_permission). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_permissions). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_permissions_user). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_permissions_vhost). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_policies). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_policy). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_queue). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_queue_get). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_queue_purge). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_queues). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_user). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_users). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_vhost). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_vhosts). |
10 | 10 | %% The Original Code is RabbitMQ Management Plugin. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_wm_whoami). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_test_db). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_test_http). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_test_unit). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_agent_app). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_agent_sup). |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_db_handler). |
41 | 41 | gc() -> |
42 | 42 | erlang:garbage_collect(whereis(rabbit_event)). |
43 | 43 | |
44 | %% some people have reasons to only run with the agent enabled: | |
45 | %% make it possible for them to configure key management app | |
46 | %% settings such as rates_mode. | |
47 | get_management_env(Key) -> | |
48 | rabbit_misc:get_env( | |
49 | rabbitmq_management, Key, | |
50 | rabbit_misc:get_env(rabbitmq_management_agent, Key, undefined)). | |
51 | ||
44 | 52 | rates_mode() -> |
45 | case application:get_env(rabbitmq_management, rates_mode) of | |
46 | {ok, Mode} -> Mode; | |
47 | _ -> basic | |
53 | case get_management_env(rates_mode) of | |
54 | undefined -> basic; | |
55 | Mode -> Mode | |
56 | end. | |
57 | ||
58 | handle_force_fine_statistics() -> | |
59 | case get_management_env(force_fine_statistics) of | |
60 | undefined -> | |
61 | ok; | |
62 | X -> | |
63 | rabbit_log:warning( | |
64 | "force_fine_statistics set to ~p; ignored.~n" | |
65 | "Replaced by {rates_mode, none} in the rabbitmq_management " | |
66 | "application.~n", [X]) | |
48 | 67 | end. |
49 | 68 | |
50 | 69 | %%---------------------------------------------------------------------------- |
51 | 70 | |
52 | 71 | ensure_statistics_enabled() -> |
53 | 72 | ForceStats = rates_mode() =/= none, |
54 | case application:get_env(rabbitmq_management_agent, | |
55 | force_fine_statistics) of | |
56 | {ok, X} -> | |
57 | rabbit_log:warning( | |
58 | "force_fine_statistics set to ~p; ignored.~n" | |
59 | "Replaced by {rates_mode, none} in the rabbitmq_management " | |
60 | "application.~n", [X]); | |
61 | undefined -> | |
62 | ok | |
63 | end, | |
73 | handle_force_fine_statistics(), | |
64 | 74 | {ok, StatsLevel} = application:get_env(rabbit, collect_statistics), |
75 | rabbit_log:info("Management plugin: using rates mode '~p'~n", [rates_mode()]), | |
65 | 76 | case {ForceStats, StatsLevel} of |
66 | 77 | {true, fine} -> |
67 | 78 | ok; |
10 | 10 | %% The Original Code is RabbitMQ Management Console. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mgmt_external_stats). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -define(CLIENT_ID_MAXLEN, 23). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -define(PROTOCOL_NAMES, [{3, "MQIsdp"}, {4, "MQTT"}]). |
9 | 9 | rm -rf $(PACKAGE_DIR)/test/certs |
10 | 10 | mkdir $(PACKAGE_DIR)/test/certs |
11 | 11 | mkdir -p $(PACKAGE_DIR)/test/ebin |
12 | sed -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config | |
13 | make -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=bunnychow DIR=$(abspath $(PACKAGE_DIR))/test/certs | |
12 | sed -E -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config | |
13 | $(MAKE) -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=bunnychow DIR=$(abspath $(PACKAGE_DIR))/test/certs | |
14 | 14 | |
15 | 15 | $(PACKAGE_DIR)+clean:: |
16 | 16 | rm -rf $(PACKAGE_DIR)/test/certs |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_collector). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_connection_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_frame). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_processor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_reader). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_sup). |
31 | 31 | = case SslListeners0 of |
32 | 32 | [] -> {none, []}; |
33 | 33 | _ -> {rabbit_networking:ensure_ssl(), |
34 | case rabbit_networking:poodle_check('STOMP') of | |
34 | case rabbit_networking:poodle_check('MQTT') of | |
35 | 35 | ok -> SslListeners0; |
36 | 36 | danger -> [] |
37 | 37 | end} |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mqtt_util). |
38 | 38 | |
39 | 39 | .PHONY: build_java_amqp |
40 | 40 | build_java_amqp: $(CHECKOUT_DIR) |
41 | make -C $(JAVA_AMQP_DIR) jar | |
42 | ||
41 | $(MAKE) -C $(JAVA_AMQP_DIR) jar |
10 | 10 | // The Original Code is RabbitMQ. |
11 | 11 | // |
12 | 12 | // The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | // Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | // Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | // |
15 | 15 | |
16 | 16 | package com.rabbitmq.mqtt.test; |
39 | 39 | import java.util.ArrayList; |
40 | 40 | import java.util.Arrays; |
41 | 41 | import java.util.List; |
42 | import java.util.concurrent.TimeoutException; | |
42 | 43 | |
43 | 44 | /*** |
44 | 45 | * MQTT v3.1 tests |
109 | 110 | } catch (Exception _) {} |
110 | 111 | } |
111 | 112 | |
112 | private void setUpAmqp() throws IOException { | |
113 | private void setUpAmqp() throws IOException, TimeoutException { | |
113 | 114 | connectionFactory = new ConnectionFactory(); |
114 | 115 | connectionFactory.setHost(host); |
115 | 116 | conn = connectionFactory.newConnection(); |
376 | 377 | } |
377 | 378 | } |
378 | 379 | |
379 | public void testInteropM2A() throws MqttException, IOException, InterruptedException { | |
380 | public void testInteropM2A() throws MqttException, IOException, InterruptedException, TimeoutException { | |
380 | 381 | setUpAmqp(); |
381 | 382 | String queue = ch.queueDeclare().getQueue(); |
382 | 383 | ch.queueBind(queue, "amq.topic", topic); |
392 | 393 | tearDownAmqp(); |
393 | 394 | } |
394 | 395 | |
395 | public void testInteropA2M() throws MqttException, IOException, InterruptedException { | |
396 | public void testInteropA2M() throws MqttException, IOException, InterruptedException, TimeoutException { | |
396 | 397 | client.connect(conOpt); |
397 | 398 | client.setCallback(this); |
398 | 399 | client.subscribe(topic, 1); |
10 | 10 | // The Original Code is RabbitMQ. |
11 | 11 | // |
12 | 12 | // The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | // Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | // Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | // |
15 | 15 | |
16 | 16 | package com.rabbitmq.mqtt.test.tls; |
0 | 0 | #!/bin/sh |
1 | make -C `dirname $0` build_java_amqp | |
2 | make -C `dirname $0` test | |
1 | $MAKE -C `dirname $0` build_java_amqp | |
2 | $MAKE -C `dirname $0` test |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -record(endpoint, |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_config). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_dyn_worker_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_dyn_worker_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_parameters). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_status). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_util). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_worker). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_worker_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_test). |
10 | 10 | %% The Original Code is RabbitMQ |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_test_all). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_shovel_test_dyn). |
4 | 4 | |
5 | 5 | rabbitmq-plugins enable rabbitmq_stomp |
6 | 6 | |
7 | Binaries for previous versions of the STOMP adapter can be obtained | |
8 | from | |
9 | <http://www.rabbitmq.com/plugins.html#rabbitmq-stomp>. | |
7 | ## Supported STOMP Versions | |
10 | 8 | |
11 | Full usage instructions can be found at | |
12 | <http://www.rabbitmq.com/stomp.html>. | |
9 | 1.0 through 1.2. | |
10 | ||
11 | ## Documentation | |
12 | ||
13 | [RabbitMQ STOMP plugin documentation](http://www.rabbitmq.com/stomp.html). |
0 | UPSTREAM_HG=https://stomppy.googlecode.com/hg/ | |
1 | REVISION=16a4000624a7 | |
0 | UPSTREAM_GIT=https://github.com/jasonrbriggs/stomp.py.git | |
1 | REVISION=v4.0.16 | |
2 | 2 | |
3 | 3 | LIB_DIR=stomppy |
4 | CHECKOUT_DIR=stomppy-hg | |
4 | CHECKOUT_DIR=stomppy-git | |
5 | 5 | |
6 | 6 | TARGETS=$(LIB_DIR) |
7 | 7 | |
13 | 13 | distclean: clean |
14 | 14 | rm -rf $(CHECKOUT_DIR) |
15 | 15 | |
16 | $(LIB_DIR) : $(CHECKOUT_DIR) rabbit.patch | |
16 | $(LIB_DIR) : $(CHECKOUT_DIR) | |
17 | 17 | rm -rf $@ |
18 | 18 | cp -R $< $@ |
19 | cd $@ && patch -p1 < ../rabbit.patch | |
20 | 19 | |
21 | 20 | $(CHECKOUT_DIR): |
22 | hg clone $(UPSTREAM_HG) $@ | |
23 | (cd $@ && hg up $(REVISION)) || rm -rf $@ | |
21 | git clone $(UPSTREAM_GIT) $@ | |
22 | (cd $@ && git checkout $(REVISION)) || rm -rf $@ | |
24 | 23 | |
25 | 24 | echo-revision: |
26 | 25 | @echo $(REVISION) |
0 | diff -r 16a4000624a7 stomp/connect.py | |
1 | --- a/stomp/connect.py Sun May 02 18:15:34 2010 +0100 | |
2 | +++ b/stomp/connect.py Mon Oct 20 19:35:44 2014 +0100 | |
3 | @@ -88,7 +88,10 @@ | |
4 | ssl_key_file = None, | |
5 | ssl_cert_file = None, | |
6 | ssl_ca_certs = None, | |
7 | - ssl_cert_validator = None): | |
8 | + ssl_cert_validator = None, | |
9 | + version = None, | |
10 | + heartbeat = None, | |
11 | + virtual_host = None): | |
12 | """ | |
13 | Initialize and start this connection. | |
14 | ||
15 | @@ -159,6 +162,16 @@ | |
16 | ||
17 | where OK is a boolean, and cert is a certificate structure | |
18 | as returned by ssl.SSLSocket.getpeercert() | |
19 | + | |
20 | + \param version | |
21 | + (optional) stomp version header to send (comma separated) | |
22 | + | |
23 | + \param heartbeat | |
24 | + (optional) heartbeat header to send (STOMP 1.1) | |
25 | + | |
26 | + \param virtual_host | |
27 | + (optional) virtual_host header to send (STOMP 1.1) | |
28 | + | |
29 | """ | |
30 | ||
31 | sorted_host_and_ports = [] | |
32 | @@ -205,6 +218,15 @@ | |
33 | self.__connect_headers['login'] = user | |
34 | self.__connect_headers['passcode'] = passcode | |
35 | ||
36 | + if version is not None: | |
37 | + self.__connect_headers['accept-version'] = version | |
38 | + | |
39 | + if heartbeat is not None: | |
40 | + self.__connect_headers['heart-beat'] = heartbeat | |
41 | + | |
42 | + if virtual_host is not None: | |
43 | + self.__connect_headers['host'] = virtual_host | |
44 | + | |
45 | self.__socket = None | |
46 | self.__socket_semaphore = threading.BoundedSemaphore(1) | |
47 | self.__current_host_and_port = None | |
48 | @@ -383,6 +405,10 @@ | |
49 | """ | |
50 | self.__send_frame_helper('DISCONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ]) | |
51 | self.__running = False | |
52 | + self.close_socket() | |
53 | + self.__current_host_and_port = None | |
54 | + | |
55 | + def close_socket(self): | |
56 | if self.__socket is not None: | |
57 | if self.__ssl: | |
58 | # | |
59 | @@ -390,20 +416,23 @@ | |
60 | # | |
61 | try: | |
62 | self.__socket = self.__socket.unwrap() | |
63 | - except Exception: | |
64 | + except Exception as e: | |
65 | # | |
66 | # unwrap seems flaky on Win with the backported ssl mod, so catch any exception and log it | |
67 | # | |
68 | - _, e, _ = sys.exc_info() | |
69 | - log.warn(e) | |
70 | + log.warning("socket unwrap() threw exception: %s" % e) | |
71 | elif hasattr(socket, 'SHUT_RDWR'): | |
72 | - self.__socket.shutdown(socket.SHUT_RDWR) | |
73 | + try: | |
74 | + self.__socket.shutdown(socket.SHUT_RDWR) | |
75 | + except Exception as e: | |
76 | + log.warning("socket shutdown() threw exception: %s" % e) | |
77 | # | |
78 | - # split this into a separate check, because sometimes the socket is nulled between shutdown and this call | |
79 | + # caution, because sometimes the socket is nulled between shutdown and this call | |
80 | # | |
81 | - if self.__socket is not None: | |
82 | + try: | |
83 | self.__socket.close() | |
84 | - self.__current_host_and_port = None | |
85 | + except Exception as e: | |
86 | + log.warning("socket close() threw exception: %s" % e) | |
87 | ||
88 | def __convert_dict(self, payload): | |
89 | """ | |
90 | @@ -449,6 +478,9 @@ | |
91 | raise KeyError("Command %s requires header %r" % (command, required_header_key)) | |
92 | self.__send_frame(command, headers, payload) | |
93 | ||
94 | + def send_frame(self, command, headers={}, payload=''): | |
95 | + self.__send_frame(command, headers, payload) | |
96 | + | |
97 | def __send_frame(self, command, headers={}, payload=''): | |
98 | """ | |
99 | Send a STOMP frame. | |
100 | @@ -638,7 +670,7 @@ | |
101 | cert_validation = ssl.CERT_NONE | |
102 | self.__socket = ssl.wrap_socket(self.__socket, keyfile = self.__ssl_key_file, | |
103 | certfile = self.__ssl_cert_file, cert_reqs = cert_validation, | |
104 | - ca_certs=self.__ssl_ca_certs, ssl_version = ssl.PROTOCOL_SSLv3) | |
105 | + ca_certs=self.__ssl_ca_certs, ssl_version = ssl.PROTOCOL_TLSv1) | |
106 | self.__socket.settimeout(None) | |
107 | if self.blocking is not None: | |
108 | self.__socket.setblocking(self.blocking) | |
109 | @@ -680,4 +712,4 @@ | |
110 | sleep_exp += 1 | |
111 | ||
112 | if not self.__socket: | |
113 | - raise exception.ReconnectFailedException | |
114 | \ No newline at end of file | |
115 | + raise exception.ReconnectFailedException |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -record(stomp_configuration, {default_login, |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -record(stomp_frame, {command, headers, body_iolist}). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -define(HEADER_ACCEPT_VERSION, "accept-version"). |
0 | 0 | RELEASABLE:=true |
1 | 1 | DEPS:=rabbitmq-server rabbitmq-erlang-client rabbitmq-test |
2 | STANDALONE_TEST_COMMANDS:=eunit:test([rabbit_stomp_test_util,rabbit_stomp_test_frame],[verbose]) | |
2 | #STANDALONE_TEST_COMMANDS:=eunit:test([rabbit_stomp_test_util,rabbit_stomp_test_frame],[verbose]) | |
3 | 3 | WITH_BROKER_TEST_SCRIPTS:=$(PACKAGE_DIR)/test/src/test.py $(PACKAGE_DIR)/test/src/test_connect_options.py $(PACKAGE_DIR)/test/src/test_ssl.py |
4 | WITH_BROKER_TEST_COMMANDS:=rabbit_stomp_test:all_tests() rabbit_stomp_amqqueue_test:all_tests() | |
4 | #WITH_BROKER_TEST_COMMANDS:=rabbit_stomp_test:all_tests() rabbit_stomp_amqqueue_test:all_tests() | |
5 | 5 | WITH_BROKER_TEST_CONFIG:=$(PACKAGE_DIR)/test/ebin/test |
6 | 6 | |
7 | 7 | define package_rules |
11 | 11 | mkdir $(PACKAGE_DIR)/test/certs |
12 | 12 | mkdir -p $(PACKAGE_DIR)/test/ebin |
13 | 13 | sed -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config |
14 | make -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=test DIR=$(abspath $(PACKAGE_DIR))/test/certs | |
15 | make -C $(PACKAGE_DIR)/deps/stomppy | |
14 | $(MAKE) -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=test DIR=$(abspath $(PACKAGE_DIR))/test/certs | |
15 | $(MAKE) -C $(PACKAGE_DIR)/deps/stomppy | |
16 | 16 | |
17 | 17 | $(PACKAGE_DIR)+clean:: |
18 | 18 | rm -rf $(PACKAGE_DIR)/test/certs |
19 | 19 | |
20 | 20 | $(PACKAGE_DIR)+clean-with-deps:: |
21 | make -C $(PACKAGE_DIR)/deps/stomppy distclean | |
21 | $(MAKE) -C $(PACKAGE_DIR)/deps/stomppy distclean | |
22 | 22 | |
23 | 23 | endef |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_client_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% stomp_frame implements the STOMP framing protocol "version 1.0", as |
150 | 150 | false -> [{Name, Value} | Headers] |
151 | 151 | end. |
152 | 152 | |
153 | parse_body(Content, Frame) -> | |
154 | parse_body(Content, Frame, [], | |
155 | integer_header(Frame, ?HEADER_CONTENT_LENGTH, unknown)). | |
153 | parse_body(Content, Frame = #stomp_frame{command = Command}) -> | |
154 | case Command of | |
155 | "SEND" -> parse_body(Content, Frame, [], integer_header(Frame, ?HEADER_CONTENT_LENGTH, unknown)); | |
156 | _ -> parse_body(Content, Frame, [], unknown) | |
157 | end. | |
156 | 158 | |
157 | 159 | parse_body(Content, Frame, Chunks, unknown) -> |
158 | 160 | parse_body2(Content, Frame, Chunks, case firstnull(Content) of |
230 | 232 | Len > 0 -> [?HEADER_CONTENT_LENGTH ++ ":", integer_to_list(Len), ?LF]; |
231 | 233 | true -> [] |
232 | 234 | end, |
233 | ?LF, BodyFragments, 0]. | |
235 | ?LF, BodyFragments, 0, ?LF]. | |
234 | 236 | |
235 | 237 | serialize_header({K, V}) when is_integer(V) -> hdr(escape(K), integer_to_list(V)); |
236 | 238 | serialize_header({K, V}) when is_list(V) -> hdr(escape(K), escape(V)). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_processor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_reader). |
73 | 73 | catch _:Ex -> |
74 | 74 | log_network_error(ConnStr, Ex), |
75 | 75 | rabbit_net:fast_close(Sock), |
76 | rabbit_stomp_processor:flush_and_die(ProcessorPid), | |
76 | 77 | exit(normal) |
77 | 78 | end, |
78 | 79 | done; |
79 | 80 | {error, enotconn} -> |
80 | 81 | rabbit_net:fast_close(Sock0), |
82 | rabbit_stomp_processor:flush_and_die(ProcessorPid), | |
81 | 83 | exit(normal); |
82 | 84 | {error, Reason} -> |
83 | 85 | log_network_error(ConnStr, Reason), |
84 | 86 | rabbit_net:fast_close(Sock0), |
87 | rabbit_stomp_processor:flush_and_die(ProcessorPid), | |
85 | 88 | exit(normal) |
86 | 89 | end |
87 | 90 | end |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_util). |
5 | 5 | class TestAck(base.BaseTest): |
6 | 6 | |
7 | 7 | def test_ack_client(self): |
8 | d = "/queue/ack-test" | |
8 | destination = "/queue/ack-test" | |
9 | 9 | |
10 | 10 | # subscribe and send message |
11 | 11 | self.listener.reset(2) ## expecting 2 messages |
12 | self.conn.subscribe(destination=d, ack='client', | |
12 | self.subscribe_dest(self.conn, destination, None, | |
13 | ack='client', | |
13 | 14 | headers={'prefetch-count': '10'}) |
14 | self.conn.send("test1", destination=d) | |
15 | self.conn.send("test2", destination=d) | |
15 | self.conn.send(destination, "test1") | |
16 | self.conn.send(destination, "test2") | |
16 | 17 | self.assertTrue(self.listener.await(4), "initial message not received") |
17 | 18 | self.assertEquals(2, len(self.listener.messages)) |
18 | 19 | |
25 | 26 | listener2 = base.WaitableListener() |
26 | 27 | listener2.reset(2) |
27 | 28 | conn2.set_listener('', listener2) |
28 | conn2.subscribe(destination=d, ack='client', | |
29 | headers={'prefetch-count': '10'}) | |
29 | self.subscribe_dest(conn2, destination, None, | |
30 | ack='client', | |
31 | headers={'prefetch-count': '10'}) | |
30 | 32 | self.assertTrue(listener2.await(), "message not received again") |
31 | 33 | self.assertEquals(2, len(listener2.messages)) |
32 | 34 | |
33 | 35 | # now ack only the last message - expecting cumulative behaviour |
34 | mid = listener2.messages[1]['headers']['message-id'] | |
35 | conn2.ack({'message-id':mid}) | |
36 | finally: | |
37 | conn2.stop() | |
36 | mid = listener2.messages[1]['headers'][self.ack_id_source_header] | |
37 | self.ack_message(conn2, mid, None) | |
38 | finally: | |
39 | conn2.disconnect() | |
38 | 40 | |
39 | 41 | # now reconnect again, shouldn't see the message |
40 | 42 | conn3 = self.create_connection() |
41 | 43 | try: |
42 | 44 | listener3 = base.WaitableListener() |
43 | 45 | conn3.set_listener('', listener3) |
44 | conn3.subscribe(destination=d) | |
46 | self.subscribe_dest(conn3, destination, None) | |
45 | 47 | self.assertFalse(listener3.await(3), |
46 | 48 | "unexpected message. ACK not working?") |
47 | 49 | finally: |
48 | conn3.stop() | |
50 | conn3.disconnect() | |
49 | 51 | |
50 | 52 | def test_ack_client_individual(self): |
51 | d = "/queue/ack-test-individual" | |
53 | destination = "/queue/ack-test-individual" | |
52 | 54 | |
53 | 55 | # subscribe and send message |
54 | 56 | self.listener.reset(2) ## expecting 2 messages |
55 | self.conn.subscribe(destination=d, ack='client-individual', | |
57 | self.subscribe_dest(self.conn, destination, None, | |
58 | ack='client-individual', | |
56 | 59 | headers={'prefetch-count': '10'}) |
57 | self.conn.send("test1", destination=d) | |
58 | self.conn.send("test2", destination=d) | |
60 | self.conn.send(destination, "test1") | |
61 | self.conn.send(destination, "test2") | |
59 | 62 | self.assertTrue(self.listener.await(4), "Both initial messages not received") |
60 | 63 | self.assertEquals(2, len(self.listener.messages)) |
61 | 64 | |
68 | 71 | listener2 = base.WaitableListener() |
69 | 72 | listener2.reset(2) ## expect 2 messages |
70 | 73 | conn2.set_listener('', listener2) |
71 | conn2.subscribe(destination=d, ack='client-individual', | |
72 | headers={'prefetch-count': '10'}) | |
74 | self.subscribe_dest(conn2, destination, None, | |
75 | ack='client-individual', | |
76 | headers={'prefetch-count': '10'}) | |
73 | 77 | self.assertTrue(listener2.await(2.5), "Did not receive 2 messages") |
74 | 78 | self.assertEquals(2, len(listener2.messages), "Not exactly 2 messages received") |
75 | 79 | |
78 | 82 | mid = None |
79 | 83 | for ind in range(nummsgs): |
80 | 84 | if listener2.messages[ind]['message']=="test2": |
81 | mid = listener2.messages[ind]['headers']['message-id'] | |
85 | mid = listener2.messages[ind]['headers'][self.ack_id_source_header] | |
82 | 86 | self.assertEquals(1, ind, 'Expecting test2 to be second message') |
83 | 87 | break |
84 | 88 | self.assertTrue(mid, "Did not find test2 message id.") |
85 | conn2.ack({'message-id':mid}) | |
86 | finally: | |
87 | conn2.stop() | |
89 | self.ack_message(conn2, mid, None) | |
90 | finally: | |
91 | conn2.disconnect() | |
88 | 92 | |
89 | 93 | # now reconnect again, shouldn't see the message |
90 | 94 | conn3 = self.create_connection() |
92 | 96 | listener3 = base.WaitableListener() |
93 | 97 | listener3.reset(2) ## expecting a single message, but wait for two |
94 | 98 | conn3.set_listener('', listener3) |
95 | conn3.subscribe(destination=d) | |
99 | self.subscribe_dest(conn3, destination, None) | |
96 | 100 | self.assertFalse(listener3.await(2.5), |
97 | 101 | "Expected to see only one message. ACK not working?") |
98 | 102 | self.assertEquals(1, len(listener3.messages), "Expecting exactly one message") |
99 | 103 | self.assertEquals("test1", listener3.messages[0]['message'], "Unexpected message remains") |
100 | 104 | finally: |
101 | conn3.stop() | |
105 | conn3.disconnect() | |
102 | 106 | |
103 | 107 | def test_ack_client_tx(self): |
104 | d = "/queue/ack-test-tx" | |
108 | destination = "/queue/ack-test-tx" | |
105 | 109 | |
106 | 110 | # subscribe and send message |
107 | 111 | self.listener.reset() |
108 | self.conn.subscribe(destination=d, ack='client') | |
109 | self.conn.send("test", destination=d) | |
112 | self.subscribe_dest(self.conn, destination, None, ack='client') | |
113 | self.conn.send(destination, "test") | |
110 | 114 | self.assertTrue(self.listener.await(3), "initial message not received") |
111 | 115 | self.assertEquals(1, len(self.listener.messages)) |
112 | 116 | |
120 | 124 | listener2 = base.WaitableListener() |
121 | 125 | conn2.set_listener('', listener2) |
122 | 126 | conn2.begin(transaction=tx) |
123 | conn2.subscribe(destination=d, ack='client') | |
127 | self.subscribe_dest(conn2, destination, None, ack='client') | |
124 | 128 | self.assertTrue(listener2.await(), "message not received again") |
125 | 129 | self.assertEquals(1, len(listener2.messages)) |
126 | 130 | |
127 | 131 | # now ack |
128 | mid = listener2.messages[0]['headers']['message-id'] | |
129 | conn2.ack({'message-id':mid, 'transaction':tx}) | |
132 | mid = listener2.messages[0]['headers'][self.ack_id_source_header] | |
133 | self.ack_message(conn2, mid, None, transaction=tx) | |
130 | 134 | |
131 | 135 | #now commit |
132 | 136 | conn2.commit(transaction=tx) |
133 | 137 | finally: |
134 | conn2.stop() | |
138 | conn2.disconnect() | |
135 | 139 | |
136 | 140 | # now reconnect again, shouldn't see the message |
137 | 141 | conn3 = self.create_connection() |
138 | 142 | try: |
139 | 143 | listener3 = base.WaitableListener() |
140 | 144 | conn3.set_listener('', listener3) |
141 | conn3.subscribe(destination=d) | |
145 | self.subscribe_dest(conn3, destination, None) | |
142 | 146 | self.assertFalse(listener3.await(3), |
143 | 147 | "unexpected message. TX ACK not working?") |
144 | 148 | finally: |
145 | conn3.stop() | |
149 | conn3.disconnect() | |
146 | 150 | |
147 | 151 | def test_topic_prefetch(self): |
148 | d = "/topic/prefetch-test" | |
152 | destination = "/topic/prefetch-test" | |
149 | 153 | |
150 | 154 | # subscribe and send message |
151 | 155 | self.listener.reset(6) ## expect 6 messages |
152 | self.conn.subscribe(destination=d, ack='client', | |
156 | self.subscribe_dest(self.conn, destination, None, | |
157 | ack='client', | |
153 | 158 | headers={'prefetch-count': '5'}) |
154 | 159 | |
155 | 160 | for x in range(10): |
156 | self.conn.send("test" + str(x), destination=d) | |
161 | self.conn.send(destination, "test" + str(x)) | |
157 | 162 | |
158 | 163 | self.assertFalse(self.listener.await(3), |
159 | 164 | "Should not have been able to see 6 messages") |
160 | 165 | self.assertEquals(5, len(self.listener.messages)) |
161 | 166 | |
162 | 167 | def test_nack(self): |
163 | d = "/queue/nack-test" | |
168 | destination = "/queue/nack-test" | |
164 | 169 | |
165 | 170 | #subscribe and send |
166 | self.conn.subscribe(destination=d, ack='client-individual') | |
167 | self.conn.send("nack-test", destination=d) | |
171 | self.subscribe_dest(self.conn, destination, None, | |
172 | ack='client-individual') | |
173 | self.conn.send(destination, "nack-test") | |
168 | 174 | |
169 | 175 | self.assertTrue(self.listener.await(), "Not received message") |
170 | message_id = self.listener.messages[0]['headers']['message-id'] | |
176 | message_id = self.listener.messages[0]['headers'][self.ack_id_source_header] | |
171 | 177 | self.listener.reset() |
172 | 178 | |
173 | self.conn.send_frame("NACK", {"message-id" : message_id}) | |
179 | self.nack_message(self.conn, message_id, None) | |
174 | 180 | self.assertTrue(self.listener.await(), "Not received message after NACK") |
175 | message_id = self.listener.messages[0]['headers']['message-id'] | |
176 | self.conn.ack({'message-id' : message_id}) | |
181 | message_id = self.listener.messages[0]['headers'][self.ack_id_source_header] | |
182 | self.ack_message(self.conn, message_id, None) | |
177 | 183 | |
178 | 184 | def test_nack_multi(self): |
179 | d = "/queue/nack-multi" | |
185 | destination = "/queue/nack-multi" | |
180 | 186 | |
181 | 187 | self.listener.reset(2) |
182 | 188 | |
183 | 189 | #subscribe and send |
184 | self.conn.subscribe(destination=d, ack='client', | |
190 | self.subscribe_dest(self.conn, destination, None, | |
191 | ack='client', | |
185 | 192 | headers = {'prefetch-count' : '10'}) |
186 | self.conn.send("nack-test1", destination=d) | |
187 | self.conn.send("nack-test2", destination=d) | |
193 | self.conn.send(destination, "nack-test1") | |
194 | self.conn.send(destination, "nack-test2") | |
188 | 195 | |
189 | 196 | self.assertTrue(self.listener.await(), "Not received messages") |
190 | message_id = self.listener.messages[1]['headers']['message-id'] | |
197 | message_id = self.listener.messages[1]['headers'][self.ack_id_source_header] | |
191 | 198 | self.listener.reset(2) |
192 | 199 | |
193 | self.conn.send_frame("NACK", {"message-id" : message_id}) | |
200 | self.nack_message(self.conn, message_id, None) | |
194 | 201 | self.assertTrue(self.listener.await(), "Not received message again") |
195 | message_id = self.listener.messages[1]['headers']['message-id'] | |
196 | self.conn.ack({'message-id' : message_id}) | |
202 | message_id = self.listener.messages[1]['headers'][self.ack_id_source_header] | |
203 | self.ack_message(self.conn, message_id, None) | |
197 | 204 | |
198 | 205 | def test_nack_without_requeueing(self): |
199 | d = "/queue/nack-test-no-requeue" | |
200 | ||
201 | self.conn.subscribe(destination=d, ack='client-individual') | |
202 | self.conn.send("nack-test", destination=d) | |
206 | destination = "/queue/nack-test-no-requeue" | |
207 | ||
208 | self.subscribe_dest(self.conn, destination, None, | |
209 | ack='client-individual') | |
210 | self.conn.send(destination, "nack-test") | |
203 | 211 | |
204 | 212 | self.assertTrue(self.listener.await(), "Not received message") |
205 | message_id = self.listener.messages[0]['headers']['message-id'] | |
213 | message_id = self.listener.messages[0]['headers'][self.ack_id_source_header] | |
206 | 214 | self.listener.reset() |
207 | 215 | |
208 | self.conn.send_frame("NACK", {"message-id" : message_id, "requeue": False}) | |
216 | self.conn.send_frame("NACK", {self.ack_id_header: message_id, "requeue": False}) | |
209 | 217 | self.assertFalse(self.listener.await(4), "Received message after NACK with requeue = False") |
5 | 5 | |
6 | 6 | class BaseTest(unittest.TestCase): |
7 | 7 | |
8 | def create_connection(self, version=None, heartbeat=None): | |
9 | conn = stomp.Connection(user="guest", passcode="guest", | |
10 | version=version, heartbeat=heartbeat) | |
8 | def create_connection_obj(self, version='1.0', vhost='/', heartbeats=(0, 0)): | |
9 | if version == '1.0': | |
10 | conn = stomp.StompConnection10() | |
11 | self.ack_id_source_header = 'message-id' | |
12 | self.ack_id_header = 'message-id' | |
13 | elif version == '1.1': | |
14 | conn = stomp.StompConnection11(vhost=vhost, | |
15 | heartbeats=heartbeats) | |
16 | self.ack_id_source_header = 'message-id' | |
17 | self.ack_id_header = 'message-id' | |
18 | elif version == '1.2': | |
19 | conn = stomp.StompConnection12(vhost=vhost, | |
20 | heartbeats=heartbeats) | |
21 | self.ack_id_source_header = 'ack' | |
22 | self.ack_id_header = 'id' | |
23 | else: | |
24 | conn = stomp.StompConnection12(vhost=vhost, | |
25 | heartbeats=heartbeats) | |
26 | conn.version = version | |
27 | return conn | |
28 | ||
29 | def create_connection(self, user='guest', passcode='guest', wait=True, **kwargs): | |
30 | conn = self.create_connection_obj(**kwargs) | |
11 | 31 | conn.start() |
12 | conn.connect() | |
32 | conn.connect(user, passcode, wait=wait) | |
13 | 33 | return conn |
34 | ||
35 | def subscribe_dest(self, conn, destination, sub_id, **kwargs): | |
36 | if type(conn) is stomp.StompConnection10: | |
37 | # 'id' is optional in STOMP 1.0. | |
38 | if sub_id != None: | |
39 | kwargs['id'] = sub_id | |
40 | conn.subscribe(destination, **kwargs) | |
41 | else: | |
42 | # 'id' is required in STOMP 1.1+. | |
43 | if sub_id == None: | |
44 | sub_id = 'ctag' | |
45 | conn.subscribe(destination, sub_id, **kwargs) | |
46 | ||
47 | def unsubscribe_dest(self, conn, destination, sub_id, **kwargs): | |
48 | if type(conn) is stomp.StompConnection10: | |
49 | # 'id' is optional in STOMP 1.0. | |
50 | if sub_id != None: | |
51 | conn.unsubscribe(id=sub_id, **kwargs) | |
52 | else: | |
53 | conn.unsubscribe(destination=destination, **kwargs) | |
54 | else: | |
55 | # 'id' is required in STOMP 1.1+. | |
56 | if sub_id == None: | |
57 | sub_id = 'ctag' | |
58 | conn.unsubscribe(sub_id, **kwargs) | |
59 | ||
60 | def ack_message(self, conn, msg_id, sub_id, **kwargs): | |
61 | if type(conn) is stomp.StompConnection10: | |
62 | conn.ack(msg_id, **kwargs) | |
63 | elif type(conn) is stomp.StompConnection11: | |
64 | if sub_id == None: | |
65 | sub_id = 'ctag' | |
66 | conn.ack(msg_id, sub_id, **kwargs) | |
67 | elif type(conn) is stomp.StompConnection12: | |
68 | conn.ack(msg_id, **kwargs) | |
69 | ||
70 | def nack_message(self, conn, msg_id, sub_id, **kwargs): | |
71 | if type(conn) is stomp.StompConnection10: | |
72 | # Normally unsupported by STOMP 1.0. | |
73 | conn.send_frame("NACK", {"message-id": msg_id}) | |
74 | elif type(conn) is stomp.StompConnection11: | |
75 | if sub_id == None: | |
76 | sub_id = 'ctag' | |
77 | conn.nack(msg_id, sub_id, **kwargs) | |
78 | elif type(conn) is stomp.StompConnection12: | |
79 | conn.nack(msg_id, **kwargs) | |
14 | 80 | |
15 | 81 | def create_subscriber_connection(self, dest): |
16 | 82 | conn = self.create_connection() |
17 | 83 | listener = WaitableListener() |
18 | 84 | conn.set_listener('', listener) |
19 | conn.subscribe(destination=dest, receipt="sub.receipt") | |
85 | self.subscribe_dest(conn, dest, None, receipt="sub.receipt") | |
20 | 86 | listener.await() |
21 | 87 | self.assertEquals(1, len(listener.receipts)) |
22 | 88 | listener.reset() |
29 | 95 | |
30 | 96 | def tearDown(self): |
31 | 97 | if self.conn.is_connected(): |
98 | self.conn.disconnect() | |
32 | 99 | self.conn.stop() |
33 | 100 | |
34 | 101 | def simple_test_send_rec(self, dest, route = None): |
35 | 102 | self.listener.reset() |
36 | 103 | |
37 | self.conn.subscribe(destination=dest) | |
38 | self.conn.send("foo", destination=dest) | |
104 | self.subscribe_dest(self.conn, dest, None) | |
105 | self.conn.send(dest, "foo") | |
39 | 106 | |
40 | 107 | self.assertTrue(self.listener.await(), "Timeout, no message received") |
41 | 108 |
13 | 13 | new_conn.set_listener('', listener) |
14 | 14 | |
15 | 15 | new_conn.start() # not going to issue connect |
16 | new_conn.subscribe(destination="/topic/implicit", id='sub_implicit', receipt='implicit') | |
16 | self.subscribe_dest(new_conn, "/topic/implicit", 'sub_implicit', | |
17 | receipt='implicit') | |
17 | 18 | |
18 | 19 | try: |
19 | 20 | self.assertTrue(listener.await(5)) |
24 | 24 | def test_invalid_exchange(self): |
25 | 25 | ''' Test invalid exchange error ''' |
26 | 26 | self.listener.reset(1) |
27 | self.conn.subscribe(destination="/exchange/does.not.exist") | |
27 | self.subscribe_dest(self.conn, "/exchange/does.not.exist", None, | |
28 | ack="auto") | |
28 | 29 | self.assertListener("Expecting an error", numErrs=1) |
29 | 30 | err = self.listener.errors[0] |
30 | 31 | self.assertEquals("not_found", err['headers']['message']) |
48 | 49 | |
49 | 50 | def test_send_receive(self): |
50 | 51 | ''' Test basic send/receive for /queue ''' |
51 | d = '/queue/test' | |
52 | self.simple_test_send_rec(d) | |
52 | destination = '/queue/test' | |
53 | self.simple_test_send_rec(destination) | |
53 | 54 | |
54 | 55 | def test_send_receive_in_other_conn(self): |
55 | 56 | ''' Test send in one connection, receive in another ''' |
56 | d = '/queue/test2' | |
57 | destination = '/queue/test2' | |
57 | 58 | |
58 | 59 | # send |
59 | self.conn.send("hello", destination=d) | |
60 | self.conn.send(destination, "hello") | |
60 | 61 | |
61 | 62 | # now receive |
62 | 63 | conn2 = self.create_connection() |
64 | 65 | listener2 = base.WaitableListener() |
65 | 66 | conn2.set_listener('', listener2) |
66 | 67 | |
67 | conn2.subscribe(destination=d) | |
68 | self.subscribe_dest(conn2, destination, None, ack="auto") | |
68 | 69 | self.assertTrue(listener2.await(10), "no receive") |
69 | 70 | finally: |
70 | conn2.stop() | |
71 | conn2.disconnect() | |
71 | 72 | |
72 | 73 | def test_send_receive_in_other_conn_with_disconnect(self): |
73 | 74 | ''' Test send, disconnect, receive ''' |
74 | d = '/queue/test3' | |
75 | destination = '/queue/test3' | |
75 | 76 | |
76 | 77 | # send |
77 | self.conn.send("hello thar", destination=d, receipt="foo") | |
78 | self.conn.send(destination, "hello thar", receipt="foo") | |
78 | 79 | self.listener.await(3) |
79 | self.conn.stop() | |
80 | self.conn.disconnect() | |
80 | 81 | |
81 | 82 | # now receive |
82 | 83 | conn2 = self.create_connection() |
84 | 85 | listener2 = base.WaitableListener() |
85 | 86 | conn2.set_listener('', listener2) |
86 | 87 | |
87 | conn2.subscribe(destination=d) | |
88 | self.subscribe_dest(conn2, destination, None, ack="auto") | |
88 | 89 | self.assertTrue(listener2.await(10), "no receive") |
89 | 90 | finally: |
90 | conn2.stop() | |
91 | conn2.disconnect() | |
91 | 92 | |
92 | 93 | |
93 | 94 | def test_multi_subscribers(self): |
94 | 95 | ''' Test multiple subscribers against a single /queue destination ''' |
95 | d = '/queue/test-multi' | |
96 | destination = '/queue/test-multi' | |
96 | 97 | |
97 | 98 | ## set up two subscribers |
98 | conn1, listener1 = self.create_subscriber_connection(d) | |
99 | conn2, listener2 = self.create_subscriber_connection(d) | |
99 | conn1, listener1 = self.create_subscriber_connection(destination) | |
100 | conn2, listener2 = self.create_subscriber_connection(destination) | |
100 | 101 | |
101 | 102 | try: |
102 | 103 | ## now send |
103 | self.conn.send("test1", destination=d) | |
104 | self.conn.send("test2", destination=d) | |
104 | self.conn.send(destination, "test1") | |
105 | self.conn.send(destination, "test2") | |
105 | 106 | |
106 | 107 | ## expect both consumers to get a message? |
107 | 108 | self.assertTrue(listener1.await(2)) |
111 | 112 | self.assertEquals(1, len(listener2.messages), |
112 | 113 | "unexpected message count") |
113 | 114 | finally: |
114 | conn1.stop() | |
115 | conn2.stop() | |
115 | conn1.disconnect() | |
116 | conn2.disconnect() | |
116 | 117 | |
117 | 118 | def test_send_with_receipt(self): |
118 | d = '/queue/test-receipt' | |
119 | destination = '/queue/test-receipt' | |
119 | 120 | def noop(): pass |
120 | self.__test_send_receipt(d, noop, noop) | |
121 | self.__test_send_receipt(destination, noop, noop) | |
121 | 122 | |
122 | 123 | def test_send_with_receipt_tx(self): |
123 | d = '/queue/test-receipt-tx' | |
124 | destination = '/queue/test-receipt-tx' | |
124 | 125 | tx = 'receipt.tx' |
125 | 126 | |
126 | 127 | def before(): |
130 | 131 | self.assertFalse(self.listener.await(1)) |
131 | 132 | self.conn.commit(transaction=tx) |
132 | 133 | |
133 | self.__test_send_receipt(d, before, after, {'transaction': tx}) | |
134 | self.__test_send_receipt(destination, before, after, {'transaction': tx}) | |
134 | 135 | |
135 | 136 | def test_interleaved_receipt_no_receipt(self): |
136 | 137 | ''' Test i-leaved receipt/no receipt, no-r bracketed by rs ''' |
137 | 138 | |
138 | d = '/queue/ir' | |
139 | destination = '/queue/ir' | |
139 | 140 | |
140 | 141 | self.listener.reset(5) |
141 | 142 | |
142 | self.conn.subscribe(destination=d) | |
143 | self.conn.send('first', destination=d, receipt='a') | |
144 | self.conn.send('second', destination=d) | |
145 | self.conn.send('third', destination=d, receipt='b') | |
143 | self.subscribe_dest(self.conn, destination, None, ack="auto") | |
144 | self.conn.send(destination, 'first', receipt='a') | |
145 | self.conn.send(destination, 'second') | |
146 | self.conn.send(destination, 'third', receipt='b') | |
146 | 147 | |
147 | 148 | self.assertListener("Missing messages/receipts", numMsgs=3, numRcts=2, timeout=3) |
148 | 149 | |
151 | 152 | def test_interleaved_receipt_no_receipt_tx(self): |
152 | 153 | ''' Test i-leaved receipt/no receipt, no-r bracketed by r+xactions ''' |
153 | 154 | |
154 | d = '/queue/ir' | |
155 | destination = '/queue/ir' | |
155 | 156 | tx = 'tx.ir' |
156 | 157 | |
157 | 158 | # three messages and two receipts |
158 | 159 | self.listener.reset(5) |
159 | 160 | |
160 | self.conn.subscribe(destination=d) | |
161 | self.subscribe_dest(self.conn, destination, None, ack="auto") | |
161 | 162 | self.conn.begin(transaction=tx) |
162 | 163 | |
163 | self.conn.send('first', destination=d, receipt='a', transaction=tx) | |
164 | self.conn.send('second', destination=d, transaction=tx) | |
165 | self.conn.send('third', destination=d, receipt='b', transaction=tx) | |
164 | self.conn.send(destination, 'first', receipt='a', transaction=tx) | |
165 | self.conn.send(destination, 'second', transaction=tx) | |
166 | self.conn.send(destination, 'third', receipt='b', transaction=tx) | |
166 | 167 | self.conn.commit(transaction=tx) |
167 | 168 | |
168 | 169 | self.assertListener("Missing messages/receipts", numMsgs=3, numRcts=2, timeout=40) |
175 | 176 | def test_interleaved_receipt_no_receipt_inverse(self): |
176 | 177 | ''' Test i-leaved receipt/no receipt, r bracketed by no-rs ''' |
177 | 178 | |
178 | d = '/queue/ir' | |
179 | destination = '/queue/ir' | |
179 | 180 | |
180 | 181 | self.listener.reset(4) |
181 | 182 | |
182 | self.conn.subscribe(destination=d) | |
183 | self.conn.send('first', destination=d) | |
184 | self.conn.send('second', destination=d, receipt='a') | |
185 | self.conn.send('third', destination=d) | |
183 | self.subscribe_dest(self.conn, destination, None, ack="auto") | |
184 | self.conn.send(destination, 'first') | |
185 | self.conn.send(destination, 'second', receipt='a') | |
186 | self.conn.send(destination, 'third') | |
186 | 187 | |
187 | 188 | self.assertListener("Missing messages/receipt", numMsgs=3, numRcts=1, timeout=3) |
188 | 189 | |
198 | 199 | for x in range(0, count): |
199 | 200 | receipt = "test" + str(x) |
200 | 201 | expected_receipts.add(receipt) |
201 | self.conn.send("test receipt", destination=destination, | |
202 | self.conn.send(destination, "test receipt", | |
202 | 203 | receipt=receipt, headers=headers) |
203 | 204 | after() |
204 | 205 | |
220 | 221 | |
221 | 222 | def test_send_receive(self): |
222 | 223 | ''' Test basic send/receive for /topic ''' |
223 | d = '/topic/test' | |
224 | self.simple_test_send_rec(d) | |
224 | destination = '/topic/test' | |
225 | self.simple_test_send_rec(destination) | |
225 | 226 | |
226 | 227 | def test_send_multiple(self): |
227 | 228 | ''' Test /topic with multiple consumers ''' |
228 | d = '/topic/multiple' | |
229 | destination = '/topic/multiple' | |
229 | 230 | |
230 | 231 | ## set up two subscribers |
231 | conn1, listener1 = self.create_subscriber_connection(d) | |
232 | conn2, listener2 = self.create_subscriber_connection(d) | |
232 | conn1, listener1 = self.create_subscriber_connection(destination) | |
233 | conn2, listener2 = self.create_subscriber_connection(destination) | |
233 | 234 | |
234 | 235 | try: |
235 | 236 | ## listeners are expecting 2 messages |
237 | 238 | listener2.reset(2) |
238 | 239 | |
239 | 240 | ## now send |
240 | self.conn.send("test1", destination=d) | |
241 | self.conn.send("test2", destination=d) | |
241 | self.conn.send(destination, "test1") | |
242 | self.conn.send(destination, "test2") | |
242 | 243 | |
243 | 244 | ## expect both consumers to get both messages |
244 | 245 | self.assertTrue(listener1.await(5)) |
248 | 249 | self.assertEquals(2, len(listener2.messages), |
249 | 250 | "unexpected message count") |
250 | 251 | finally: |
251 | conn1.stop() | |
252 | conn2.stop() | |
252 | conn1.disconnect() | |
253 | conn2.disconnect() | |
254 | ||
255 | def test_send_multiple_with_a_large_message(self): | |
256 | ''' Test /topic with multiple consumers ''' | |
257 | destination = '/topic/16mb' | |
258 | # payload size | |
259 | s = 1024 * 1024 * 16 | |
260 | message = 'x' * s | |
261 | ||
262 | conn1, listener1 = self.create_subscriber_connection(destination) | |
263 | conn2, listener2 = self.create_subscriber_connection(destination) | |
264 | ||
265 | try: | |
266 | listener1.reset(2) | |
267 | listener2.reset(2) | |
268 | ||
269 | self.conn.send(destination, message) | |
270 | self.conn.send(destination, message) | |
271 | ||
272 | self.assertTrue(listener1.await(10)) | |
273 | self.assertEquals(2, len(listener1.messages), | |
274 | "unexpected message count") | |
275 | self.assertTrue(len(listener2.messages[0]['message']) == s, | |
276 | "unexpected message size") | |
277 | ||
278 | self.assertTrue(listener2.await(10)) | |
279 | self.assertEquals(2, len(listener2.messages), | |
280 | "unexpected message count") | |
281 | finally: | |
282 | conn1.disconnect() | |
283 | conn2.disconnect() | |
253 | 284 | |
254 | 285 | class TestReplyQueue(base.BaseTest): |
255 | 286 | |
267 | 298 | conn2, listener2 = self.create_subscriber_connection(known) |
268 | 299 | |
269 | 300 | try: |
270 | self.conn.send("test", destination=known, | |
301 | self.conn.send(known, "test", | |
271 | 302 | headers = {"reply-to": reply}) |
272 | 303 | |
273 | 304 | self.assertTrue(listener2.await(5)) |
276 | 307 | reply_to = listener2.messages[0]['headers']['reply-to'] |
277 | 308 | self.assertTrue(reply_to.startswith('/reply-queue/')) |
278 | 309 | |
279 | conn2.send("reply", destination=reply_to) | |
310 | conn2.send(reply_to, "reply") | |
280 | 311 | self.assertTrue(self.listener.await(5)) |
281 | 312 | self.assertEquals("reply", self.listener.messages[0]['message']) |
282 | 313 | finally: |
283 | conn2.stop() | |
314 | conn2.disconnect() | |
284 | 315 | |
285 | 316 | def test_reuse_reply_queue(self): |
286 | 317 | ''' Test re-use of reply-to queue ''' |
294 | 325 | self.assertEquals(1, len(listna.messages)) |
295 | 326 | reply_to = listna.messages[0]['headers']['reply-to'] |
296 | 327 | self.assertTrue(reply_to.startswith('/reply-queue/')) |
297 | cntn.send("reply", destination=reply_to) | |
328 | cntn.send(reply_to, "reply") | |
298 | 329 | |
299 | 330 | ## Client 1 uses pre-supplied connection and listener |
300 | 331 | ## Set up clients 2 and 3 |
302 | 333 | conn3, listener3 = self.create_subscriber_connection(known3) |
303 | 334 | try: |
304 | 335 | self.listener.reset(2) |
305 | self.conn.send("test2", destination=known2, | |
336 | self.conn.send(known2, "test2", | |
306 | 337 | headers = {"reply-to": reply}) |
307 | self.conn.send("test3", destination=known3, | |
338 | self.conn.send(known3, "test3", | |
308 | 339 | headers = {"reply-to": reply}) |
309 | 340 | respond(conn2, listener2) |
310 | 341 | respond(conn3, listener3) |
314 | 345 | self.assertEquals("reply", self.listener.messages[0]['message']) |
315 | 346 | self.assertEquals("reply", self.listener.messages[1]['message']) |
316 | 347 | finally: |
317 | conn2.stop() | |
318 | conn3.stop() | |
348 | conn2.disconnect() | |
349 | conn3.disconnect() | |
319 | 350 | |
320 | 351 | def test_perm_reply_queue(self): |
321 | 352 | '''As test_reply_queue, but with a non-temp reply queue''' |
329 | 360 | conn2, listener2 = self.create_subscriber_connection(known) |
330 | 361 | |
331 | 362 | try: |
332 | conn1.send("test", destination=known, | |
363 | conn1.send(known, "test", | |
333 | 364 | headers = {"reply-to": reply}) |
334 | 365 | |
335 | 366 | self.assertTrue(listener2.await(5)) |
338 | 369 | reply_to = listener2.messages[0]['headers']['reply-to'] |
339 | 370 | self.assertTrue(reply_to == reply) |
340 | 371 | |
341 | conn2.send("reply", destination=reply_to) | |
372 | conn2.send(reply_to, "reply") | |
342 | 373 | self.assertTrue(listener1.await(5)) |
343 | 374 | self.assertEquals("reply", listener1.messages[0]['message']) |
344 | 375 | finally: |
345 | conn1.stop() | |
346 | conn2.stop() | |
376 | conn1.disconnect() | |
377 | conn2.disconnect() | |
347 | 378 | |
348 | 379 | class TestDurableSubscription(base.BaseTest): |
349 | 380 | |
355 | 386 | if not id: |
356 | 387 | id = TestDurableSubscription.ID |
357 | 388 | |
358 | conn.subscribe(destination=dest, | |
359 | headers ={'persistent': 'true', | |
360 | 'receipt': 1, | |
361 | 'id': id}) | |
389 | self.subscribe_dest(conn, dest, id, ack="auto", | |
390 | headers = {'persistent': 'true', | |
391 | 'receipt': 1}) | |
362 | 392 | |
363 | 393 | def __assert_receipt(self, listener=None, pos=None): |
364 | 394 | if not listener: |
380 | 410 | self.assertEquals(pos, self.listener.messages[0]['msg_no']) |
381 | 411 | |
382 | 412 | def test_durable_subscription(self): |
383 | d = '/topic/durable' | |
384 | ||
385 | self.__subscribe(d) | |
413 | destination = '/topic/durable' | |
414 | ||
415 | self.__subscribe(destination) | |
386 | 416 | self.__assert_receipt() |
387 | 417 | |
388 | 418 | # send first message without unsubscribing |
389 | 419 | self.listener.reset(1) |
390 | self.conn.send("first", destination=d) | |
420 | self.conn.send(destination, "first") | |
391 | 421 | self.__assert_message("first") |
392 | 422 | |
393 | 423 | # now unsubscribe (disconnect only) |
394 | self.conn.unsubscribe(id=TestDurableSubscription.ID) | |
424 | self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID) | |
395 | 425 | |
396 | 426 | # send again |
397 | 427 | self.listener.reset(2) |
398 | self.conn.send("second", destination=d) | |
428 | self.conn.send(destination, "second") | |
399 | 429 | |
400 | 430 | # resubscribe and expect receipt |
401 | self.__subscribe(d) | |
431 | self.__subscribe(destination) | |
402 | 432 | self.__assert_receipt(pos=1) |
403 | 433 | # and message |
404 | 434 | self.__assert_message("second", pos=2) |
405 | 435 | |
406 | 436 | # now unsubscribe (cancel) |
407 | self.conn.unsubscribe(id=TestDurableSubscription.ID, | |
437 | self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID, | |
408 | 438 | headers={'persistent': 'true'}) |
409 | 439 | |
410 | 440 | # send again |
411 | 441 | self.listener.reset(1) |
412 | self.conn.send("third", destination=d) | |
442 | self.conn.send(destination, "third") | |
413 | 443 | |
414 | 444 | # resubscribe and expect no message |
415 | self.__subscribe(d) | |
445 | self.__subscribe(destination) | |
416 | 446 | self.assertTrue(self.listener.await(3)) |
417 | 447 | self.assertEquals(0, len(self.listener.messages)) |
418 | 448 | self.assertEquals(1, len(self.listener.receipts)) |
419 | 449 | |
420 | 450 | def test_share_subscription(self): |
421 | d = '/topic/durable-shared' | |
451 | destination = '/topic/durable-shared' | |
422 | 452 | |
423 | 453 | conn2 = self.create_connection() |
424 | 454 | conn2.set_listener('', self.listener) |
425 | 455 | |
426 | 456 | try: |
427 | self.__subscribe(d) | |
457 | self.__subscribe(destination) | |
428 | 458 | self.__assert_receipt() |
429 | 459 | self.listener.reset(1) |
430 | self.__subscribe(d, conn2) | |
460 | self.__subscribe(destination, conn2) | |
431 | 461 | self.__assert_receipt() |
432 | 462 | |
433 | 463 | self.listener.reset(100) |
434 | 464 | |
435 | 465 | # send 100 messages |
436 | 466 | for x in xrange(0, 100): |
437 | self.conn.send("msg" + str(x), destination=d) | |
467 | self.conn.send(destination, "msg" + str(x)) | |
438 | 468 | |
439 | 469 | self.assertTrue(self.listener.await(5)) |
440 | 470 | self.assertEquals(100, len(self.listener.messages)) |
441 | 471 | finally: |
442 | conn2.stop() | |
472 | conn2.disconnect() | |
443 | 473 | |
444 | 474 | def test_separate_ids(self): |
445 | d = '/topic/durable-separate' | |
475 | destination = '/topic/durable-separate' | |
446 | 476 | |
447 | 477 | conn2 = self.create_connection() |
448 | 478 | listener2 = base.WaitableListener() |
450 | 480 | |
451 | 481 | try: |
452 | 482 | # ensure durable subscription exists for each ID |
453 | self.__subscribe(d) | |
483 | self.__subscribe(destination) | |
454 | 484 | self.__assert_receipt() |
455 | self.__subscribe(d, conn2, "other.id") | |
485 | self.__subscribe(destination, conn2, "other.id") | |
456 | 486 | self.__assert_receipt(listener2) |
457 | self.conn.unsubscribe(id=TestDurableSubscription.ID) | |
458 | conn2.unsubscribe(id="other.id") | |
487 | self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID) | |
488 | self.unsubscribe_dest(conn2, destination, "other.id") | |
459 | 489 | |
460 | 490 | self.listener.reset(101) |
461 | 491 | listener2.reset(101) ## 100 messages and 1 receipt |
462 | 492 | |
463 | 493 | # send 100 messages |
464 | 494 | for x in xrange(0, 100): |
465 | self.conn.send("msg" + str(x), destination=d) | |
466 | ||
467 | self.__subscribe(d) | |
468 | self.__subscribe(d, conn2, "other.id") | |
495 | self.conn.send(destination, "msg" + str(x)) | |
496 | ||
497 | self.__subscribe(destination) | |
498 | self.__subscribe(destination, conn2, "other.id") | |
469 | 499 | |
470 | 500 | for l in [self.listener, listener2]: |
471 | 501 | self.assertTrue(l.await(20)) |
472 | 502 | self.assertEquals(100, len(l.messages)) |
473 | 503 | |
474 | 504 | finally: |
475 | conn2.stop() | |
505 | conn2.disconnect() | |
476 | 506 | |
477 | 507 | def test_durable_subscribe_no_id(self): |
478 | d = '/topic/durable-invalid' | |
479 | ||
480 | self.conn.subscribe(destination=d, headers={'persistent':'true'}), | |
508 | destination = '/topic/durable-invalid' | |
509 | ||
510 | self.conn.send_frame('SUBSCRIBE', | |
511 | {'destination': destination, 'ack': 'auto', 'persistent': 'true'}) | |
481 | 512 | self.listener.await(3) |
482 | 513 | self.assertEquals(1, len(self.listener.errors)) |
483 | 514 | self.assertEquals("Missing Header", self.listener.errors[0]['headers']['message']) |
484 | ||
485 |
27 | 27 | |
28 | 28 | def test_unknown_destination(self): |
29 | 29 | self.listener.reset() |
30 | self.conn.send(destination="/something/interesting") | |
30 | self.conn.send("/something/interesting", 'test_unknown_destination') | |
31 | 31 | |
32 | 32 | self.assertTrue(self.listener.await()) |
33 | 33 | self.assertEquals(1, len(self.listener.errors)) |
53 | 53 | |
54 | 54 | def __test_invalid_destination(self, dtype, content): |
55 | 55 | self.listener.reset() |
56 | self.conn.send(destination="/" + dtype + content) | |
56 | self.conn.send("/" + dtype + content, '__test_invalid_destination:' + dtype + content) | |
57 | 57 | |
58 | 58 | self.assertTrue(self.listener.await()) |
59 | 59 | self.assertEquals(1, len(self.listener.errors)) |
44 | 44 | d = "/queue/unsub04" |
45 | 45 | self.unsub_test(d, self.sub_and_send(d, subid="queid", receipt="unsub.rct"), numRcts=1) |
46 | 46 | |
47 | def test_connect_version_1_0(self): | |
48 | ''' Test CONNECT with version 1.0''' | |
49 | self.conn.disconnect() | |
50 | new_conn = self.create_connection(version="1.0") | |
51 | try: | |
52 | self.assertTrue(new_conn.is_connected()) | |
53 | finally: | |
54 | new_conn.disconnect() | |
55 | self.assertFalse(new_conn.is_connected()) | |
56 | ||
47 | 57 | def test_connect_version_1_1(self): |
48 | 58 | ''' Test CONNECT with version 1.1''' |
49 | 59 | self.conn.disconnect() |
54 | 64 | new_conn.disconnect() |
55 | 65 | self.assertFalse(new_conn.is_connected()) |
56 | 66 | |
67 | def test_connect_version_1_2(self): | |
68 | ''' Test CONNECT with version 1.2''' | |
69 | self.conn.disconnect() | |
70 | new_conn = self.create_connection(version="1.2") | |
71 | try: | |
72 | self.assertTrue(new_conn.is_connected()) | |
73 | finally: | |
74 | new_conn.disconnect() | |
75 | self.assertFalse(new_conn.is_connected()) | |
76 | ||
57 | 77 | def test_heartbeat_disconnects_client(self): |
58 | 78 | ''' Test heart-beat disconnection''' |
59 | 79 | self.conn.disconnect() |
60 | new_conn = self.create_connection(heartbeat="1500,0") | |
80 | new_conn = self.create_connection(version='1.1', heartbeats=(1500, 0)) | |
61 | 81 | try: |
62 | 82 | self.assertTrue(new_conn.is_connected()) |
63 | 83 | time.sleep(1) |
70 | 90 | |
71 | 91 | def test_unsupported_version(self): |
72 | 92 | ''' Test unsupported version on CONNECT command''' |
73 | self.bad_connect(stomp.Connection(user="guest", | |
74 | passcode="guest", | |
75 | version="100.1"), | |
76 | "Supported versions are 1.0,1.1,1.2\n") | |
93 | self.bad_connect("Supported versions are 1.0,1.1,1.2\n", version='100.1') | |
77 | 94 | |
78 | 95 | def test_bad_username(self): |
79 | 96 | ''' Test bad username''' |
80 | self.bad_connect(stomp.Connection(user="gust", | |
81 | passcode="guest"), | |
82 | "Access refused for user 'gust'\n") | |
97 | self.bad_connect("Access refused for user 'gust'\n", user='gust') | |
83 | 98 | |
84 | 99 | def test_bad_password(self): |
85 | 100 | ''' Test bad password''' |
86 | self.bad_connect(stomp.Connection(user="guest", | |
87 | passcode="gust"), | |
88 | "Access refused for user 'guest'\n") | |
101 | self.bad_connect("Access refused for user 'guest'\n", passcode='gust') | |
89 | 102 | |
90 | 103 | def test_bad_vhost(self): |
91 | 104 | ''' Test bad virtual host''' |
92 | self.bad_connect(stomp.Connection(user="guest", | |
93 | passcode="guest", | |
94 | virtual_host="//"), | |
95 | "Virtual host '//' access denied") | |
105 | self.bad_connect("Virtual host '//' access denied", version='1.1', vhost='//') | |
96 | 106 | |
97 | def bad_connect(self, new_conn, expected): | |
107 | def bad_connect(self, expected, user='guest', passcode='guest', **kwargs): | |
98 | 108 | self.conn.disconnect() |
109 | new_conn = self.create_connection_obj(**kwargs) | |
99 | 110 | listener = base.WaitableListener() |
100 | 111 | new_conn.set_listener('', listener) |
101 | 112 | try: |
102 | 113 | new_conn.start() |
103 | new_conn.connect() | |
114 | new_conn.connect(user, passcode) | |
104 | 115 | self.assertTrue(listener.await()) |
105 | 116 | self.assertEquals(expected, listener.errors[0]['message']) |
106 | 117 | finally: |
135 | 146 | |
136 | 147 | def unsub_test(self, dest, verbs, numRcts=0): |
137 | 148 | def afterfun(): |
138 | self.conn.send("after-test", destination=dest) | |
149 | self.conn.send(dest, "after-test") | |
139 | 150 | subverb, unsubverb = verbs |
140 | 151 | self.assertListenerAfter(subverb, numMsgs=1, |
141 | 152 | errMsg="FAILED to subscribe and send") |
144 | 155 | self.assertListenerAfter(afterfun, |
145 | 156 | errMsg="Still receiving messages") |
146 | 157 | |
147 | def sub_and_send(self, dest, subid="", receipt=""): | |
158 | def sub_and_send(self, dest, subid=None, receipt=None): | |
148 | 159 | def subfun(): |
149 | if subid=="": | |
150 | self.conn.subscribe(destination=dest) | |
151 | else: | |
152 | self.conn.subscribe(destination=dest, id=subid) | |
153 | self.conn.send("test", destination=dest) | |
160 | self.subscribe_dest(self.conn, dest, subid) | |
161 | self.conn.send(dest, "test") | |
154 | 162 | def unsubfun(): |
155 | if subid=="" and receipt=="": | |
156 | self.conn.unsubscribe(destination=dest) | |
157 | elif receipt=="": | |
158 | self.conn.unsubscribe(id=subid) | |
159 | elif subid=="": | |
160 | self.conn.unsubscribe(destination=dest, receipt=receipt) | |
161 | else: | |
162 | self.conn.unsubscribe(id=subid, receipt=receipt) | |
163 | headers = {} | |
164 | if receipt != None: | |
165 | headers['receipt'] = receipt | |
166 | self.unsubscribe_dest(self.conn, dest, subid, **headers) | |
163 | 167 | return subfun, unsubfun |
50 | 50 | |
51 | 51 | |
52 | 52 | def match(self, pattern, data): |
53 | ''' helper: try to match 'pattern' regexp with 'data' string. | |
54 | Fail test if they don't match. | |
53 | ''' helper: try to match a regexp with a string. | |
54 | Fail test if they do not match. | |
55 | 55 | ''' |
56 | 56 | matched = re.match(pattern, data) |
57 | 57 | if matched: |
194 | 194 | '\n\x00') |
195 | 195 | for cd in [self.cd1, self.cd2]: |
196 | 196 | self.match(resp, cd.recv(4096)) |
197 | ||
198 | ||
199 | @connect(['cd']) | |
200 | def test_huge_message(self): | |
201 | ''' Test sending/receiving huge (16MB) message. ''' | |
202 | subscribe=( 'SUBSCRIBE\n' | |
203 | 'id: xxx\n' | |
204 | 'destination:/exchange/amq.topic/test_huge_message\n' | |
205 | '\n\0') | |
206 | self.cd.sendall(subscribe) | |
207 | ||
208 | message = 'x' * 1024*1024*16 | |
209 | ||
210 | self.cd.sendall('SEND\n' | |
211 | 'destination:/exchange/amq.topic/test_huge_message\n' | |
212 | 'content-type:text/plain\n' | |
213 | '\n' | |
214 | '%s' | |
215 | '\0' % message) | |
216 | ||
217 | resp=('MESSAGE\n' | |
218 | 'subscription:(.*)\n' | |
219 | 'destination:/topic/test_huge_message\n' | |
220 | 'message-id:(.*)\n' | |
221 | 'content-type:text/plain\n' | |
222 | 'content-length:%i\n' | |
223 | '\n' | |
224 | '%s(.*)' | |
225 | % (len(message), message[:8000]) ) | |
226 | ||
227 | recv = [] | |
228 | s = 0 | |
229 | while len(recv) < 1 or recv[-1][-1] != '\0': | |
230 | buf = self.cd.recv(4096*16) | |
231 | s += len(buf) | |
232 | recv.append( buf ) | |
233 | buf = ''.join(recv) | |
234 | ||
235 | # matching 100MB regexp is way too expensive. | |
236 | self.match(resp, buf[:8192]) | |
237 | self.assertEqual(len(buf) > len(message), True) | |
238 | 197 | |
239 | 198 | @connect(['cd']) |
240 | 199 | def test_message_with_embedded_nulls(self): |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_amqqueue_test). |
33 | 33 | |
34 | 34 | run() -> |
35 | 35 | [put(K, 0) || K <- [sent, recd, last_sent, last_recd]], |
36 | put(last_ts, erlang:now()), | |
36 | put(last_ts, os:timestamp()), | |
37 | 37 | {ok, Pub} = rabbit_stomp_client:connect(), |
38 | 38 | {ok, Recv} = rabbit_stomp_client:connect(), |
39 | 39 | Self = self(), |
40 | spawn(fun() -> publish(Self, Pub, 0, erlang:now()) end), | |
40 | spawn(fun() -> publish(Self, Pub, 0, os:timestamp()) end), | |
41 | 41 | rabbit_stomp_client:send( |
42 | 42 | Recv, "SUBSCRIBE", [{"destination", ?DESTINATION}]), |
43 | spawn(fun() -> recv(Self, Recv, 0, erlang:now()) end), | |
43 | spawn(fun() -> recv(Self, Recv, 0, os:timestamp()) end), | |
44 | 44 | report(). |
45 | 45 | |
46 | 46 | report() -> |
48 | 48 | {sent, C} -> put(sent, C); |
49 | 49 | {recd, C} -> put(recd, C) |
50 | 50 | end, |
51 | Diff = timer:now_diff(erlang:now(), get(last_ts)), | |
51 | Diff = timer:now_diff(os:timestamp(), get(last_ts)), | |
52 | 52 | case Diff > ?MICROS_PER_UPDATE of |
53 | 53 | true -> S = get(sent) - get(last_sent), |
54 | 54 | R = get(recd) - get(last_recd), |
55 | 55 | put(last_sent, get(sent)), |
56 | 56 | put(last_recd, get(recd)), |
57 | put(last_ts, erlang:now()), | |
57 | put(last_ts, os:timestamp()), | |
58 | 58 | io:format("Send ~p msg/s | Recv ~p msg/s~n", |
59 | 59 | [trunc(S * ?MICROS_PER_SECOND / Diff), |
60 | 60 | trunc(R * ?MICROS_PER_SECOND / Diff)]); |
66 | 66 | rabbit_stomp_client:send( |
67 | 67 | Client, "SEND", [{"destination", ?DESTINATION}], |
68 | 68 | [integer_to_list(Count)]), |
69 | Diff = timer:now_diff(erlang:now(), TS), | |
69 | Diff = timer:now_diff(os:timestamp(), TS), | |
70 | 70 | case Diff > ?MICROS_PER_UPDATE_MSG of |
71 | 71 | true -> Owner ! {sent, Count + 1}, |
72 | publish(Owner, Client, Count + 1, erlang:now()); | |
72 | publish(Owner, Client, Count + 1, os:timestamp()); | |
73 | 73 | false -> publish(Owner, Client, Count + 1, TS) |
74 | 74 | end. |
75 | 75 | |
78 | 78 | rabbit_stomp_client:recv(Client0), |
79 | 79 | BodyInt = list_to_integer(binary_to_list(iolist_to_binary(Body))), |
80 | 80 | Count = BodyInt, |
81 | Diff = timer:now_diff(erlang:now(), TS), | |
81 | Diff = timer:now_diff(os:timestamp(), TS), | |
82 | 82 | case Diff > ?MICROS_PER_UPDATE_MSG of |
83 | 83 | true -> Owner ! {recd, Count + 1}, |
84 | recv(Owner, Client1, Count + 1, erlang:now()); | |
84 | recv(Owner, Client1, Count + 1, os:timestamp()); | |
85 | 85 | false -> recv(Owner, Client1, Count + 1, TS) |
86 | 86 | end. |
87 | 87 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_test). |
23 | 23 | |
24 | 24 | all_tests() -> |
25 | 25 | test_messages_not_dropped_on_disconnect(), |
26 | test_direct_client_connections_are_not_leaked(), | |
27 | ok. | |
28 | ||
29 | -define(GARBAGE, <<"bdaf63dda9d78b075c748b740e7c3510ad203b07\nbdaf63dd">>). | |
30 | ||
31 | count_connections() -> | |
32 | length(supervisor2:which_children(rabbit_stomp_client_sup_sup)). | |
33 | ||
34 | test_direct_client_connections_are_not_leaked() -> | |
35 | N = count_connections(), | |
36 | lists:foreach(fun (_) -> | |
37 | {ok, Client = {Socket, _}} = rabbit_stomp_client:connect(), | |
38 | %% send garbage which trips up the parser | |
39 | gen_tcp:send(Socket, ?GARBAGE), | |
40 | rabbit_stomp_client:send( | |
41 | Client, "LOL", [{"", ""}]) | |
42 | end, | |
43 | lists:seq(1, 1000)), | |
44 | timer:sleep(5000), | |
45 | N = count_connections(), | |
26 | 46 | ok. |
27 | 47 | |
28 | 48 | test_messages_not_dropped_on_disconnect() -> |
49 | N = count_connections(), | |
29 | 50 | {ok, Client} = rabbit_stomp_client:connect(), |
51 | N1 = N + 1, | |
52 | N1 = count_connections(), | |
30 | 53 | [rabbit_stomp_client:send( |
31 | 54 | Client, "SEND", [{"destination", ?DESTINATION}], |
32 | 55 | [integer_to_list(Count)]) || Count <- lists:seq(1, 1000)], |
33 | 56 | rabbit_stomp_client:disconnect(Client), |
34 | 57 | QName = rabbit_misc:r(<<"/">>, queue, <<"bulk-test">>), |
35 | 58 | timer:sleep(3000), |
59 | N = count_connections(), | |
36 | 60 | rabbit_amqqueue:with( |
37 | 61 | QName, fun(Q) -> |
38 | 62 | 1000 = pget(messages, rabbit_amqqueue:info(Q, [messages])) |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_test_frame). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_stomp_test_util). |
6 | 6 | |
7 | 7 | def test_send_and_disconnect(self): |
8 | 8 | ''' Test close socket after send does not lose messages ''' |
9 | d = "/queue/reliability" | |
9 | destination = "/queue/reliability" | |
10 | 10 | pub_conn = self.create_connection() |
11 | 11 | try: |
12 | 12 | msg = "0" * (128) |
16 | 16 | listener = base.WaitableListener() |
17 | 17 | listener.reset(count) |
18 | 18 | self.conn.set_listener('', listener) |
19 | self.conn.subscribe(destination=d) | |
19 | self.subscribe_dest(self.conn, destination, None) | |
20 | 20 | |
21 | 21 | for x in range(0, count): |
22 | pub_conn.send(msg + str(x), destination=d) | |
22 | pub_conn.send(destination, msg + str(x)) | |
23 | 23 | time.sleep(2.0) |
24 | pub_conn.close_socket() | |
24 | pub_conn.disconnect() | |
25 | 25 | |
26 | 26 | if listener.await(30): |
27 | 27 | self.assertEquals(count, len(listener.messages)) |
4 | 4 | |
5 | 5 | import stomp |
6 | 6 | import base |
7 | import ssl | |
7 | 8 | |
8 | 9 | |
9 | 10 | base_path = os.path.dirname(sys.argv[0]) |
15 | 16 | class TestSslClient(unittest.TestCase): |
16 | 17 | |
17 | 18 | def __ssl_connect(self): |
18 | conn = stomp.Connection(user="guest", passcode="guest", | |
19 | host_and_ports = [ ('localhost', 61614) ], | |
19 | conn = stomp.Connection(host_and_ports = [ ('localhost', 61614) ], | |
20 | 20 | use_ssl = True, ssl_key_file = ssl_key_file, |
21 | 21 | ssl_cert_file = ssl_cert_file, |
22 | 22 | ssl_ca_certs = ssl_ca_certs) |
23 | 23 | print "FILE: ", ssl_cert_file |
24 | 24 | conn.start() |
25 | conn.connect() | |
25 | conn.connect("guest", "guest") | |
26 | 26 | return conn |
27 | 27 | |
28 | 28 | def __ssl_auth_connect(self): |
36 | 36 | |
37 | 37 | def test_ssl_connect(self): |
38 | 38 | conn = self.__ssl_connect() |
39 | conn.stop() | |
39 | conn.disconnect() | |
40 | 40 | |
41 | 41 | def test_ssl_auth_connect(self): |
42 | 42 | conn = self.__ssl_auth_connect() |
43 | conn.stop() | |
43 | conn.disconnect() | |
44 | 44 | |
45 | 45 | def test_ssl_send_receive(self): |
46 | 46 | conn = self.__ssl_connect() |
57 | 57 | conn.set_listener('', listener) |
58 | 58 | |
59 | 59 | d = "/topic/ssl.test" |
60 | conn.subscribe(destination=d, receipt="sub") | |
60 | conn.subscribe(destination=d, ack="auto", id="ctag", receipt="sub") | |
61 | 61 | |
62 | 62 | self.assertTrue(listener.await(1)) |
63 | 63 | |
65 | 65 | listener.receipts[0]['headers']['receipt-id']) |
66 | 66 | |
67 | 67 | listener.reset(1) |
68 | conn.send("Hello SSL!", destination=d) | |
68 | conn.send(body="Hello SSL!", destination=d) | |
69 | 69 | |
70 | 70 | self.assertTrue(listener.await()) |
71 | 71 |
2 | 2 | import test_runner |
3 | 3 | |
4 | 4 | if __name__ == '__main__': |
5 | modules = ['parsing', 'destinations', 'lifecycle', 'transactions', | |
6 | 'ack', 'errors', 'reliability'] | |
5 | modules = [ | |
6 | 'parsing', | |
7 | 'destinations', | |
8 | 'lifecycle', | |
9 | 'transactions', | |
10 | 'ack', | |
11 | 'errors', | |
12 | 'reliability', | |
13 | ] | |
7 | 14 | test_runner.run_unittests(modules) |
8 | 15 |
6 | 6 | |
7 | 7 | def test_tx_commit(self): |
8 | 8 | ''' Test TX with a COMMIT and ensure messages are delivered ''' |
9 | d = "/exchange/amq.fanout" | |
9 | destination = "/exchange/amq.fanout" | |
10 | 10 | tx = "test.tx" |
11 | 11 | |
12 | 12 | self.listener.reset() |
13 | self.conn.subscribe(destination=d) | |
13 | self.subscribe_dest(self.conn, destination, None) | |
14 | 14 | self.conn.begin(transaction=tx) |
15 | self.conn.send("hello!", destination=d, transaction=tx) | |
16 | self.conn.send("again!", destination=d) | |
15 | self.conn.send(destination, "hello!", transaction=tx) | |
16 | self.conn.send(destination, "again!") | |
17 | 17 | |
18 | 18 | ## should see the second message |
19 | 19 | self.assertTrue(self.listener.await(3)) |
30 | 30 | |
31 | 31 | def test_tx_abort(self): |
32 | 32 | ''' Test TX with an ABORT and ensure messages are discarded ''' |
33 | d = "/exchange/amq.fanout" | |
33 | destination = "/exchange/amq.fanout" | |
34 | 34 | tx = "test.tx" |
35 | 35 | |
36 | 36 | self.listener.reset() |
37 | self.conn.subscribe(destination=d) | |
37 | self.subscribe_dest(self.conn, destination, None) | |
38 | 38 | self.conn.begin(transaction=tx) |
39 | self.conn.send("hello!", destination=d, transaction=tx) | |
40 | self.conn.send("again!", destination=d) | |
39 | self.conn.send(destination, "hello!", transaction=tx) | |
40 | self.conn.send(destination, "again!") | |
41 | 41 | |
42 | 42 | ## should see the second message |
43 | 43 | self.assertTrue(self.listener.await(3)) |
204 | 204 | Q = Q0#amqqueue{arguments = [{<<"x-max-priority">>, long, 5}]}, |
205 | 205 | PQ = rabbit_priority_queue, |
206 | 206 | BQS1 = PQ:init(Q, new, fun(_, _) -> ok end), |
207 | {Duration1, BQS2} = PQ:ram_duration(BQS1), | |
207 | {_Duration1, BQS2} = PQ:ram_duration(BQS1), | |
208 | 208 | BQS3 = PQ:set_ram_duration_target(infinity, BQS2), |
209 | 209 | BQS4 = PQ:set_ram_duration_target(1, BQS3), |
210 | {Duration2, BQS5} = PQ:ram_duration(BQS4), | |
210 | {_Duration2, BQS5} = PQ:ram_duration(BQS4), | |
211 | 211 | PQ:delete_and_terminate(a_whim, BQS5), |
212 | 212 | passed. |
213 | 213 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_app). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_consumer). |
10 | 10 | %% The Original Code is RabbitMQ Federation. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_consumer_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_files). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_mgmt). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_traces). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | |
15 | 15 | -module(rabbit_tracing_wm_file). |
16 | 16 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_wm_files). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | |
15 | 15 | -module(rabbit_tracing_wm_trace). |
16 | 16 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_wm_traces). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_tracing_test). |
29 | 29 | [Head, Body] = binary:split(Frame, <<"\n\n">>), |
30 | 30 | [Command | HeaderLines] = binary:split(Head, <<"\n">>, [global]), |
31 | 31 | Headers = [list_to_tuple(binary:split(Line, <<":">>)) || Line <- HeaderLines], |
32 | [Body1, <<>>] = binary:split(Body, [<<0>>],[{scope,{byte_size(Body)-1, 1}}]), | |
32 | [Body1, <<>>] = binary:split(Body, [<<0, 10>>],[{scope,{byte_size(Body)-2, 2}}]), | |
33 | 33 | {Command, Headers, Body1}. |
34 | 34 | |
35 | 35 | %% ---------- |
11 | 11 | ## The Original Code is RabbitMQ. |
12 | 12 | ## |
13 | 13 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | ## Copyright (c) 2012-2014 GoPivotal, Inc. All rights reserved. | |
14 | ## Copyright (c) 2012-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | ## |
16 | 16 | |
17 | 17 | ### next line potentially updated in package install steps |
25 | 25 | |
26 | 26 | ## Set default values |
27 | 27 | |
28 | BOOT_MODULE="rabbit" | |
29 | ||
28 | 30 | CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq |
29 | 31 | LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq |
30 | 32 | MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia |
31 | 33 | ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins |
32 | 34 | |
33 | 35 | PLUGINS_DIR="${RABBITMQ_HOME}/plugins" |
36 | IO_THREAD_POOL_SIZE=64 | |
34 | 37 | |
35 | 38 | CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf |
0 | @echo off | |
1 | ||
2 | REM ### next line potentially updated in package install steps | |
3 | REM set SYS_PREFIX= | |
4 | ||
5 | REM ### next line will be updated when generating a standalone release | |
6 | REM ERL_DIR= | |
7 | set ERL_DIR= | |
8 | ||
9 | REM These boot files don't appear to be referenced in the batch scripts | |
10 | REM set CLEAN_BOOT_FILE=start_clean | |
11 | REM set SASL_BOOT_FILE=start_sasl | |
12 | ||
13 | REM ## Set default values | |
14 | ||
15 | if "!RABBITMQ_BASE!"=="" ( | |
16 | set RABBITMQ_BASE=!APPDATA!\RabbitMQ | |
17 | ) | |
18 | ||
19 | REM BOOT_MODULE="rabbit" | |
20 | REM CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq | |
21 | REM LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq | |
22 | REM MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia | |
23 | REM ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins | |
24 | set BOOT_MODULE=rabbit | |
25 | set CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq | |
26 | set LOG_BASE=!RABBITMQ_BASE!\log | |
27 | set MNESIA_BASE=!RABBITMQ_BASE!\db | |
28 | set ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins | |
29 | ||
30 | REM PLUGINS_DIR="${RABBITMQ_HOME}/plugins" | |
31 | set PLUGINS_DIR=!TDP0!..\plugins | |
32 | ||
33 | REM CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf | |
34 | if "!RABBITMQ_CONF_ENV_FILE!"=="" ( | |
35 | set CONF_ENV_FILE=!APPDATA!\RabbitMQ\rabbitmq-env-conf.bat | |
36 | ) |
4 | 4 | REM <rabbitmq_nodename> (s)name of the erlang node to connect to (required) |
5 | 5 | |
6 | 6 | setlocal |
7 | ||
8 | set TDP0=%~dp0 | |
9 | ||
10 | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | |
11 | REM Non-empty defaults should be set in rabbitmq-env | |
12 | call "!TDP0!\rabbitmq-env.bat" | |
7 | 13 | |
8 | 14 | if "%1"=="" goto fail |
9 | 15 | |
16 | 22 | if not exist "%WMIC_PATH%" ( |
17 | 23 | goto fail |
18 | 24 | ) |
19 | ||
20 | :: sets sname/name :: | |
21 | if "!RABBITMQ_USE_LONGNAME!"=="" ( | |
22 | set RABBITMQ_NAME_TYPE="-sname" | |
23 | ) | |
24 | ||
25 | if "!RABBITMQ_USE_LONGNAME!"=="true" ( | |
26 | set RABBITMQ_NAME_TYPE="-name" | |
27 | ) | |
28 | ||
29 | 25 | |
30 | 26 | :getpid |
31 | 27 | for /f "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NAME_TYPE% %1%%'" get processid 2^>nul`) do ( |
11 | 11 | ## The Original Code is RabbitMQ. |
12 | 12 | ## |
13 | 13 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | ## |
16 | 16 | |
17 | 17 | # We set +e here since since our test for "readlink -f" below needs to |
43 | 43 | . ${SCRIPT_DIR}/rabbitmq-defaults |
44 | 44 | |
45 | 45 | ## Common defaults |
46 | SERVER_ERL_ARGS="+K true +A30 +P 1048576 \ | |
47 | -kernel inet_default_connect_options [{nodelay,true}]" | |
46 | SERVER_ERL_ARGS="+P 1048576" | |
48 | 47 | |
49 | 48 | # warn about old rabbitmq.conf file, if no new one |
50 | 49 | if [ -f /etc/rabbitmq/rabbitmq.conf ] && \ |
53 | 52 | echo "location has moved to ${CONF_ENV_FILE}" |
54 | 53 | fi |
55 | 54 | |
55 | # We save the current value of $RABBITMQ_PID_FILE in case it was set by | |
56 | # an init script. If $CONF_ENV_FILE overrides it again, we must ignore | |
57 | # it and warn the user. | |
58 | saved_RABBITMQ_PID_FILE=$RABBITMQ_PID_FILE | |
59 | ||
56 | 60 | ## Get configuration variables from the configure environment file |
57 | 61 | [ -f ${CONF_ENV_FILE} ] && . ${CONF_ENV_FILE} || true |
62 | ||
63 | if [ "$saved_RABBITMQ_PID_FILE" -a \ | |
64 | "$saved_RABBITMQ_PID_FILE" != "$RABBITMQ_PID_FILE" ]; then | |
65 | echo "WARNING: RABBITMQ_PID_FILE was already set by the init script to:" 1>&2 | |
66 | echo " $saved_RABBITMQ_PID_FILE" 1>&2 | |
67 | echo " The value set in rabbitmq-env.conf is ignored because it" 1>&2 | |
68 | echo " would break the init script." 1>&2 | |
69 | ||
70 | RABBITMQ_PID_FILE="$saved_RABBITMQ_PID_FILE" | |
71 | fi | |
58 | 72 | |
59 | 73 | [ "x" = "x$RABBITMQ_USE_LONGNAME" ] && RABBITMQ_USE_LONGNAME=${USE_LONGNAME} |
60 | 74 | if [ "xtrue" = "x$RABBITMQ_USE_LONGNAME" ] ; then |
69 | 83 | |
70 | 84 | ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set |
71 | 85 | |
86 | rmq_realpath() { | |
87 | local path=$1 | |
88 | ||
89 | if [ -d "$path" ]; then | |
90 | cd "$path" && pwd | |
91 | elif [ -f "$path" ]; then | |
92 | cd "$(dirname "$path")" && echo $(pwd)/$(basename "$path") | |
93 | else | |
94 | echo "$path" | |
95 | fi | |
96 | } | |
97 | ||
98 | rmq_check_if_shared_with_mnesia() { | |
99 | local var | |
100 | ||
101 | local mnesia_dir=$(rmq_realpath "${RABBITMQ_MNESIA_DIR}") | |
102 | local prefix="WARNING:" | |
103 | ||
104 | for var in "$@"; do | |
105 | local dir=$(eval "echo \"\$$var\"") | |
106 | ||
107 | case $(rmq_realpath "$dir") in | |
108 | ${mnesia_dir}) | |
109 | warning=1 | |
110 | echo "$prefix $var is equal to RABBITMQ_MNESIA_DIR" 1>&2 | |
111 | ;; | |
112 | ${mnesia_dir}/*) | |
113 | warning=1 | |
114 | echo "$prefix $var is located inside RABBITMQ_MNESIA_DIR" 1>&2 | |
115 | ;; | |
116 | esac | |
117 | ||
118 | if [ "x$warning" = "x1" ]; then | |
119 | prefix=" " | |
120 | fi | |
121 | done | |
122 | ||
123 | if [ "x$warning" = "x1" ]; then | |
124 | echo "$prefix => Auto-clustering will not work ('cluster_nodes' in rabbitmq.config)" 1>&2 | |
125 | fi | |
126 | } | |
127 | ||
72 | 128 | DEFAULT_NODE_IP_ADDRESS=auto |
73 | 129 | DEFAULT_NODE_PORT=5672 |
74 | 130 | [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS} |
82 | 138 | [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${RABBITMQ_NODE_PORT} + 20000)) |
83 | 139 | |
84 | 140 | [ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME} |
141 | [ "x" = "x$RABBITMQ_IO_THREAD_POOL_SIZE" ] && RABBITMQ_IO_THREAD_POOL_SIZE=${IO_THREAD_POOL_SIZE} | |
85 | 142 | [ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS} |
86 | 143 | [ "x" = "x$RABBITMQ_CONFIG_FILE" ] && RABBITMQ_CONFIG_FILE=${CONFIG_FILE} |
87 | 144 | [ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE} |
93 | 150 | |
94 | 151 | [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${PID_FILE} |
95 | 152 | [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${RABBITMQ_MNESIA_DIR}.pid |
153 | ||
154 | [ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE} | |
96 | 155 | |
97 | 156 | [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${PLUGINS_EXPAND_DIR} |
98 | 157 | [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME}-plugins-expand |
109 | 168 | |
110 | 169 | [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS} |
111 | 170 | |
171 | # Check if files and directories non-related to Mnesia are configured | |
172 | # to be in $RABBITMQ_MNESIA_DIR. If this is the case, issue a warning | |
173 | # because it will prevent auto-clustering from working (the node will be | |
174 | # considered non-virgin). | |
175 | ||
176 | rmq_check_if_shared_with_mnesia \ | |
177 | RABBITMQ_CONFIG_FILE \ | |
178 | RABBITMQ_LOG_BASE \ | |
179 | RABBITMQ_PID_FILE \ | |
180 | RABBITMQ_PLUGINS_EXPAND_DIR \ | |
181 | RABBITMQ_ENABLED_PLUGINS_FILE \ | |
182 | RABBITMQ_PLUGINS_DIR \ | |
183 | RABBITMQ_LOGS \ | |
184 | RABBITMQ_SASL_LOGS | |
185 | ||
112 | 186 | ##--- End of overridden <var_name> variables |
113 | 187 | |
114 | 188 | # Since we source this elsewhere, don't accidentally stop execution |
0 | @echo off | |
1 | ||
2 | REM Scopes the variables to the current batch file | |
3 | REM setlocal | |
4 | ||
5 | rem Preserve values that might contain exclamation marks before | |
6 | rem enabling delayed expansion | |
7 | set TDP0=%~dp0 | |
8 | REM setlocal enabledelayedexpansion | |
9 | ||
10 | REM SCRIPT_DIR=`dirname $SCRIPT_PATH` | |
11 | REM RABBITMQ_HOME="${SCRIPT_DIR}/.." | |
12 | set SCRIPT_DIR=%TDP0% | |
13 | set RABBITMQ_HOME=%SCRIPT_DIR%.. | |
14 | ||
15 | REM ## Set defaults | |
16 | REM . ${SCRIPT_DIR}/rabbitmq-defaults | |
17 | call "%SCRIPT_DIR%\rabbitmq-defaults.bat" | |
18 | ||
19 | REM These common defaults aren't referenced in the batch scripts | |
20 | REM ## Common defaults | |
21 | REM SERVER_ERL_ARGS="+P 1048576" | |
22 | REM | |
23 | REM # warn about old rabbitmq.conf file, if no new one | |
24 | REM if [ -f /etc/rabbitmq/rabbitmq.conf ] && \ | |
25 | REM [ ! -f ${CONF_ENV_FILE} ] ; then | |
26 | REM echo -n "WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- " | |
27 | REM echo "location has moved to ${CONF_ENV_FILE}" | |
28 | REM fi | |
29 | ||
30 | REM ERL_ARGS aren't referenced in the batch scripts | |
31 | REM Common defaults | |
32 | REM set SERVER_ERL_ARGS=+P 1048576 | |
33 | ||
34 | REM ## Get configuration variables from the configure environment file | |
35 | REM [ -f ${CONF_ENV_FILE} ] && . ${CONF_ENV_FILE} || true | |
36 | if exist "!RABBITMQ_CONF_ENV_FILE!" ( | |
37 | call !RABBITMQ_CONF_ENV_FILE! | |
38 | ) | |
39 | ||
40 | REM Check for the short names here too | |
41 | if "!RABBITMQ_USE_LONGNAME!"=="" ( | |
42 | if "!USE_LONGNAME!"=="" ( | |
43 | set RABBITMQ_NAME_TYPE="-sname" | |
44 | ) | |
45 | ) | |
46 | ||
47 | if "!RABBITMQ_USE_LONGNAME!"=="true" ( | |
48 | if "!USE_LONGNAME!"=="true" ( | |
49 | set RABBITMQ_NAME_TYPE="-name" | |
50 | ) | |
51 | ) | |
52 | ||
53 | if "!COMPUTERNAME!"=="" ( | |
54 | set COMPUTERNAME=localhost | |
55 | ) | |
56 | ||
57 | REM [ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME} | |
58 | if "!RABBITMQ_NODENAME!"=="" ( | |
59 | if "!NODENAME!"=="" ( | |
60 | set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME! | |
61 | ) else ( | |
62 | set RABBITMQ_NODENAME=!NODENAME! | |
63 | ) | |
64 | ) | |
65 | ||
66 | REM | |
67 | REM ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set | |
68 | REM | |
69 | REM DEFAULT_NODE_IP_ADDRESS=auto | |
70 | REM DEFAULT_NODE_PORT=5672 | |
71 | REM [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS} | |
72 | REM [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${NODE_PORT} | |
73 | REM [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_IP_ADDRESS=${DEFAULT_NODE_IP_ADDRESS} | |
74 | REM [ "x" != "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${DEFAULT_NODE_PORT} | |
75 | ||
76 | REM if "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( | |
77 | REM if not "!RABBITMQ_NODE_PORT!"=="" ( | |
78 | REM set RABBITMQ_NODE_IP_ADDRESS=auto | |
79 | REM ) | |
80 | REM ) else ( | |
81 | REM if "!RABBITMQ_NODE_PORT!"=="" ( | |
82 | REM set RABBITMQ_NODE_PORT=5672 | |
83 | REM ) | |
84 | REM ) | |
85 | ||
86 | REM DOUBLE CHECK THIS LOGIC | |
87 | if "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( | |
88 | if "!NODE_IP_ADDRESS!"=="" ( | |
89 | set RABBITMQ_NODE_IP_ADDRESS=auto | |
90 | ) else ( | |
91 | set RABBITMQ_NODE_IP_ADDRESS=!NODE_IP_ADDRESS! | |
92 | ) | |
93 | ) | |
94 | ||
95 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
96 | if "!NODE_PORT!"=="" ( | |
97 | set RABBITMQ_NODE_PORT=5672 | |
98 | ) else ( | |
99 | set RABBITMQ_NODE_PORT=!NODE_PORT! | |
100 | ) | |
101 | ) | |
102 | ||
103 | REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && RABBITMQ_DIST_PORT=${DIST_PORT} | |
104 | REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${DEFAULT_NODE_PORT} + 20000)) | |
105 | REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${RABBITMQ_NODE_PORT} + 20000)) | |
106 | ||
107 | if "!RABBITMQ_DIST_PORT!"=="" ( | |
108 | if "!DIST_PORT!"=="" ( | |
109 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
110 | set RABBITMQ_DIST_PORT=25672 | |
111 | ) else ( | |
112 | set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT! | |
113 | ) | |
114 | ) else ( | |
115 | set RABBITMQ_DIST_PORT=!DIST_PORT! | |
116 | ) | |
117 | ) | |
118 | ||
119 | REM [ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS} | |
120 | REM No Windows equivalent | |
121 | ||
122 | REM [ "x" = "x$RABBITMQ_CONFIG_FILE" ] && RABBITMQ_CONFIG_FILE=${CONFIG_FILE} | |
123 | if "!RABBITMQ_CONFIG_FILE!"=="" ( | |
124 | if "!CONFIG_FILE!"=="" ( | |
125 | set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq | |
126 | ) else ( | |
127 | set RABBITMQ_CONFIG_FILE=!CONFIG_FILE! | |
128 | ) | |
129 | ) | |
130 | ||
131 | REM [ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE} | |
132 | if "!RABBITMQ_LOG_BASE!"=="" ( | |
133 | if "!LOG_BASE!"=="" ( | |
134 | set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!\log | |
135 | ) else ( | |
136 | set RABBITMQ_LOG_BASE=!LOG_BASE! | |
137 | ) | |
138 | ) | |
139 | ||
140 | REM [ "x" = "x$RABBITMQ_MNESIA_BASE" ] && RABBITMQ_MNESIA_BASE=${MNESIA_BASE} | |
141 | if "!RABBITMQ_MNESIA_BASE!"=="" ( | |
142 | if "!MNESIA_BASE!"=="" ( | |
143 | set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!\db | |
144 | ) else ( | |
145 | set RABBITMQ_MNESIA_BASE=!MNESIA_BASE! | |
146 | ) | |
147 | ) | |
148 | ||
149 | REM [ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS} | |
150 | REM No Windows equivalent | |
151 | ||
152 | REM [ "x" = "x$RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS" ] && RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=${SERVER_ADDITIONAL_ERL_ARGS} | |
153 | REM No Windows equivalent | |
154 | ||
155 | REM [ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${MNESIA_DIR} | |
156 | REM [ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME} | |
157 | if "!RABBITMQ_MNESIA_DIR!"=="" ( | |
158 | if "!MNESIA_DIR!"=="" ( | |
159 | set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia | |
160 | ) else ( | |
161 | set RABBITMQ_MNESIA_DIR=!MNESIA_DIR! | |
162 | ) | |
163 | ) | |
164 | ||
165 | REM [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${PID_FILE} | |
166 | REM [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${RABBITMQ_MNESIA_DIR}.pid | |
167 | REM No Windows equivalent | |
168 | ||
169 | REM [ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE} | |
170 | if "!RABBITMQ_BOOT_MODULE!"=="" ( | |
171 | if "!BOOT_MODULE!"=="" ( | |
172 | set RABBITMQ_BOOT_MODULE=rabbit | |
173 | ) else ( | |
174 | set RABBITMQ_BOOT_MODULE=!BOOT_MODULE! | |
175 | ) | |
176 | ) | |
177 | ||
178 | REM [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${PLUGINS_EXPAND_DIR} | |
179 | REM [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME}-plugins-expand | |
180 | if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" ( | |
181 | if "!PLUGINS_EXPAND_DIR!"=="" ( | |
182 | set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand | |
183 | ) else ( | |
184 | set RABBITMQ_PLUGINS_EXPAND_DIR=!PLUGINS_EXPAND_DIR! | |
185 | ) | |
186 | ) | |
187 | ||
188 | REM [ "x" = "x$RABBITMQ_ENABLED_PLUGINS_FILE" ] && RABBITMQ_ENABLED_PLUGINS_FILE=${ENABLED_PLUGINS_FILE} | |
189 | if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" ( | |
190 | if "!ENABLED_PLUGINS_FILE!"=="" ( | |
191 | set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins | |
192 | ) else ( | |
193 | set RABBITMQ_ENABLED_PLUGINS_FILE=!ENABLED_PLUGINS_FILE! | |
194 | ) | |
195 | ) | |
196 | ||
197 | REM [ "x" = "x$RABBITMQ_PLUGINS_DIR" ] && RABBITMQ_PLUGINS_DIR=${PLUGINS_DIR} | |
198 | if "!RABBITMQ_PLUGINS_DIR!"=="" ( | |
199 | if "!PLUGINS_DIR!"=="" ( | |
200 | set RABBITMQ_PLUGINS_DIR=!RABBITMQ_BASE!\plugins | |
201 | ) else ( | |
202 | set RABBITMQ_PLUGINS_DIR=!PLUGINS_DIR! | |
203 | ) | |
204 | ) | |
205 | ||
206 | REM ## Log rotation | |
207 | REM [ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS=${LOGS} | |
208 | REM [ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}.log" | |
209 | if "!RABBITMQ_LOGS!"=="" ( | |
210 | if "!LOGS!"=="" ( | |
211 | set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log | |
212 | ) else ( | |
213 | set LOGS=!LOGS! | |
214 | ) | |
215 | ) | |
216 | ||
217 | REM [ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS=${SASL_LOGS} | |
218 | REM [ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}-sasl.log" | |
219 | if "!RABBITMQ_SASL_LOGS!"=="" ( | |
220 | if "!SASL_LOGS!"=="" ( | |
221 | set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log | |
222 | ) else ( | |
223 | set SASL_LOGS=!SASL_LOGS! | |
224 | ) | |
225 | ) | |
226 | ||
227 | REM [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS} | |
228 | if "!$RABBITMQ_CTL_ERL_ARGS!"=="" ( | |
229 | if not "!CTL_ERL_ARGS!"=="" ( | |
230 | set RABBITMQ_CTL_ERL_ARGS=!CTL_ERL_ARGS! | |
231 | ) | |
232 | ) | |
233 | ||
234 | REM ADDITIONAL WINDOWS ONLY CONFIG ITEMS | |
235 | REM rabbitmq-plugins.bat | |
236 | REM if "!RABBITMQ_SERVICENAME!"=="" ( | |
237 | REM set RABBITMQ_SERVICENAME=RabbitMQ | |
238 | REM ) | |
239 | ||
240 | if "!RABBITMQ_SERVICENAME!"=="" ( | |
241 | if "!SERVICENAME!"=="" ( | |
242 | set RABBITMQ_SERVICENAME=RabbitMQ | |
243 | ) else ( | |
244 | set RABBITMQ_SERVICENAME=!SERVICENAME! | |
245 | ) | |
246 | ) | |
247 | ||
248 | REM ##--- End of overridden <var_name> variables | |
249 | REM | |
250 | REM # Since we source this elsewhere, don't accidentally stop execution | |
251 | REM true |
11 | 11 | ## The Original Code is RabbitMQ. |
12 | 12 | ## |
13 | 13 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | ## |
16 | 16 | |
17 | 17 | # Get default settings with user overrides for (RABBITMQ_)<var_name> |
0 | 0 | @echo off |
1 | ||
1 | 2 | REM The contents of this file are subject to the Mozilla Public License |
2 | 3 | REM Version 1.1 (the "License"); you may not use this file except in |
3 | 4 | REM compliance with the License. You may obtain a copy of the License |
11 | 12 | REM The Original Code is RabbitMQ. |
12 | 13 | REM |
13 | 14 | REM The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
15 | REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 16 | REM |
16 | 17 | |
17 | 18 | setlocal |
22 | 23 | set STAR=%* |
23 | 24 | setlocal enabledelayedexpansion |
24 | 25 | |
25 | if "!RABBITMQ_SERVICENAME!"=="" ( | |
26 | set RABBITMQ_SERVICENAME=RabbitMQ | |
27 | ) | |
28 | ||
29 | if "!RABBITMQ_BASE!"=="" ( | |
30 | set RABBITMQ_BASE=!APPDATA!\!RABBITMQ_SERVICENAME! | |
31 | ) | |
32 | ||
33 | if "!RABBITMQ_NODENAME!"=="" ( | |
34 | set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME! | |
35 | ) | |
26 | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | |
27 | REM Non-empty defaults should be set in rabbitmq-env | |
28 | call "!TDP0!\rabbitmq-env.bat" | |
36 | 29 | |
37 | 30 | if not exist "!ERLANG_HOME!\bin\erl.exe" ( |
38 | 31 | echo. |
44 | 37 | echo RabbitMQ server distribution in the Erlang lib folder. |
45 | 38 | echo. |
46 | 39 | exit /B 1 |
47 | ) | |
48 | ||
49 | if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" ( | |
50 | set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins | |
51 | ) | |
52 | ||
53 | if "!RABBITMQ_PLUGINS_DIR!"=="" ( | |
54 | set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins | |
55 | 40 | ) |
56 | 41 | |
57 | 42 | "!ERLANG_HOME!\bin\erl.exe" ^ |
11 | 11 | ## The Original Code is RabbitMQ. |
12 | 12 | ## |
13 | 13 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | ## |
16 | 16 | |
17 | 17 | # Get default settings with user overrides for (RABBITMQ_)<var_name> |
20 | 20 | |
21 | 21 | RABBITMQ_START_RABBIT= |
22 | 22 | [ "x" = "x$RABBITMQ_ALLOW_INPUT" ] && RABBITMQ_START_RABBIT=" -noinput" |
23 | [ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s rabbit boot " | |
23 | [ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s $RABBITMQ_BOOT_MODULE boot " | |
24 | 24 | |
25 | 25 | case "$(uname -s)" in |
26 | 26 | CYGWIN*) # we make no attempt to record the cygwin pid; rabbitmqctl wait |
75 | 75 | RABBITMQ_LISTEN_ARG= |
76 | 76 | [ "x" != "x$RABBITMQ_NODE_PORT" ] && [ "x" != "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_LISTEN_ARG="-rabbit tcp_listeners [{\""${RABBITMQ_NODE_IP_ADDRESS}"\","${RABBITMQ_NODE_PORT}"}]" |
77 | 77 | |
78 | # If $RABBITMQ_LOGS is '-', send all log messages to stdout. Likewise | |
79 | # for RABBITMQ_SASL_LOGS. This is particularily useful for Docker | |
80 | # images. | |
81 | ||
82 | if [ "$RABBITMQ_LOGS" = '-' ]; then | |
83 | RABBIT_ERROR_LOGGER='tty' | |
84 | else | |
85 | RABBIT_ERROR_LOGGER='{file,"'${RABBITMQ_LOGS}'"}' | |
86 | fi | |
87 | ||
88 | if [ "$RABBITMQ_SASL_LOGS" = '-' ]; then | |
89 | SASL_ERROR_LOGGER=tty | |
90 | RABBIT_SASL_ERROR_LOGGER='tty' | |
91 | else | |
92 | SASL_ERROR_LOGGER=false | |
93 | RABBIT_SASL_ERROR_LOGGER='{file,"'${RABBITMQ_SASL_LOGS}'"}' | |
94 | fi | |
95 | ||
78 | 96 | # we need to turn off path expansion because some of the vars, notably |
79 | 97 | # RABBITMQ_SERVER_ERL_ARGS, contain terms that look like globs and |
80 | 98 | # there is no other way of preventing their expansion. |
88 | 106 | -boot "${SASL_BOOT_FILE}" \ |
89 | 107 | ${RABBITMQ_CONFIG_ARG} \ |
90 | 108 | +W w \ |
109 | +A ${RABBITMQ_IO_THREAD_POOL_SIZE} \ | |
91 | 110 | ${RABBITMQ_SERVER_ERL_ARGS} \ |
111 | +K true \ | |
112 | -kernel inet_default_connect_options "[{nodelay,true}]" \ | |
92 | 113 | ${RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS} \ |
93 | 114 | ${RABBITMQ_LISTEN_ARG} \ |
94 | 115 | -sasl errlog_type error \ |
95 | -sasl sasl_error_logger false \ | |
96 | -rabbit error_logger '{file,"'${RABBITMQ_LOGS}'"}' \ | |
97 | -rabbit sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \ | |
116 | -sasl sasl_error_logger "$SASL_ERROR_LOGGER" \ | |
117 | -rabbit error_logger "$RABBIT_ERROR_LOGGER" \ | |
118 | -rabbit sasl_error_logger "$RABBIT_SASL_ERROR_LOGGER" \ | |
98 | 119 | -rabbit enabled_plugins_file "\"$RABBITMQ_ENABLED_PLUGINS_FILE\"" \ |
99 | 120 | -rabbit plugins_dir "\"$RABBITMQ_PLUGINS_DIR\"" \ |
100 | 121 | -rabbit plugins_expand_dir "\"$RABBITMQ_PLUGINS_EXPAND_DIR\"" \ |
11 | 11 | REM The Original Code is RabbitMQ. |
12 | 12 | REM |
13 | 13 | REM The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | REM |
16 | 16 | |
17 | 17 | setlocal |
22 | 22 | set STAR=%* |
23 | 23 | setlocal enabledelayedexpansion |
24 | 24 | |
25 | if "!RABBITMQ_USE_LONGNAME!"=="" ( | |
26 | set RABBITMQ_NAME_TYPE="-sname" | |
27 | ) | |
28 | ||
29 | if "!RABBITMQ_USE_LONGNAME!"=="true" ( | |
30 | set RABBITMQ_NAME_TYPE="-name" | |
31 | ) | |
32 | ||
33 | if "!RABBITMQ_BASE!"=="" ( | |
34 | set RABBITMQ_BASE=!APPDATA!\RabbitMQ | |
35 | ) | |
36 | ||
37 | if "!COMPUTERNAME!"=="" ( | |
38 | set COMPUTERNAME=localhost | |
39 | ) | |
40 | ||
41 | if "!RABBITMQ_NODENAME!"=="" ( | |
42 | set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME! | |
43 | ) | |
44 | ||
45 | if "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( | |
46 | if not "!RABBITMQ_NODE_PORT!"=="" ( | |
47 | set RABBITMQ_NODE_IP_ADDRESS=auto | |
48 | ) | |
49 | ) else ( | |
50 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
51 | set RABBITMQ_NODE_PORT=5672 | |
52 | ) | |
53 | ) | |
54 | ||
55 | if "!RABBITMQ_DIST_PORT!"=="" ( | |
56 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
57 | set RABBITMQ_DIST_PORT=25672 | |
58 | ) else ( | |
59 | set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT! | |
60 | ) | |
61 | ) | |
25 | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | |
26 | REM Non-empty defaults should be set in rabbitmq-env | |
27 | call "%TDP0%\rabbitmq-env.bat" | |
62 | 28 | |
63 | 29 | if not exist "!ERLANG_HOME!\bin\erl.exe" ( |
64 | 30 | echo. |
70 | 36 | echo RabbitMQ server distribution in the Erlang lib folder. |
71 | 37 | echo. |
72 | 38 | exit /B 1 |
73 | ) | |
74 | ||
75 | if "!RABBITMQ_MNESIA_BASE!"=="" ( | |
76 | set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db | |
77 | ) | |
78 | if "!RABBITMQ_LOG_BASE!"=="" ( | |
79 | set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!/log | |
80 | ) | |
81 | ||
82 | ||
83 | rem We save the previous logs in their respective backup | |
84 | rem Log management (rotation, filtering based of size...) is left as an exercice for the user. | |
85 | ||
86 | set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log | |
87 | set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log | |
88 | ||
89 | rem End of log management | |
90 | ||
91 | ||
92 | if "!RABBITMQ_MNESIA_DIR!"=="" ( | |
93 | set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia | |
94 | ) | |
95 | ||
96 | if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" ( | |
97 | set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand | |
98 | ) | |
99 | ||
100 | if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" ( | |
101 | set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins | |
102 | ) | |
103 | ||
104 | if "!RABBITMQ_PLUGINS_DIR!"=="" ( | |
105 | set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins | |
106 | 39 | ) |
107 | 40 | |
108 | 41 | set RABBITMQ_EBIN_ROOT=!TDP0!..\ebin |
124 | 57 | |
125 | 58 | set RABBITMQ_EBIN_PATH="-pa !RABBITMQ_EBIN_ROOT!" |
126 | 59 | |
127 | if "!RABBITMQ_CONFIG_FILE!"=="" ( | |
128 | set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq | |
129 | ) | |
130 | ||
131 | 60 | if exist "!RABBITMQ_CONFIG_FILE!.config" ( |
132 | 61 | set RABBITMQ_CONFIG_ARG=-config "!RABBITMQ_CONFIG_FILE!" |
133 | 62 | ) else ( |
143 | 72 | |
144 | 73 | set RABBITMQ_START_RABBIT= |
145 | 74 | if "!RABBITMQ_NODE_ONLY!"=="" ( |
146 | set RABBITMQ_START_RABBIT=-s rabbit boot | |
75 | set RABBITMQ_START_RABBIT=-s "!RABBITMQ_BOOT_MODULE!" boot | |
76 | ) | |
77 | ||
78 | if "!RABBITMQ_IO_THREAD_POOL_SIZE!"=="" ( | |
79 | set RABBITMQ_IO_THREAD_POOL_ARG=30 | |
147 | 80 | ) |
148 | 81 | |
149 | 82 | "!ERLANG_HOME!\bin\erl.exe" ^ |
154 | 87 | !RABBITMQ_CONFIG_ARG! ^ |
155 | 88 | !RABBITMQ_NAME_TYPE! !RABBITMQ_NODENAME! ^ |
156 | 89 | +W w ^ |
157 | +A30 ^ | |
90 | +A "!RABBITMQ_IO_THREAD_POOL_SIZE!" ^ | |
158 | 91 | +P 1048576 ^ |
159 | -kernel inet_default_connect_options "[{nodelay, true}]" ^ | |
160 | 92 | !RABBITMQ_LISTEN_ARG! ^ |
161 | 93 | !RABBITMQ_SERVER_ERL_ARGS! ^ |
94 | -kernel inet_default_connect_options "[{nodelay, true}]" ^ | |
162 | 95 | !RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS! ^ |
163 | 96 | -sasl errlog_type error ^ |
164 | 97 | -sasl sasl_error_logger false ^ |
11 | 11 | REM The Original Code is RabbitMQ. |
12 | 12 | REM |
13 | 13 | REM The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | REM |
16 | 16 | |
17 | 17 | setlocal |
22 | 22 | set TDP0=%~dp0 |
23 | 23 | set P1=%1 |
24 | 24 | setlocal enabledelayedexpansion |
25 | ||
26 | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | |
27 | REM Non-empty defaults should be set in rabbitmq-env | |
28 | call "%TDP0%\rabbitmq-env.bat" | |
25 | 29 | |
26 | 30 | set STARVAR= |
27 | 31 | shift |
31 | 35 | shift |
32 | 36 | goto loop1 |
33 | 37 | :after_loop |
34 | ||
35 | if "!RABBITMQ_USE_LONGNAME!"=="" ( | |
36 | set RABBITMQ_NAME_TYPE="-sname" | |
37 | ) | |
38 | ||
39 | if "!RABBITMQ_USE_LONGNAME!"=="true" ( | |
40 | set RABBITMQ_NAME_TYPE="-name" | |
41 | ) | |
42 | ||
43 | if "!RABBITMQ_SERVICENAME!"=="" ( | |
44 | set RABBITMQ_SERVICENAME=RabbitMQ | |
45 | ) | |
46 | ||
47 | if "!RABBITMQ_BASE!"=="" ( | |
48 | set RABBITMQ_BASE=!APPDATA!\!RABBITMQ_SERVICENAME! | |
49 | ) | |
50 | ||
51 | if "!COMPUTERNAME!"=="" ( | |
52 | set COMPUTERNAME=localhost | |
53 | ) | |
54 | ||
55 | if "!RABBITMQ_NODENAME!"=="" ( | |
56 | set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME! | |
57 | ) | |
58 | ||
59 | if "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( | |
60 | if not "!RABBITMQ_NODE_PORT!"=="" ( | |
61 | set RABBITMQ_NODE_IP_ADDRESS=auto | |
62 | ) | |
63 | ) else ( | |
64 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
65 | set RABBITMQ_NODE_PORT=5672 | |
66 | ) | |
67 | ) | |
68 | ||
69 | if "!RABBITMQ_DIST_PORT!"=="" ( | |
70 | if "!RABBITMQ_NODE_PORT!"=="" ( | |
71 | set RABBITMQ_DIST_PORT=25672 | |
72 | ) else ( | |
73 | set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT! | |
74 | ) | |
75 | ) | |
76 | 38 | |
77 | 39 | if "!ERLANG_SERVICE_MANAGER_PATH!"=="" ( |
78 | 40 | if not exist "!ERLANG_HOME!\bin\erl.exe" ( |
112 | 74 | exit /B 1 |
113 | 75 | ) |
114 | 76 | |
115 | if "!RABBITMQ_MNESIA_BASE!"=="" ( | |
116 | set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db | |
117 | ) | |
118 | if "!RABBITMQ_LOG_BASE!"=="" ( | |
119 | set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!/log | |
120 | ) | |
121 | ||
122 | ||
123 | rem We save the previous logs in their respective backup | |
124 | rem Log management (rotation, filtering based on size...) is left as an exercise for the user. | |
125 | ||
126 | set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log | |
127 | set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log | |
128 | ||
129 | rem End of log management | |
130 | ||
131 | ||
132 | if "!RABBITMQ_MNESIA_DIR!"=="" ( | |
133 | set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia | |
134 | ) | |
135 | ||
136 | if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" ( | |
137 | set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand | |
138 | ) | |
139 | ||
140 | 77 | if "!P1!" == "install" goto INSTALL_SERVICE |
141 | 78 | for %%i in (start stop disable enable list remove) do if "%%i" == "!P1!" goto MODIFY_SERVICE |
142 | 79 | |
173 | 110 | echo !RABBITMQ_SERVICENAME! service is already present - only updating service parameters |
174 | 111 | ) |
175 | 112 | |
176 | if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" ( | |
177 | set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins | |
178 | ) | |
179 | ||
180 | if "!RABBITMQ_PLUGINS_DIR!"=="" ( | |
181 | set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins | |
182 | ) | |
183 | ||
184 | 113 | set RABBITMQ_EBIN_ROOT=!TDP0!..\ebin |
185 | ||
186 | if "!RABBITMQ_CONFIG_FILE!"=="" ( | |
187 | set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq | |
188 | ) | |
189 | 114 | |
190 | 115 | "!ERLANG_HOME!\bin\erl.exe" ^ |
191 | 116 | -pa "!RABBITMQ_EBIN_ROOT!" ^ |
223 | 148 | set RABBITMQ_START_RABBIT=-s rabbit boot |
224 | 149 | ) |
225 | 150 | |
151 | if "!RABBITMQ_IO_THREAD_POOL_SIZE!"=="" ( | |
152 | set RABBITMQ_IO_THREAD_POOL_SIZE=30 | |
153 | ) | |
154 | ||
226 | 155 | set ERLANG_SERVICE_ARGUMENTS= ^ |
227 | 156 | -pa "!RABBITMQ_EBIN_ROOT!" ^ |
157 | -boot start_sasl ^ | |
228 | 158 | !RABBITMQ_START_RABBIT! ^ |
229 | -s rabbit boot ^ | |
230 | 159 | !RABBITMQ_CONFIG_ARG! ^ |
231 | 160 | +W w ^ |
232 | +A30 ^ | |
161 | +A "!RABBITMQ_IO_THREAD_POOL_SIZE!" ^ | |
233 | 162 | +P 1048576 ^ |
234 | 163 | -kernel inet_default_connect_options "[{nodelay,true}]" ^ |
235 | 164 | !RABBITMQ_LISTEN_ARG! ^ |
11 | 11 | ## The Original Code is RabbitMQ. |
12 | 12 | ## |
13 | 13 | ## The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | ## |
16 | 16 | |
17 | 17 | # Get default settings with user overrides for (RABBITMQ_)<var_name> |
11 | 11 | REM The Original Code is RabbitMQ. |
12 | 12 | REM |
13 | 13 | REM The Initial Developer of the Original Code is GoPivotal, Inc. |
14 | REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
14 | REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
15 | 15 | REM |
16 | 16 | |
17 | REM Scopes the variables to the current batch file | |
17 | 18 | setlocal |
18 | 19 | |
19 | 20 | rem Preserve values that might contain exclamation marks before |
21 | 22 | set TDP0=%~dp0 |
22 | 23 | set STAR=%* |
23 | 24 | setlocal enabledelayedexpansion |
24 | ||
25 | if "!RABBITMQ_BASE!"=="" ( | |
26 | set RABBITMQ_BASE=!APPDATA!\RabbitMQ | |
27 | ) | |
28 | ||
29 | if "!COMPUTERNAME!"=="" ( | |
30 | set COMPUTERNAME=localhost | |
31 | ) | |
32 | ||
33 | if "!RABBITMQ_NODENAME!"=="" ( | |
34 | set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME! | |
35 | ) | |
36 | ||
37 | if "!RABBITMQ_MNESIA_BASE!"=="" ( | |
38 | set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db | |
39 | ) | |
40 | ||
41 | if "!RABBITMQ_MNESIA_DIR!"=="" ( | |
42 | set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia | |
43 | ) | |
44 | 25 | |
45 | 26 | if not exist "!ERLANG_HOME!\bin\erl.exe" ( |
46 | 27 | echo. |
53 | 34 | echo. |
54 | 35 | exit /B 1 |
55 | 36 | ) |
37 | ||
38 | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | |
39 | REM Non-empty defaults should be set in rabbitmq-env | |
40 | call "%TDP0%\rabbitmq-env.bat" | |
56 | 41 | |
57 | 42 | "!ERLANG_HOME!\bin\erl.exe" ^ |
58 | 43 | -pa "!TDP0!..\ebin" ^ |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | -module(app_utils). |
16 | 16 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(background_gc). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(credit_flow). |
67 | 67 | put(Key, Expr) |
68 | 68 | end). |
69 | 69 | |
70 | %% If current process was blocked by credit flow in the last | |
71 | %% STATE_CHANGE_INTERVAL milliseconds, state/0 will report it as "in | |
72 | %% flow". | |
73 | -define(STATE_CHANGE_INTERVAL, 1000000). | |
74 | ||
70 | 75 | %%---------------------------------------------------------------------------- |
71 | 76 | |
72 | 77 | %% There are two "flows" here; of messages and of credit, going in |
116 | 121 | false -> case get(credit_blocked_at) of |
117 | 122 | undefined -> running; |
118 | 123 | B -> Diff = timer:now_diff(erlang:now(), B), |
119 | case Diff < 5000000 of | |
124 | case Diff < ?STATE_CHANGE_INTERVAL of | |
120 | 125 | true -> flow; |
121 | 126 | false -> running |
122 | 127 | end |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(delegate). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(delegate_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% A dual-index tree. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(file_handle_cache). |
147 | 147 | copy/3, set_maximum_since_use/1, delete/1, clear/1]). |
148 | 148 | -export([obtain/0, obtain/1, release/0, release/1, transfer/1, transfer/2, |
149 | 149 | set_limit/1, get_limit/0, info_keys/0, with_handle/1, with_handle/2, |
150 | info/0, info/1]). | |
150 | info/0, info/1, clear_read_cache/0]). | |
151 | 151 | -export([ulimit/0]). |
152 | 152 | |
153 | 153 | -export([start_link/0, start_link/2, init/1, handle_call/3, handle_cast/2, |
162 | 162 | -define(OBTAIN_LIMIT(LIMIT), trunc((LIMIT * 0.9) - 2)). |
163 | 163 | -define(CLIENT_ETS_TABLE, file_handle_cache_client). |
164 | 164 | -define(ELDERS_ETS_TABLE, file_handle_cache_elders). |
165 | ||
166 | -include("rabbit.hrl"). % For #amqqueue record definition. | |
165 | 167 | |
166 | 168 | %%---------------------------------------------------------------------------- |
167 | 169 | |
352 | 354 | read_buffer_rem = BufRem - Count, |
353 | 355 | read_buffer_usage = BufUsg + Count }]}; |
354 | 356 | ([Handle0]) -> |
357 | maybe_reduce_read_cache([Ref]), | |
355 | 358 | Handle = #handle{read_buffer = Buf, |
356 | 359 | read_buffer_pos = BufPos, |
357 | 360 | read_buffer_rem = BufRem, |
579 | 582 | info() -> info(?INFO_KEYS). |
580 | 583 | info(Items) -> gen_server2:call(?SERVER, {info, Items}, infinity). |
581 | 584 | |
585 | clear_read_cache() -> | |
586 | gen_server2:cast(?SERVER, clear_read_cache), | |
587 | clear_vhost_read_cache(rabbit_vhost:list()). | |
588 | ||
589 | clear_vhost_read_cache([]) -> | |
590 | ok; | |
591 | clear_vhost_read_cache([VHost | Rest]) -> | |
592 | clear_queue_read_cache(rabbit_amqqueue:list(VHost)), | |
593 | clear_vhost_read_cache(Rest). | |
594 | ||
595 | clear_queue_read_cache([]) -> | |
596 | ok; | |
597 | clear_queue_read_cache([#amqqueue{pid = MPid, slave_pids = SPids} | Rest]) -> | |
598 | %% Limit the action to the current node. | |
599 | Pids = [P || P <- [MPid | SPids], node(P) =:= node()], | |
600 | %% This function is executed in the context of the backing queue | |
601 | %% process because the read buffer is stored in the process | |
602 | %% dictionary. | |
603 | Fun = fun(_, State) -> | |
604 | clear_process_read_cache(), | |
605 | State | |
606 | end, | |
607 | [rabbit_amqqueue:run_backing_queue(Pid, rabbit_variable_queue, Fun) | |
608 | || Pid <- Pids], | |
609 | clear_queue_read_cache(Rest). | |
610 | ||
611 | clear_process_read_cache() -> | |
612 | [ | |
613 | begin | |
614 | Handle1 = reset_read_buffer(Handle), | |
615 | put({Ref, fhc_handle}, Handle1) | |
616 | end || | |
617 | {{Ref, fhc_handle}, Handle} <- get(), | |
618 | size(Handle#handle.read_buffer) > 0 | |
619 | ]. | |
620 | ||
582 | 621 | %%---------------------------------------------------------------------------- |
583 | 622 | %% Internal functions |
584 | 623 | %%---------------------------------------------------------------------------- |
961 | 1000 | false -> Usg * 2 |
962 | 1001 | end, Lim)}. |
963 | 1002 | |
1003 | maybe_reduce_read_cache(SparedRefs) -> | |
1004 | case rabbit_memory_monitor:memory_use(bytes) of | |
1005 | {_, infinity} -> ok; | |
1006 | {MemUse, MemLimit} when MemUse < MemLimit -> ok; | |
1007 | {MemUse, MemLimit} -> reduce_read_cache( | |
1008 | (MemUse - MemLimit) * 2, | |
1009 | SparedRefs) | |
1010 | end. | |
1011 | ||
1012 | reduce_read_cache(MemToFree, SparedRefs) -> | |
1013 | Handles = lists:sort( | |
1014 | fun({_, H1}, {_, H2}) -> H1 < H2 end, | |
1015 | [{R, H} || {{R, fhc_handle}, H} <- get(), | |
1016 | not lists:member(R, SparedRefs) | |
1017 | andalso size(H#handle.read_buffer) > 0]), | |
1018 | FreedMem = lists:foldl( | |
1019 | fun | |
1020 | (_, Freed) when Freed >= MemToFree -> | |
1021 | Freed; | |
1022 | ({Ref, #handle{read_buffer = Buf} = Handle}, Freed) -> | |
1023 | Handle1 = reset_read_buffer(Handle), | |
1024 | put({Ref, fhc_handle}, Handle1), | |
1025 | Freed + size(Buf) | |
1026 | end, 0, Handles), | |
1027 | if | |
1028 | FreedMem < MemToFree andalso SparedRefs =/= [] -> | |
1029 | reduce_read_cache(MemToFree - FreedMem, []); | |
1030 | true -> | |
1031 | ok | |
1032 | end. | |
1033 | ||
964 | 1034 | infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items]. |
965 | 1035 | |
966 | 1036 | i(total_limit, #fhc_state{limit = Limit}) -> Limit; |
1114 | 1184 | {noreply, process_pending( |
1115 | 1185 | update_counts({obtain, socket}, ToPid, +N, |
1116 | 1186 | update_counts({obtain, socket}, FromPid, -N, |
1117 | State)))}. | |
1187 | State)))}; | |
1188 | ||
1189 | handle_cast(clear_read_cache, State) -> | |
1190 | clear_process_read_cache(), | |
1191 | {noreply, State}. | |
1118 | 1192 | |
1119 | 1193 | handle_info(check_counts, State) -> |
1120 | 1194 | {noreply, maybe_reduce(State #fhc_state { timer_ref = undefined })}; |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(file_handle_cache_stats). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(gatherer). |
575 | 575 | {ok, State, Timeout, Backoff = {backoff, _, _, _}, Mod1} -> |
576 | 576 | Backoff1 = extend_backoff(Backoff), |
577 | 577 | proc_lib:init_ack(Starter, {ok, self()}), |
578 | loop(GS2State #gs2_state { mod = Mod1, | |
579 | state = State, | |
580 | time = Timeout, | |
581 | timeout_state = Backoff1 }); | |
578 | loop(find_prioritisers( | |
579 | GS2State #gs2_state { mod = Mod1, | |
580 | state = State, | |
581 | time = Timeout, | |
582 | timeout_state = Backoff1 })); | |
582 | 583 | {stop, Reason} -> |
583 | 584 | %% For consistency, we must make sure that the |
584 | 585 | %% registered name (if any) is unregistered before |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(gm). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(lqueue). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(mirrored_supervisor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(mirrored_supervisor_sups). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(mnesia_sync). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(pmon). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% Priority queues have essentially the same interface as ordinary |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit). |
39 | 39 | {requires, pre_boot}, |
40 | 40 | {enables, external_infrastructure}]}). |
41 | 41 | |
42 | %% rabbit_alarm currently starts memory and disk space monitors | |
43 | -rabbit_boot_step({rabbit_alarm, | |
44 | [{description, "alarm handler"}, | |
45 | {mfa, {rabbit_alarm, start, []}}, | |
46 | {requires, pre_boot}, | |
47 | {enables, external_infrastructure}]}). | |
48 | ||
42 | 49 | -rabbit_boot_step({database, |
43 | 50 | [{mfa, {rabbit_mnesia, init, []}}, |
44 | 51 | {requires, file_handle_cache}, |
53 | 60 | -rabbit_boot_step({file_handle_cache, |
54 | 61 | [{description, "file handle cache server"}, |
55 | 62 | {mfa, {rabbit, start_fhc, []}}, |
56 | {requires, pre_boot}, | |
63 | %% FHC needs memory monitor to be running | |
64 | {requires, rabbit_alarm}, | |
57 | 65 | {enables, worker_pool}]}). |
58 | 66 | |
59 | 67 | -rabbit_boot_step({worker_pool, |
83 | 91 | -rabbit_boot_step({kernel_ready, |
84 | 92 | [{description, "kernel ready"}, |
85 | 93 | {requires, external_infrastructure}]}). |
86 | ||
87 | -rabbit_boot_step({rabbit_alarm, | |
88 | [{description, "alarm handler"}, | |
89 | {mfa, {rabbit_alarm, start, []}}, | |
90 | {requires, kernel_ready}, | |
91 | {enables, core_initialized}]}). | |
92 | 94 | |
93 | 95 | -rabbit_boot_step({rabbit_memory_monitor, |
94 | 96 | [{description, "memory monitor"}, |
882 | 884 | %% We don't want this in fhc since it references rabbit stuff. And we can't put |
883 | 885 | %% this in the bootstep directly. |
884 | 886 | start_fhc() -> |
885 | rabbit_sup:start_restartable_child( | |
887 | ok = rabbit_sup:start_restartable_child( | |
886 | 888 | file_handle_cache, |
887 | [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]). | |
889 | [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]), | |
890 | ensure_working_fhc(). | |
891 | ||
892 | ensure_working_fhc() -> | |
893 | %% To test the file handle cache, we simply read a file we know it | |
894 | %% exists (Erlang kernel's .app file). | |
895 | %% | |
896 | %% To avoid any pollution of the application process' dictionary by | |
897 | %% file_handle_cache, we spawn a separate process. | |
898 | Parent = self(), | |
899 | TestFun = fun() -> | |
900 | Filename = filename:join(code:lib_dir(kernel, ebin), "kernel.app"), | |
901 | {ok, Fd} = file_handle_cache:open(Filename, [raw, binary, read], []), | |
902 | {ok, _} = file_handle_cache:read(Fd, 1), | |
903 | ok = file_handle_cache:close(Fd), | |
904 | Parent ! fhc_ok | |
905 | end, | |
906 | TestPid = spawn_link(TestFun), | |
907 | %% Because we are waiting for the test fun, abuse the | |
908 | %% 'mnesia_table_loading_timeout' parameter to find a sane timeout | |
909 | %% value. | |
910 | Timeout = rabbit_table:wait_timeout(), | |
911 | receive | |
912 | fhc_ok -> ok; | |
913 | {'EXIT', TestPid, Exception} -> throw({ensure_working_fhc, Exception}) | |
914 | after Timeout -> | |
915 | throw({ensure_working_fhc, {timeout, TestPid}}) | |
916 | end. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_access_control). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_alarm). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_amqqueue). |
781 | 781 | fun () -> |
782 | 782 | Qs = mnesia:match_object(rabbit_queue, |
783 | 783 | #amqqueue{_ = '_'}, write), |
784 | [case lists:member(Node, RSs) of | |
785 | true -> RSs1 = RSs -- [Node], | |
786 | store_queue( | |
787 | Q#amqqueue{recoverable_slaves = RSs1}); | |
788 | false -> ok | |
789 | end || #amqqueue{recoverable_slaves = RSs} = Q <- Qs], | |
784 | [maybe_clear_recoverable_node(Node, Q) || Q <- Qs], | |
790 | 785 | ok |
791 | 786 | end). |
787 | ||
788 | maybe_clear_recoverable_node(Node, | |
789 | #amqqueue{sync_slave_pids = SPids, | |
790 | recoverable_slaves = RSs} = Q) -> | |
791 | case lists:member(Node, RSs) of | |
792 | true -> | |
793 | %% There is a race with | |
794 | %% rabbit_mirror_queue_slave:record_synchronised/1 called | |
795 | %% by the incoming slave node and this function, called | |
796 | %% by the master node. If this function is executed after | |
797 | %% record_synchronised/1, the node is erroneously removed | |
798 | %% from the recoverable slaves list. | |
799 | %% | |
800 | %% We check if the slave node's queue PID is alive. If it is | |
801 | %% the case, then this function is executed after. In this | |
802 | %% situation, we don't touch the queue record, it is already | |
803 | %% correct. | |
804 | DoClearNode = | |
805 | case [SP || SP <- SPids, node(SP) =:= Node] of | |
806 | [SPid] -> not rabbit_misc:is_process_alive(SPid); | |
807 | _ -> true | |
808 | end, | |
809 | if | |
810 | DoClearNode -> RSs1 = RSs -- [Node], | |
811 | store_queue( | |
812 | Q#amqqueue{recoverable_slaves = RSs1}); | |
813 | true -> ok | |
814 | end; | |
815 | false -> | |
816 | ok | |
817 | end. | |
792 | 818 | |
793 | 819 | on_node_down(Node) -> |
794 | 820 | rabbit_misc:execute_mnesia_tx_with_tail( |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_amqqueue_process). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_amqqueue_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_amqqueue_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_dummy). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_backend_internal). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_mechanism). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_mechanism_amqplain). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_mechanism_cr_demo). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_auth_mechanism_plain). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_authn_backend). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_authz_backend). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_autoheal). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_backing_queue). |
251 | 251 | |
252 | 252 | behaviour_info(callbacks) -> |
253 | 253 | [{start, 1}, {stop, 0}, {init, 3}, {terminate, 2}, |
254 | {delete_and_terminate, 2}, {purge, 1}, {purge_acks, 1}, {publish, 6}, | |
254 | {delete_and_terminate, 2}, {delete_crashed, 1}, {purge, 1}, | |
255 | {purge_acks, 1}, {publish, 6}, | |
255 | 256 | {publish_delivered, 5}, {discard, 4}, {drain_confirmed, 1}, |
256 | {dropwhile, 2}, {fetchwhile, 4}, | |
257 | {fetch, 2}, {ack, 2}, {requeue, 2}, {ackfold, 4}, {fold, 3}, {len, 1}, | |
257 | {dropwhile, 2}, {fetchwhile, 4}, {fetch, 2}, | |
258 | {drop, 2}, {ack, 2}, {requeue, 2}, {ackfold, 4}, {fold, 3}, {len, 1}, | |
258 | 259 | {is_empty, 1}, {depth, 1}, {set_ram_duration_target, 2}, |
259 | 260 | {ram_duration, 1}, {needs_timeout, 1}, {timeout, 1}, |
260 | 261 | {handle_pre_hibernate, 1}, {resume, 1}, {msg_rates, 1}, |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_basic). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_binary_generator). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_binary_parser). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_binding). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_channel). |
39 | 39 | queue_consumers, delivering_queues, |
40 | 40 | queue_collector_pid, stats_timer, confirm_enabled, publish_seqno, |
41 | 41 | unconfirmed, confirmed, mandatory, capabilities, trace_state, |
42 | consumer_prefetch, reply_consumer}). | |
42 | consumer_prefetch, reply_consumer, | |
43 | %% flow | noflow, see rabbitmq-server#114 | |
44 | delivery_flow}). | |
43 | 45 | |
44 | 46 | -define(MAX_PERMISSION_CACHE_SIZE, 12). |
45 | 47 | |
234 | 236 | process_flag(trap_exit, true), |
235 | 237 | ?store_proc_name({ConnName, Channel}), |
236 | 238 | ok = pg_local:join(rabbit_channels, self()), |
239 | Flow = case rabbit_misc:get_env(rabbit, mirroring_flow_control, true) of | |
240 | true -> flow; | |
241 | false -> noflow | |
242 | end, | |
237 | 243 | State = #ch{state = starting, |
238 | 244 | protocol = Protocol, |
239 | 245 | channel = Channel, |
262 | 268 | capabilities = Capabilities, |
263 | 269 | trace_state = rabbit_trace:init(VHost), |
264 | 270 | consumer_prefetch = 0, |
265 | reply_consumer = none}, | |
271 | reply_consumer = none, | |
272 | delivery_flow = Flow}, | |
266 | 273 | State1 = rabbit_event:init_stats_timer(State, #ch.stats_timer), |
267 | 274 | rabbit_event:notify(channel_created, infos(?CREATION_EVENT_KEYS, State1)), |
268 | 275 | rabbit_event:if_enabled(State1, #ch.stats_timer, |
769 | 776 | confirm_enabled = ConfirmEnabled, |
770 | 777 | trace_state = TraceState, |
771 | 778 | user = #user{username = Username}, |
772 | conn_name = ConnName}) -> | |
779 | conn_name = ConnName, | |
780 | delivery_flow = Flow}) -> | |
773 | 781 | check_msg_size(Content), |
774 | 782 | ExchangeName = rabbit_misc:r(VHostPath, exchange, ExchangeNameBin), |
775 | 783 | check_write_permitted(ExchangeName, State), |
796 | 804 | QNames = rabbit_exchange:route(Exchange, Delivery), |
797 | 805 | rabbit_trace:tap_in(Message, QNames, ConnName, ChannelNum, |
798 | 806 | Username, TraceState), |
799 | DQ = {Delivery#delivery{flow = flow}, QNames}, | |
807 | DQ = {Delivery#delivery{flow = Flow}, QNames}, | |
800 | 808 | {noreply, case Tx of |
801 | 809 | none -> deliver_to_queues(DQ, State1); |
802 | 810 | {Msgs, Acks} -> Msgs1 = queue:in(DQ, Msgs), |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% Since the AMQP methods used here are queue related, |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_channel_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_channel_sup_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_cli). |
17 | 17 | -include("rabbit_cli.hrl"). |
18 | 18 | |
19 | 19 | -export([main/3, start_distribution/0, start_distribution/1, |
20 | parse_arguments/4, rpc_call/4]). | |
20 | parse_arguments/4, rpc_call/4, rpc_call/5]). | |
21 | 21 | |
22 | 22 | %%---------------------------------------------------------------------------- |
23 | 23 | |
93 | 93 | print_error("~p", [Reason]), |
94 | 94 | rabbit_misc:quit(2); |
95 | 95 | {badrpc, Reason} -> |
96 | print_error("unable to connect to node ~w: ~w", [Node, Reason]), | |
97 | print_badrpc_diagnostics([Node]), | |
96 | case Reason of | |
97 | timeout -> | |
98 | print_error("operation ~w on node ~w timed out", [Command, Node]); | |
99 | _ -> | |
100 | print_error("unable to connect to node ~w: ~w", [Node, Reason]), | |
101 | print_badrpc_diagnostics([Node]) | |
102 | end, | |
98 | 103 | rabbit_misc:quit(2); |
99 | 104 | {badrpc_multi, Reason, Nodes} -> |
100 | 105 | print_error("unable to connect to nodes ~p: ~w", [Nodes, Reason]), |
209 | 214 | %% a timeout unless we set our ticktime to be the same. So let's do |
210 | 215 | %% that. |
211 | 216 | rpc_call(Node, Mod, Fun, Args) -> |
212 | case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of | |
217 | rpc_call(Node, Mod, Fun, Args, ?RPC_TIMEOUT). | |
218 | ||
219 | rpc_call(Node, Mod, Fun, Args, Timeout) -> | |
220 | case rpc:call(Node, net_kernel, get_net_ticktime, [], Timeout) of | |
213 | 221 | {badrpc, _} = E -> E; |
214 | 222 | Time -> net_kernel:set_net_ticktime(Time, 0), |
215 | rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT) | |
216 | end. | |
223 | rpc:call(Node, Mod, Fun, Args, Timeout) | |
224 | end. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_client_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_command_assembler). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_connection_helper_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_connection_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_control_main). |
18 | 18 | -include("rabbit_cli.hrl"). |
19 | 19 | |
20 | 20 | -export([start/0, stop/0, parse_arguments/2, action/5, |
21 | sync_queue/1, cancel_sync_queue/1, become/1]). | |
22 | ||
23 | -import(rabbit_cli, [rpc_call/4]). | |
21 | sync_queue/1, cancel_sync_queue/1, become/1, | |
22 | purge_queue/1]). | |
23 | ||
24 | -import(rabbit_cli, [rpc_call/4, rpc_call/5]). | |
24 | 25 | |
25 | 26 | -define(EXTERNAL_CHECK_INTERVAL, 1000). |
26 | 27 | |
27 | -define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node)]). | |
28 | -define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node), ?TIMEOUT_DEF]). | |
28 | 29 | |
29 | 30 | -define(COMMANDS, |
30 | 31 | [stop, |
44 | 45 | cluster_status, |
45 | 46 | {sync_queue, [?VHOST_DEF]}, |
46 | 47 | {cancel_sync_queue, [?VHOST_DEF]}, |
48 | {purge_queue, [?VHOST_DEF]}, | |
47 | 49 | |
48 | 50 | add_user, |
49 | 51 | delete_user, |
107 | 109 | forget_cluster_node, rename_cluster_node, cluster_status, status, |
108 | 110 | environment, eval, force_boot]). |
109 | 111 | |
112 | -define(COMMANDS_WITH_TIMEOUT, | |
113 | [list_user_permissions, list_policies, list_queues, list_exchanges, | |
114 | list_bindings, list_connections, list_channels, list_consumers, | |
115 | list_vhosts, list_parameters, | |
116 | purge_queue]). | |
117 | ||
110 | 118 | %%---------------------------------------------------------------------------- |
111 | 119 | |
112 | 120 | -ifdef(use_specs). |
116 | 124 | -spec(action/5 :: |
117 | 125 | (atom(), node(), [string()], [{string(), any()}], |
118 | 126 | fun ((string(), [any()]) -> 'ok')) |
127 | -> 'ok'). | |
128 | ||
129 | -spec(action/6 :: | |
130 | (atom(), node(), [string()], [{string(), any()}], | |
131 | fun ((string(), [any()]) -> 'ok'), timeout()) | |
119 | 132 | -> 'ok'). |
120 | 133 | |
121 | 134 | -endif. |
135 | 148 | io:format(Format ++ " ...~n", Args1) |
136 | 149 | end |
137 | 150 | end, |
138 | do_action(Command, Node, Args, Opts, Inform) | |
151 | try | |
152 | T = case get_timeout(Opts) of | |
153 | {ok, Timeout} -> | |
154 | Timeout; | |
155 | {error, _} -> | |
156 | %% since this is an error with user input, ignore the quiet | |
157 | %% setting | |
158 | io:format("Failed to parse provided timeout value, using ~s~n", [?RPC_TIMEOUT]), | |
159 | ?RPC_TIMEOUT | |
160 | end, | |
161 | do_action(Command, Node, Args, Opts, Inform, T) | |
162 | catch _:E -> E | |
163 | end | |
139 | 164 | end, rabbit_ctl_usage). |
140 | 165 | |
141 | 166 | parse_arguments(CmdLine, NodeStr) -> |
159 | 184 | end, |
160 | 185 | io:nl(). |
161 | 186 | |
187 | get_timeout(Opts) -> | |
188 | parse_timeout(proplists:get_value(?TIMEOUT_OPT, Opts, ?RPC_TIMEOUT)). | |
189 | ||
190 | parse_number(N) when is_list(N) -> | |
191 | try list_to_integer(N) of | |
192 | Val -> Val | |
193 | catch error:badarg -> | |
194 | %% could have been a float, give it | |
195 | %% another shot | |
196 | list_to_float(N) | |
197 | end. | |
198 | ||
199 | parse_timeout("infinity") -> | |
200 | {ok, infinity}; | |
201 | parse_timeout(infinity) -> | |
202 | {ok, infinity}; | |
203 | parse_timeout(N) when is_list(N) -> | |
204 | try parse_number(N) of | |
205 | M -> | |
206 | Y = case M >= 0 of | |
207 | true -> round(M) * 1000; | |
208 | false -> ?RPC_TIMEOUT | |
209 | end, | |
210 | {ok, Y} | |
211 | catch error:badarg -> | |
212 | {error, infinity} | |
213 | end; | |
214 | parse_timeout(N) -> | |
215 | {ok, N}. | |
216 | ||
217 | announce_timeout(infinity, _Inform) -> | |
218 | %% no-op | |
219 | ok; | |
220 | announce_timeout(Timeout, Inform) when is_number(Timeout) -> | |
221 | Inform("Timeout: ~w seconds", [Timeout/1000]), | |
222 | ok. | |
223 | ||
162 | 224 | stop() -> |
163 | 225 | ok. |
164 | 226 | |
165 | 227 | %%---------------------------------------------------------------------------- |
166 | 228 | |
167 | do_action(Command, Node, Args, Opts, Inform) -> | |
229 | do_action(Command, Node, Args, Opts, Inform, Timeout) -> | |
168 | 230 | case lists:member(Command, ?COMMANDS_NOT_REQUIRING_APP) of |
169 | false -> case ensure_app_running(Node) of | |
170 | ok -> action(Command, Node, Args, Opts, Inform); | |
171 | E -> E | |
172 | end; | |
173 | true -> action(Command, Node, Args, Opts, Inform) | |
231 | false -> | |
232 | case ensure_app_running(Node) of | |
233 | ok -> | |
234 | case lists:member(Command, ?COMMANDS_WITH_TIMEOUT) of | |
235 | true -> | |
236 | announce_timeout(Timeout, Inform), | |
237 | action(Command, Node, Args, Opts, Inform, Timeout); | |
238 | false -> | |
239 | action(Command, Node, Args, Opts, Inform) | |
240 | end; | |
241 | E -> E | |
242 | end; | |
243 | true -> | |
244 | action(Command, Node, Args, Opts, Inform) | |
174 | 245 | end. |
175 | 246 | |
176 | 247 | action(stop, Node, Args, _Opts, Inform) -> |
312 | 383 | rpc_call(Node, rabbit_auth_backend_internal, set_tags, |
313 | 384 | [list_to_binary(Username), Tags]); |
314 | 385 | |
315 | action(list_users, Node, [], _Opts, Inform) -> | |
316 | Inform("Listing users", []), | |
317 | display_info_list( | |
318 | call(Node, {rabbit_auth_backend_internal, list_users, []}), | |
319 | rabbit_auth_backend_internal:user_info_keys()); | |
320 | ||
321 | 386 | action(add_vhost, Node, Args = [_VHostPath], _Opts, Inform) -> |
322 | 387 | Inform("Creating vhost \"~s\"", Args), |
323 | 388 | call(Node, {rabbit_vhost, add, Args}); |
325 | 390 | action(delete_vhost, Node, Args = [_VHostPath], _Opts, Inform) -> |
326 | 391 | Inform("Deleting vhost \"~s\"", Args), |
327 | 392 | call(Node, {rabbit_vhost, delete, Args}); |
328 | ||
329 | action(list_vhosts, Node, Args, _Opts, Inform) -> | |
330 | Inform("Listing vhosts", []), | |
331 | ArgAtoms = default_if_empty(Args, [name]), | |
332 | display_info_list(call(Node, {rabbit_vhost, info_all, []}), ArgAtoms); | |
333 | ||
334 | action(list_user_permissions, Node, Args = [_Username], _Opts, Inform) -> | |
335 | Inform("Listing permissions for user ~p", Args), | |
336 | display_info_list(call(Node, {rabbit_auth_backend_internal, | |
337 | list_user_permissions, Args}), | |
338 | rabbit_auth_backend_internal:user_perms_info_keys()); | |
339 | ||
340 | action(list_queues, Node, Args, Opts, Inform) -> | |
341 | Inform("Listing queues", []), | |
342 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
343 | ArgAtoms = default_if_empty(Args, [name, messages]), | |
344 | display_info_list(rpc_call(Node, rabbit_amqqueue, info_all, | |
345 | [VHostArg, ArgAtoms]), | |
346 | ArgAtoms); | |
347 | ||
348 | action(list_exchanges, Node, Args, Opts, Inform) -> | |
349 | Inform("Listing exchanges", []), | |
350 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
351 | ArgAtoms = default_if_empty(Args, [name, type]), | |
352 | display_info_list(rpc_call(Node, rabbit_exchange, info_all, | |
353 | [VHostArg, ArgAtoms]), | |
354 | ArgAtoms); | |
355 | ||
356 | action(list_bindings, Node, Args, Opts, Inform) -> | |
357 | Inform("Listing bindings", []), | |
358 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
359 | ArgAtoms = default_if_empty(Args, [source_name, source_kind, | |
360 | destination_name, destination_kind, | |
361 | routing_key, arguments]), | |
362 | display_info_list(rpc_call(Node, rabbit_binding, info_all, | |
363 | [VHostArg, ArgAtoms]), | |
364 | ArgAtoms); | |
365 | ||
366 | action(list_connections, Node, Args, _Opts, Inform) -> | |
367 | Inform("Listing connections", []), | |
368 | ArgAtoms = default_if_empty(Args, [user, peer_host, peer_port, state]), | |
369 | display_info_list(rpc_call(Node, rabbit_networking, connection_info_all, | |
370 | [ArgAtoms]), | |
371 | ArgAtoms); | |
372 | ||
373 | action(list_channels, Node, Args, _Opts, Inform) -> | |
374 | Inform("Listing channels", []), | |
375 | ArgAtoms = default_if_empty(Args, [pid, user, consumer_count, | |
376 | messages_unacknowledged]), | |
377 | display_info_list(rpc_call(Node, rabbit_channel, info_all, [ArgAtoms]), | |
378 | ArgAtoms); | |
379 | ||
380 | action(list_consumers, Node, _Args, Opts, Inform) -> | |
381 | Inform("Listing consumers", []), | |
382 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
383 | display_info_list(rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg]), | |
384 | rabbit_amqqueue:consumer_info_keys()); | |
385 | 393 | |
386 | 394 | action(trace_on, Node, [], Opts, Inform) -> |
387 | 395 | VHost = proplists:get_value(?VHOST_OPT, Opts), |
415 | 423 | call(Node, {rabbit_auth_backend_internal, clear_permissions, |
416 | 424 | [Username, VHost]}); |
417 | 425 | |
418 | action(list_permissions, Node, [], Opts, Inform) -> | |
419 | VHost = proplists:get_value(?VHOST_OPT, Opts), | |
420 | Inform("Listing permissions in vhost \"~s\"", [VHost]), | |
421 | display_info_list(call(Node, {rabbit_auth_backend_internal, | |
422 | list_vhost_permissions, [VHost]}), | |
423 | rabbit_auth_backend_internal:vhost_perms_info_keys()); | |
424 | ||
425 | 426 | action(set_parameter, Node, [Component, Key, Value], Opts, Inform) -> |
426 | 427 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), |
427 | 428 | Inform("Setting runtime parameter ~p for component ~p to ~p", |
436 | 437 | rpc_call(Node, rabbit_runtime_parameters, clear, [VHostArg, |
437 | 438 | list_to_binary(Component), |
438 | 439 | list_to_binary(Key)]); |
439 | ||
440 | action(list_parameters, Node, [], Opts, Inform) -> | |
441 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
442 | Inform("Listing runtime parameters", []), | |
443 | display_info_list( | |
444 | rpc_call(Node, rabbit_runtime_parameters, list_formatted, [VHostArg]), | |
445 | rabbit_runtime_parameters:info_keys()); | |
446 | 440 | |
447 | 441 | action(set_policy, Node, [Key, Pattern, Defn], Opts, Inform) -> |
448 | 442 | Msg = "Setting policy ~p for pattern ~p to ~p with priority ~p", |
458 | 452 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), |
459 | 453 | Inform("Clearing policy ~p", [Key]), |
460 | 454 | rpc_call(Node, rabbit_policy, delete, [VHostArg, list_to_binary(Key)]); |
461 | ||
462 | action(list_policies, Node, [], Opts, Inform) -> | |
463 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
464 | Inform("Listing policies", []), | |
465 | display_info_list(rpc_call(Node, rabbit_policy, list_formatted, [VHostArg]), | |
466 | rabbit_policy:info_keys()); | |
467 | 455 | |
468 | 456 | action(report, Node, _Args, _Opts, Inform) -> |
469 | 457 | Inform("Reporting server status on ~p~n~n", [erlang:universaltime()]), |
492 | 480 | end; |
493 | 481 | {error, E, _} -> |
494 | 482 | {error_string, format_parse_error(E)} |
495 | end. | |
483 | end; | |
484 | ||
485 | action(Command, Node, Args, Opts, Inform) -> | |
486 | %% For backward compatibility, run commands accepting a timeout with | |
487 | %% the default timeout. | |
488 | action(Command, Node, Args, Opts, Inform, ?RPC_TIMEOUT). | |
489 | ||
490 | action(purge_queue, _Node, [], _Opts, _Inform, _Timeout) -> | |
491 | {error, "purge_queue takes queue name as an argument"}; | |
492 | ||
493 | action(purge_queue, Node, [Q], Opts, Inform, Timeout) -> | |
494 | VHost = proplists:get_value(?VHOST_OPT, Opts), | |
495 | QRes = rabbit_misc:r(list_to_binary(VHost), queue, list_to_binary(Q)), | |
496 | Inform("Purging ~s", [rabbit_misc:rs(QRes)]), | |
497 | rpc_call(Node, rabbit_control_main, purge_queue, [QRes], Timeout); | |
498 | ||
499 | action(list_users, Node, [], _Opts, Inform, Timeout) -> | |
500 | Inform("Listing users", []), | |
501 | display_info_list( | |
502 | call(Node, {rabbit_auth_backend_internal, list_users, []}, Timeout), | |
503 | rabbit_auth_backend_internal:user_info_keys()); | |
504 | ||
505 | action(list_permissions, Node, [], Opts, Inform, Timeout) -> | |
506 | VHost = proplists:get_value(?VHOST_OPT, Opts), | |
507 | Inform("Listing permissions in vhost \"~s\"", [VHost]), | |
508 | display_info_list(call(Node, {rabbit_auth_backend_internal, | |
509 | list_vhost_permissions, [VHost]}, Timeout), | |
510 | rabbit_auth_backend_internal:vhost_perms_info_keys()); | |
511 | ||
512 | action(list_parameters, Node, [], Opts, Inform, Timeout) -> | |
513 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
514 | Inform("Listing runtime parameters", []), | |
515 | display_info_list( | |
516 | rpc_call(Node, rabbit_runtime_parameters, list_formatted, [VHostArg], | |
517 | Timeout), | |
518 | rabbit_runtime_parameters:info_keys()); | |
519 | ||
520 | action(list_policies, Node, [], Opts, Inform, Timeout) -> | |
521 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
522 | Inform("Listing policies", []), | |
523 | display_info_list(rpc_call(Node, rabbit_policy, list_formatted, [VHostArg], | |
524 | Timeout), | |
525 | rabbit_policy:info_keys()); | |
526 | ||
527 | action(list_vhosts, Node, Args, _Opts, Inform, Timeout) -> | |
528 | Inform("Listing vhosts", []), | |
529 | ArgAtoms = default_if_empty(Args, [name]), | |
530 | display_info_list(call(Node, {rabbit_vhost, info_all, []}, Timeout), | |
531 | ArgAtoms); | |
532 | ||
533 | action(list_user_permissions, _Node, _Args = [], _Opts, _Inform, _Timeout) -> | |
534 | {error_string, | |
535 | "list_user_permissions expects a username argument, but none provided."}; | |
536 | action(list_user_permissions, Node, Args = [_Username], _Opts, Inform, Timeout) -> | |
537 | Inform("Listing permissions for user ~p", Args), | |
538 | display_info_list(call(Node, {rabbit_auth_backend_internal, | |
539 | list_user_permissions, Args}, Timeout), | |
540 | rabbit_auth_backend_internal:user_perms_info_keys()); | |
541 | ||
542 | action(list_queues, Node, Args, Opts, Inform, Timeout) -> | |
543 | Inform("Listing queues", []), | |
544 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
545 | ArgAtoms = default_if_empty(Args, [name, messages]), | |
546 | display_info_list(rpc_call(Node, rabbit_amqqueue, info_all, | |
547 | [VHostArg, ArgAtoms], Timeout), | |
548 | ArgAtoms); | |
549 | ||
550 | action(list_exchanges, Node, Args, Opts, Inform, Timeout) -> | |
551 | Inform("Listing exchanges", []), | |
552 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
553 | ArgAtoms = default_if_empty(Args, [name, type]), | |
554 | display_info_list(rpc_call(Node, rabbit_exchange, info_all, | |
555 | [VHostArg, ArgAtoms], Timeout), | |
556 | ArgAtoms); | |
557 | ||
558 | action(list_bindings, Node, Args, Opts, Inform, Timeout) -> | |
559 | Inform("Listing bindings", []), | |
560 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
561 | ArgAtoms = default_if_empty(Args, [source_name, source_kind, | |
562 | destination_name, destination_kind, | |
563 | routing_key, arguments]), | |
564 | display_info_list(rpc_call(Node, rabbit_binding, info_all, | |
565 | [VHostArg, ArgAtoms], Timeout), | |
566 | ArgAtoms); | |
567 | ||
568 | action(list_connections, Node, Args, _Opts, Inform, Timeout) -> | |
569 | Inform("Listing connections", []), | |
570 | ArgAtoms = default_if_empty(Args, [user, peer_host, peer_port, state]), | |
571 | display_info_list(rpc_call(Node, rabbit_networking, connection_info_all, | |
572 | [ArgAtoms], Timeout), | |
573 | ArgAtoms); | |
574 | ||
575 | action(list_channels, Node, Args, _Opts, Inform, Timeout) -> | |
576 | Inform("Listing channels", []), | |
577 | ArgAtoms = default_if_empty(Args, [pid, user, consumer_count, | |
578 | messages_unacknowledged]), | |
579 | display_info_list(rpc_call(Node, rabbit_channel, info_all, [ArgAtoms], | |
580 | Timeout), | |
581 | ArgAtoms); | |
582 | ||
583 | action(list_consumers, Node, _Args, Opts, Inform, Timeout) -> | |
584 | Inform("Listing consumers", []), | |
585 | VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), | |
586 | display_info_list(rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg], | |
587 | Timeout), | |
588 | rabbit_amqqueue:consumer_info_keys()). | |
589 | ||
496 | 590 | |
497 | 591 | format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)). |
498 | 592 | |
504 | 598 | rabbit_amqqueue:with( |
505 | 599 | Q, fun(#amqqueue{pid = QPid}) -> |
506 | 600 | rabbit_amqqueue:cancel_sync_mirrors(QPid) |
601 | end). | |
602 | ||
603 | purge_queue(Q) -> | |
604 | rabbit_amqqueue:with( | |
605 | Q, fun(Q1) -> | |
606 | rabbit_amqqueue:purge(Q1), | |
607 | ok | |
507 | 608 | end). |
508 | 609 | |
509 | 610 | %%---------------------------------------------------------------------------- |
649 | 750 | call(Node, {Mod, Fun, Args}) -> |
650 | 751 | rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary_utf8/1, Args)). |
651 | 752 | |
753 | call(Node, {Mod, Fun, Args}, Timeout) -> | |
754 | rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary_utf8/1, Args), Timeout). | |
755 | ||
652 | 756 | list_to_binary_utf8(L) -> |
653 | 757 | B = list_to_binary(L), |
654 | 758 | case rabbit_binary_parser:validate_utf8(B) of |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_dead_letter). |
77 | 77 | content = Content2}. |
78 | 78 | |
79 | 79 | |
80 | x_death_event_key(Info, Key, KeyType) -> | |
80 | x_death_event_key(Info, Key) -> | |
81 | 81 | case lists:keysearch(Key, 1, Info) of |
82 | false -> undefined; | |
83 | {value, {Key, KeyType, Val}} -> Val | |
84 | end. | |
82 | false -> undefined; | |
83 | {value, {Key, _KeyType, Val}} -> Val | |
84 | end. | |
85 | ||
86 | maybe_append_to_event_group(Table, _Key, _SeenKeys, []) -> | |
87 | [Table]; | |
88 | maybe_append_to_event_group(Table, {_Queue, _Reason} = Key, SeenKeys, Acc) -> | |
89 | case sets:is_element(Key, SeenKeys) of | |
90 | true -> Acc; | |
91 | false -> [Table | Acc] | |
92 | end. | |
93 | ||
94 | group_by_queue_and_reason([]) -> | |
95 | []; | |
96 | group_by_queue_and_reason([Table]) -> | |
97 | [Table]; | |
98 | group_by_queue_and_reason(Tables) -> | |
99 | {_, Grouped} = | |
100 | lists:foldl( | |
101 | fun ({table, Info}, {SeenKeys, Acc}) -> | |
102 | Q = x_death_event_key(Info, <<"queue">>), | |
103 | R = x_death_event_key(Info, <<"reason">>), | |
104 | Matcher = queue_and_reason_matcher(Q, R), | |
105 | {Matches, _} = lists:partition(Matcher, Tables), | |
106 | {Augmented, N} = case Matches of | |
107 | [X] -> {X, 1}; | |
108 | [X|_] = Xs -> {X, length(Xs)} | |
109 | end, | |
110 | Key = {Q, R}, | |
111 | Acc1 = maybe_append_to_event_group( | |
112 | ensure_xdeath_event_count(Augmented, N), | |
113 | Key, SeenKeys, Acc), | |
114 | {sets:add_element(Key, SeenKeys), Acc1} | |
115 | end, {sets:new(), []}, Tables), | |
116 | Grouped. | |
85 | 117 | |
86 | 118 | update_x_death_header(Info, Headers) -> |
87 | Q = x_death_event_key(Info, <<"queue">>, longstr), | |
88 | R = x_death_event_key(Info, <<"reason">>, longstr), | |
119 | Q = x_death_event_key(Info, <<"queue">>), | |
120 | R = x_death_event_key(Info, <<"reason">>), | |
89 | 121 | case rabbit_basic:header(<<"x-death">>, Headers) of |
90 | 122 | undefined -> |
91 | rabbit_basic:prepend_table_header(<<"x-death">>, | |
123 | rabbit_basic:prepend_table_header( | |
124 | <<"x-death">>, | |
92 | 125 | [{<<"count">>, long, 1} | Info], Headers); |
93 | 126 | {<<"x-death">>, array, Tables} -> |
127 | %% group existing x-death headers in case we have some from | |
128 | %% before rabbitmq-server#78 | |
129 | GroupedTables = group_by_queue_and_reason(Tables), | |
94 | 130 | {Matches, Others} = lists:partition( |
95 | fun ({table, Info0}) -> | |
96 | x_death_event_key(Info0, <<"queue">>, longstr) =:= Q | |
97 | andalso x_death_event_key(Info0, <<"reason">>, longstr) =:= R | |
98 | end, Tables), | |
131 | queue_and_reason_matcher(Q, R), | |
132 | GroupedTables), | |
99 | 133 | Info1 = case Matches of |
100 | 134 | [] -> |
101 | 135 | [{<<"count">>, long, 1} | Info]; |
102 | 136 | [{table, M}] -> |
103 | case x_death_event_key(M, <<"count">>, long) of | |
104 | undefined -> | |
105 | [{<<"count">>, long, 1} | M]; | |
106 | N -> | |
107 | lists:keyreplace( | |
108 | <<"count">>, 1, M, | |
109 | {<<"count">>, long, N + 1}) | |
110 | end | |
137 | increment_xdeath_event_count(M) | |
111 | 138 | end, |
112 | rabbit_misc:set_table_value(Headers, <<"x-death">>, array, | |
139 | rabbit_misc:set_table_value( | |
140 | Headers, <<"x-death">>, array, | |
113 | 141 | [{table, rabbit_misc:sort_field_table(Info1)} | Others]) |
142 | end. | |
143 | ||
144 | ensure_xdeath_event_count({table, Info}, InitialVal) when InitialVal >= 1 -> | |
145 | {table, ensure_xdeath_event_count(Info, InitialVal)}; | |
146 | ensure_xdeath_event_count(Info, InitialVal) when InitialVal >= 1 -> | |
147 | case x_death_event_key(Info, <<"count">>) of | |
148 | undefined -> | |
149 | [{<<"count">>, long, InitialVal} | Info]; | |
150 | _ -> | |
151 | Info | |
152 | end. | |
153 | ||
154 | increment_xdeath_event_count(Info) -> | |
155 | case x_death_event_key(Info, <<"count">>) of | |
156 | undefined -> | |
157 | [{<<"count">>, long, 1} | Info]; | |
158 | N -> | |
159 | lists:keyreplace( | |
160 | <<"count">>, 1, Info, | |
161 | {<<"count">>, long, N + 1}) | |
162 | end. | |
163 | ||
164 | queue_and_reason_matcher(Q, R) -> | |
165 | F = fun(Info) -> | |
166 | x_death_event_key(Info, <<"queue">>) =:= Q | |
167 | andalso x_death_event_key(Info, <<"reason">>) =:= R | |
168 | end, | |
169 | fun({table, Info}) -> | |
170 | F(Info); | |
171 | (Info) when is_list(Info) -> | |
172 | F(Info) | |
114 | 173 | end. |
115 | 174 | |
116 | 175 | per_msg_ttl_header(#'P_basic'{expiration = undefined}) -> |
177 | 236 | true -> ok; |
178 | 237 | undefined -> rabbit_log:warning( |
179 | 238 | "Message dropped. Dead-letter queues cycle detected" ++ |
180 | ": ~p~nThis cycle will NOT be reported again.~n", | |
239 | ": ~p~nThis cycle will NOT be reported again.~n", | |
181 | 240 | [Queues]), |
182 | 241 | put(Key, true) |
183 | 242 | end. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_diagnostics). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_direct). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_disk_monitor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_epmd_monitor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_error_logger). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_error_logger_file_h). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_event). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_decorator). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type_direct). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type_fanout). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type_headers). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type_invalid). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_exchange_type_topic). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_file). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% TODO auto-generate |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_guid). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_heartbeat). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% The purpose of the limiter is to stem the flow of messages from |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_log). |
83 | 83 | level(debug) -> 4; |
84 | 84 | level(info) -> 3; |
85 | 85 | level(warning) -> 2; |
86 | level(warn) -> 2; | |
86 | 87 | level(error) -> 1; |
87 | 88 | level(none) -> 0. |
88 | 89 |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | |
24 | 24 | -behaviour(gen_server2). |
25 | 25 | |
26 | 26 | -export([start_link/0, register/2, deregister/1, |
27 | report_ram_duration/2, stop/0, conserve_resources/3]). | |
27 | report_ram_duration/2, stop/0, conserve_resources/3, memory_use/1]). | |
28 | 28 | |
29 | 29 | -export([init/1, handle_call/3, handle_cast/2, handle_info/2, |
30 | 30 | terminate/2, code_change/3]). |
90 | 90 | gen_server2:cast(Pid, {disk_alarm, Conserve}); |
91 | 91 | conserve_resources(_Pid, _Source, _Conserve) -> |
92 | 92 | ok. |
93 | ||
94 | memory_use(bytes) -> | |
95 | MemoryLimit = vm_memory_monitor:get_memory_limit(), | |
96 | {erlang:memory(total), case MemoryLimit > 0.0 of | |
97 | true -> MemoryLimit; | |
98 | false -> infinity | |
99 | end}; | |
100 | memory_use(ratio) -> | |
101 | MemoryLimit = vm_memory_monitor:get_memory_limit(), | |
102 | case MemoryLimit > 0.0 of | |
103 | true -> erlang:memory(total) / MemoryLimit; | |
104 | false -> infinity | |
105 | end. | |
93 | 106 | |
94 | 107 | %%---------------------------------------------------------------------------- |
95 | 108 | %% Gen_server callbacks |
222 | 235 | queue_duration_count = Count}) -> |
223 | 236 | {ok, LimitThreshold} = |
224 | 237 | application:get_env(rabbit, vm_memory_high_watermark_paging_ratio), |
225 | MemoryLimit = vm_memory_monitor:get_memory_limit(), | |
226 | MemoryRatio = case MemoryLimit > 0.0 of | |
227 | true -> erlang:memory(total) / MemoryLimit; | |
228 | false -> infinity | |
229 | end, | |
238 | MemoryRatio = memory_use(ratio), | |
230 | 239 | if MemoryRatio =:= infinity -> |
231 | 240 | 0.0; |
232 | 241 | MemoryRatio < LimitThreshold orelse Count == 0 -> |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_coordinator). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_master). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_misc). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_mode). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_mode_all). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_mode_exactly). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_mode_nodes). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mirror_queue_slave). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_misc). |
71 | 71 | -export([store_proc_name/1, store_proc_name/2]). |
72 | 72 | -export([moving_average/4]). |
73 | 73 | -export([now_to_ms/1]). |
74 | -export([get_env/3]). | |
74 | 75 | |
75 | 76 | %% Horrible macro to use in guards |
76 | 77 | -define(IS_BENIGN_EXIT(R), |
260 | 261 | -spec(now_to_ms/1 :: ({non_neg_integer(), |
261 | 262 | non_neg_integer(), |
262 | 263 | non_neg_integer()}) -> pos_integer()). |
264 | -spec(get_env/3 :: (atom(), atom(), term()) -> term()). | |
263 | 265 | -endif. |
264 | 266 | |
265 | 267 | %%---------------------------------------------------------------------------- |
1095 | 1097 | store_proc_name(Type, ProcName) -> store_proc_name({Type, ProcName}). |
1096 | 1098 | store_proc_name(TypeProcName) -> put(process_name, TypeProcName). |
1097 | 1099 | |
1100 | %% application:get_env/3 is only available in R16B01 or later. | |
1101 | get_env(Application, Key, Def) -> | |
1102 | case application:get_env(Application, Key) of | |
1103 | {ok, Val} -> Val; | |
1104 | undefined -> Def | |
1105 | end. | |
1106 | ||
1098 | 1107 | moving_average(_Time, _HalfLife, Next, undefined) -> |
1099 | 1108 | Next; |
1100 | 1109 | %% We want the Weight to decrease as Time goes up (since Weight is the |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mnesia). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_mnesia_rename). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_msg_file). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_msg_store). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_msg_store_ets_index). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_msg_store_gc). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_msg_store_index). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_net). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_networking). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_node_monitor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_nodes). |
136 | 136 | [{" * TCP connection succeeded but Erlang distribution " |
137 | 137 | "failed~n" |
138 | 138 | " * suggestion: hostname mismatch?~n" |
139 | " * suggestion: is the cookie set correctly?", []}]; | |
139 | " * suggestion: is the cookie set correctly?~n" | |
140 | " * suggestion: is the Erlang distribution using TLS?", []}]; | |
140 | 141 | {error, Reason} -> |
141 | 142 | [{" * can't establish TCP connection, reason: ~s~n" |
142 | 143 | " * suggestion: blocked by firewall?", |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_parameter_validation). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_plugins). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_plugins_main). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_policies). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_policy). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_policy_validator). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_prelaunch). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_prequeue). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_priority_queue). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_queue_collector). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_queue_consumers). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_queue_index). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_reader). |
195 | 195 | log(error, "Error on AMQP connection ~p: ~s~n", |
196 | 196 | [self(), rabbit_misc:format_inet_error(Reason)]); |
197 | 197 | socket_error(Reason) -> |
198 | log(error, "Error on AMQP connection ~p:~n~p~n", [self(), Reason]). | |
198 | Level = | |
199 | case Reason of | |
200 | {ssl_upgrade_error, closed} -> | |
201 | %% The socket was closed while upgrading to SSL. | |
202 | %% This is presumably a TCP healthcheck, so don't log | |
203 | %% it unless specified otherwise. | |
204 | debug; | |
205 | _ -> | |
206 | error | |
207 | end, | |
208 | log(Level, "Error on AMQP connection ~p:~n~p~n", [self(), Reason]). | |
199 | 209 | |
200 | 210 | inet_op(F) -> rabbit_misc:throw_on_error(inet_error, F). |
201 | 211 | |
262 | 272 | handshake, 8)]}), |
263 | 273 | log(info, "closing AMQP connection ~p (~s)~n", [self(), Name]) |
264 | 274 | catch |
265 | Ex -> log(case Ex of | |
266 | connection_closed_with_no_data_received -> debug; | |
267 | connection_closed_abruptly -> warning; | |
268 | _ -> error | |
269 | end, "closing AMQP connection ~p (~s):~n~p~n", | |
270 | [self(), Name, Ex]) | |
275 | Ex -> | |
276 | log_connection_exception(Name, Ex) | |
271 | 277 | after |
272 | 278 | %% We don't call gen_tcp:close/1 here since it waits for |
273 | 279 | %% pending output to be sent, which results in unnecessary |
281 | 287 | rabbit_event:notify(connection_closed, [{pid, self()}]) |
282 | 288 | end, |
283 | 289 | done. |
290 | ||
291 | log_connection_exception(Name, Ex) -> | |
292 | Severity = case Ex of | |
293 | connection_closed_with_no_data_received -> debug; | |
294 | connection_closed_abruptly -> warning; | |
295 | _ -> error | |
296 | end, | |
297 | log_connection_exception(Severity, Name, Ex). | |
298 | ||
299 | log_connection_exception(Severity, Name, {heartbeat_timeout, TimeoutSec}) -> | |
300 | %% Long line to avoid extra spaces and line breaks in log | |
301 | log(Severity, "closing AMQP connection ~p (~s):~nMissed heartbeats from client, timeout: ~ps~n", | |
302 | [self(), Name, TimeoutSec]); | |
303 | log_connection_exception(Severity, Name, Ex) -> | |
304 | log(Severity, "closing AMQP connection ~p (~s):~n~p~n", | |
305 | [self(), Name, Ex]). | |
284 | 306 | |
285 | 307 | run({M, F, A}) -> |
286 | 308 | try apply(M, F, A) |
344 | 366 | State#v1{pending_recv = false}); |
345 | 367 | closed when State#v1.connection_state =:= closed -> |
346 | 368 | ok; |
369 | closed when CS =:= pre_init andalso Buf =:= [] -> | |
370 | stop(tcp_healthcheck, State); | |
347 | 371 | closed -> |
348 | 372 | stop(closed, State); |
349 | 373 | {error, Reason} -> |
358 | 382 | end |
359 | 383 | end. |
360 | 384 | |
361 | stop(closed, #v1{connection_state = pre_init} = State) -> | |
385 | stop(tcp_healthcheck, State) -> | |
362 | 386 | %% The connection was closed before any packet was received. It's |
363 | 387 | %% probably a load-balancer healthcheck: don't consider this a |
364 | 388 | %% failure. |
420 | 444 | throw({handshake_timeout, State#v1.callback}); |
421 | 445 | handle_other(heartbeat_timeout, State = #v1{connection_state = closed}) -> |
422 | 446 | State; |
423 | handle_other(heartbeat_timeout, State = #v1{connection_state = S}) -> | |
447 | handle_other(heartbeat_timeout, | |
448 | State = #v1{connection = #connection{timeout_sec = T}}) -> | |
424 | 449 | maybe_emit_stats(State), |
425 | throw({heartbeat_timeout, S}); | |
450 | throw({heartbeat_timeout, T}); | |
426 | 451 | handle_other({'$gen_call', From, {shutdown, Explanation}}, State) -> |
427 | 452 | {ForceTermination, NewState} = terminate(Explanation, State), |
428 | 453 | gen_server:reply(From, ok), |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% We use a gen_server simply so that during the terminate/2 call |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_registry). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_restartable_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_router). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_runtime_parameter). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_runtime_parameters). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_sasl_report_file_h). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_ssl). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_table). |
17 | 17 | |
18 | 18 | -export([create/0, create_local_copy/1, wait_for_replicated/0, wait/1, |
19 | 19 | force_load/0, is_present/0, is_empty/0, needs_default_data/0, |
20 | check_schema_integrity/0, clear_ram_only_tables/0]). | |
20 | check_schema_integrity/0, clear_ram_only_tables/0, wait_timeout/0]). | |
21 | 21 | |
22 | 22 | -include("rabbit.hrl"). |
23 | 23 | |
29 | 29 | -spec(create_local_copy/1 :: ('disc' | 'ram') -> 'ok'). |
30 | 30 | -spec(wait_for_replicated/0 :: () -> 'ok'). |
31 | 31 | -spec(wait/1 :: ([atom()]) -> 'ok'). |
32 | -spec(wait_timeout/0 :: () -> non_neg_integer() | infinity). | |
32 | 33 | -spec(force_load/0 :: () -> 'ok'). |
33 | 34 | -spec(is_present/0 :: () -> boolean()). |
34 | 35 | -spec(is_empty/0 :: () -> boolean()). |
72 | 73 | wait(TableNames) -> |
73 | 74 | %% We might be in ctl here for offline ops, in which case we can't |
74 | 75 | %% get_env() for the rabbit app. |
75 | Timeout = case application:get_env(rabbit, mnesia_table_loading_timeout) of | |
76 | {ok, T} -> T; | |
77 | undefined -> 30000 | |
78 | end, | |
76 | Timeout = wait_timeout(), | |
79 | 77 | case mnesia:wait_for_tables(TableNames, Timeout) of |
80 | 78 | ok -> |
81 | 79 | ok; |
83 | 81 | throw({error, {timeout_waiting_for_tables, BadTabs}}); |
84 | 82 | {error, Reason} -> |
85 | 83 | throw({error, {failed_waiting_for_tables, Reason}}) |
84 | end. | |
85 | ||
86 | wait_timeout() -> | |
87 | case application:get_env(rabbit, mnesia_table_loading_timeout) of | |
88 | {ok, T} -> T; | |
89 | undefined -> 30000 | |
86 | 90 | end. |
87 | 91 | |
88 | 92 | force_load() -> [mnesia:force_load_table(T) || T <- names()], ok. |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_trace). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_types). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_upgrade). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_upgrade_functions). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_variable_queue). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_version). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_vhost). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_vm). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(rabbit_writer). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% Invoke callbacks on startup and termination. |
136 | 136 | -record(state, {name, |
137 | 137 | strategy :: strategy(), |
138 | 138 | children = [] :: [child_rec()], |
139 | dynamics :: ?DICT:?DICT() | ?SET:?SET(), | |
139 | dynamics :: ?DICT:?DICT() | ?SETS:?SET(), | |
140 | 140 | intensity :: non_neg_integer(), |
141 | 141 | period :: pos_integer(), |
142 | 142 | restarts = [], |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(tcp_acceptor). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(tcp_acceptor_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(tcp_listener). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(tcp_listener_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(truncate). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | %% In practice Erlang shouldn't be allowed to grow to more than a half |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(worker_pool). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(worker_pool_sup). |
10 | 10 | %% The Original Code is RabbitMQ. |
11 | 11 | %% |
12 | 12 | %% The Initial Developer of the Original Code is GoPivotal, Inc. |
13 | %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved. | |
13 | %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. | |
14 | 14 | %% |
15 | 15 | |
16 | 16 | -module(worker_pool_worker). |