summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert@lshift.net>2009-02-20 15:13:20 +0000
committerHubert Plociniczak <hubert@lshift.net>2009-02-20 15:13:20 +0000
commit783c28fc1ff31620fa99a26280a583f9da8a9c06 (patch)
treee2fb03b3933b107b8b17b302d568994208c8f1e9
parent9c8b9d142e64b6975029f5c41421c3c4dc3022e9 (diff)
parent71077f0a21145fbd72db936b95c5075c0910e3e6 (diff)
downloadrabbitmq-server-git-783c28fc1ff31620fa99a26280a583f9da8a9c06.tar.gz
Merge v1_5 into bug20329
-rw-r--r--Makefile2
-rw-r--r--docs/rabbitmq-multi.1.pod2
-rw-r--r--docs/rabbitmq-server.1.pod4
-rw-r--r--docs/rabbitmq.conf.5.pod (renamed from docs/rabbitmq.5.pod)28
-rw-r--r--docs/rabbitmqctl.1.pod8
-rw-r--r--packaging/RPMS/Fedora/init.d6
-rw-r--r--packaging/RPMS/Fedora/rabbitmq-server.logrotate2
-rw-r--r--packaging/RPMS/Fedora/rabbitmq-server.spec5
-rw-r--r--packaging/debs/Debian/debian/dirs1
-rw-r--r--packaging/debs/Debian/debian/init.d6
-rw-r--r--packaging/debs/Debian/debian/postrm3
-rw-r--r--packaging/debs/Debian/debian/rabbitmq-server.logrotate2
-rwxr-xr-xscripts/rabbitmq-multi7
-rwxr-xr-xscripts/rabbitmq-server9
-rw-r--r--src/rabbit.erl4
-rw-r--r--src/rabbit_channel.erl8
-rw-r--r--src/rabbit_guid.erl126
-rw-r--r--src/rabbit_misc.erl40
-rw-r--r--src/rabbit_persister.erl2
19 files changed, 192 insertions, 73 deletions
diff --git a/Makefile b/Makefile
index f924b8e62d..e0f01f4c60 100644
--- a/Makefile
+++ b/Makefile
@@ -143,7 +143,7 @@ distclean: clean
%.gz: %.pod
pod2man \
- -n `echo $$(basename $*) | sed -e 's/\.[^.]\+//'` \
+ -n `echo $$(basename $*) | sed -e 's/\.[[:digit:]]\+//'` \
-s `echo $$(basename $*) | sed -e 's/.*\.\([^.]\+\)/\1/'` \
-c "RabbitMQ AMQP Server" \
-d "" \
diff --git a/docs/rabbitmq-multi.1.pod b/docs/rabbitmq-multi.1.pod
index 82c3911681..23fd96ed65 100644
--- a/docs/rabbitmq-multi.1.pod
+++ b/docs/rabbitmq-multi.1.pod
@@ -40,7 +40,7 @@ Start 3 local RabbitMQ nodes with unique, sequential port numbers:
=head1 SEE ALSO
-rabbitmq-server(1), rabbitmqctl(1)
+rabbitmq.conf(5), rabbitmq-server(1), rabbitmqctl(1)
=head1 AUTHOR
diff --git a/docs/rabbitmq-server.1.pod b/docs/rabbitmq-server.1.pod
index 00210c8b5c..99a7ceccf3 100644
--- a/docs/rabbitmq-server.1.pod
+++ b/docs/rabbitmq-server.1.pod
@@ -44,7 +44,7 @@ B<RABBITMQ_NODE_PORT>
Defaults to 5672.
B<RABBITMQ_CLUSTER_CONFIG_FILE>
- Defaults to /etc/default/rabbitmq_cluster.config. If this file is
+ Defaults to /etc/rabbitmq/rabbitmq_cluster.config. If this file is
present it is used by the server to auto-configure a RabbitMQ
cluster.
See the clustering guide at http://www.rabbitmq.com/clustering.html
@@ -62,7 +62,7 @@ Run RabbitMQ AMQP server in the background:
=head1 SEE ALSO
-rabbitmq-multi(1), rabbitmqctl(1)
+rabbitmq.conf(5), rabbitmq-multi(1), rabbitmqctl(1)
=head1 AUTHOR
diff --git a/docs/rabbitmq.5.pod b/docs/rabbitmq.conf.5.pod
index e6972935f5..9b2536c383 100644
--- a/docs/rabbitmq.5.pod
+++ b/docs/rabbitmq.conf.5.pod
@@ -1,10 +1,10 @@
=head1 NAME
-/etc/default/rabbitmq - default settings for RabbitMQ AMQP server
+/etc/rabbitmq/rabbitmq.conf - default settings for RabbitMQ AMQP server
=head1 DESCRIPTION
-/etc/default/rabbitmq contains variable settings that override the
+/etc/rabbitmq/rabbitmq.conf contains variable settings that override the
defaults built in to the RabbitMQ startup scripts.
The file is interpreted by the system shell, and so should consist of
@@ -13,29 +13,29 @@ syntax is permitted (since the file is sourced using the shell "."
operator), including line comments starting with "#".
In order of preference, the startup scripts get their values from the
-environment, from /etc/default/rabbitmq, and finally from the built-in
-default values. For example, for the B<RABBITMQ_NODENAME> setting,
+environment, from /etc/rabbitmq/rabbitmq.conf and finally from the
+built-in default values. For example, for the B<RABBITMQ_NODENAME> setting,
B<RABBITMQ_NODENAME>
- from the environment is checked first. If it is absent or equal
- to the empty string, then
+ from the environment is checked first. If it is absent or equal to
+ the empty string, then
B<NODENAME>
- from /etc/default/rabbitmq is checked next. If it is also absent
- or set equal to the empty string, then the default value from the
- startup script is used.
+ from /etc/rabbitmq/rabbitmq.conf is checked. If it is also absent
+ or set equal to the empty string then the default value from
+ the startup script is used.
-The variable names in /etc/default/rabbitmq are always equal to the
+The variable names in /etc/rabbitmq/rabbitmq.conf are always equal to the
environment variable names, with the B<RABBITMQ_> prefix removed:
B<RABBITMQ_NODE_PORT> from the environment becomes B<NODE_PORT> in the
-/etc/default/rabbitmq file, etc.
+/etc/rabbitmq/rabbitmq.conf file, etc.
=head1 EXAMPLES
-The following is an example of a complete /etc/default/rabbitmq file
+The following is an example of a complete /etc/rabbitmq/rabbitmq.conf file
that overrides the default Erlang node name from "rabbit" to "hare":
- # I am a complete /etc/default/rabbitmq file.
+ # I am a complete /etc/rabbitmq/rabbitmq.conf file.
# Comment lines start with a hash character.
# This is a /bin/sh script file - use ordinary envt var syntax
NODENAME=hare
@@ -46,7 +46,7 @@ rabbitmq-server(1), rabbitmq-multi(1), rabbitmqctl(1)
=head1 AUTHOR
-Originally written by The RabbitMQ Team <info@lshift.net>
+Originally written by The RabbitMQ Team <info@rabbitmq.com>
=head1 COPYRIGHT
diff --git a/docs/rabbitmqctl.1.pod b/docs/rabbitmqctl.1.pod
index d2cb019973..17dd833836 100644
--- a/docs/rabbitmqctl.1.pod
+++ b/docs/rabbitmqctl.1.pod
@@ -106,7 +106,8 @@ add_vhost I<vhostpath>
delete_vhost I<vhostpath>
delete a virtual host I<vhostpath>.
- That command deletes also all its exchanges, queues and user mappings.
+ That command deletes also all its exchanges, queues and user
+ mappings.
list_vhosts
list all virtual hosts.
@@ -153,7 +154,8 @@ messages_ready
number of messages ready to be delivered to clients
messages_unacknowledged
- number of messages delivered to clients but not yet acknowledged
+ number of messages delivered to clients but not yet
+ acknowledged
messages_uncommitted
number of messages published in as yet uncommitted transactions
@@ -290,7 +292,7 @@ them:
=head1 SEE ALSO
-rabbitmq-multi(1), rabbitmq-server(1)
+rabbitmq.conf(5), rabbitmq-multi(1), rabbitmq-server(1)
=head1 AUTHOR
diff --git a/packaging/RPMS/Fedora/init.d b/packaging/RPMS/Fedora/init.d
index 9409b73cad..fef5fe3d62 100644
--- a/packaging/RPMS/Fedora/init.d
+++ b/packaging/RPMS/Fedora/init.d
@@ -16,6 +16,7 @@
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/usr/sbin/rabbitmq-multi
NAME=rabbitmq-server
DESC=rabbitmq-server
@@ -89,7 +90,10 @@ status_rabbitmq() {
rotate_logs_rabbitmq() {
set +e
- $DAEMON rotate_logs ${ROTATE_SUFFIX} 2>&1
+ $DAEMON rotate_logs ${ROTATE_SUFFIX}
+ if [ $? != 0 ] ; then
+ RETVAL=1
+ fi
set -e
}
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.logrotate b/packaging/RPMS/Fedora/rabbitmq-server.logrotate
index ab87e4a5c6..6b657614de 100644
--- a/packaging/RPMS/Fedora/rabbitmq-server.logrotate
+++ b/packaging/RPMS/Fedora/rabbitmq-server.logrotate
@@ -7,6 +7,6 @@
notifempty
sharedscripts
postrotate
- /sbin/service rabbitmq-server rotate-logs
+ /sbin/service rabbitmq-server rotate-logs > /dev/null
endscript
}
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec
index c636c820ae..b9693092f1 100644
--- a/packaging/RPMS/Fedora/rabbitmq-server.spec
+++ b/packaging/RPMS/Fedora/rabbitmq-server.spec
@@ -60,6 +60,8 @@ install -p -D -m 0755 %{S:2} %{buildroot}%{_sbindir}/rabbitmq-multi
install -p -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server
+mkdir -p %{buildroot}/etc/rabbitmq
+
rm %{_maindir}/LICENSE %{_maindir}/LICENSE-MPL-RabbitMQ %{_maindir}/INSTALL
#Build the list of files
@@ -99,6 +101,9 @@ fi
%defattr(-,root,root,-)
%attr(0750, rabbitmq, rabbitmq) %dir /var/lib/rabbitmq
%attr(0750, rabbitmq, rabbitmq) %dir /var/log/rabbitmq
+%dir /var/lib/rabbitmq
+%dir /var/log/rabbitmq
+%dir /etc/rabbitmq
%{_rabbit_erllibdir}
%{_rabbit_libdir}
%{_initrddir}/rabbitmq-server
diff --git a/packaging/debs/Debian/debian/dirs b/packaging/debs/Debian/debian/dirs
index 1a707bc191..625b7d41f5 100644
--- a/packaging/debs/Debian/debian/dirs
+++ b/packaging/debs/Debian/debian/dirs
@@ -5,4 +5,5 @@ usr/share/man
var/lib/rabbitmq/mnesia
var/log/rabbitmq
etc/logrotate.d
+etc/rabbitmq
diff --git a/packaging/debs/Debian/debian/init.d b/packaging/debs/Debian/debian/init.d
index 36cb922cc4..ef66add5a5 100644
--- a/packaging/debs/Debian/debian/init.d
+++ b/packaging/debs/Debian/debian/init.d
@@ -9,6 +9,7 @@
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/usr/sbin/rabbitmq-multi
NAME=rabbitmq-server
DESC=rabbitmq-server
@@ -78,7 +79,10 @@ status_rabbitmq() {
rotate_logs_rabbitmq() {
set +e
- $DAEMON rotate_logs ${ROTATE_SUFFIX} 2>&1
+ $DAEMON rotate_logs ${ROTATE_SUFFIX}
+ if [ $? != 0 ] ; then
+ RETVAL=1
+ fi
set -e
}
diff --git a/packaging/debs/Debian/debian/postrm b/packaging/debs/Debian/debian/postrm
index 8d1e92a929..a999d95b29 100644
--- a/packaging/debs/Debian/debian/postrm
+++ b/packaging/debs/Debian/debian/postrm
@@ -31,6 +31,9 @@ case "$1" in
if [ -d /var/run/rabbitmq ]; then
rm -r /var/run/rabbitmq
fi
+ if [ -d /etc/rabbitmq ]; then
+ rm -r /etc/rabbitmq
+ fi
if getent passwd rabbitmq >/dev/null; then
deluser rabbitmq
fi
diff --git a/packaging/debs/Debian/debian/rabbitmq-server.logrotate b/packaging/debs/Debian/debian/rabbitmq-server.logrotate
index bfd6b8da0b..c786df77b2 100644
--- a/packaging/debs/Debian/debian/rabbitmq-server.logrotate
+++ b/packaging/debs/Debian/debian/rabbitmq-server.logrotate
@@ -7,6 +7,6 @@
notifempty
sharedscripts
postrotate
- /etc/init.d/rabbitmq-server rotate-logs
+ /etc/init.d/rabbitmq-server rotate-logs > /dev/null
endscript
}
diff --git a/scripts/rabbitmq-multi b/scripts/rabbitmq-multi
index 84985e900f..4cf0703a4c 100755
--- a/scripts/rabbitmq-multi
+++ b/scripts/rabbitmq-multi
@@ -30,7 +30,7 @@
## Contributor(s): ______________________________________.
##
-[ -f /etc/default/rabbitmq ] && . /etc/default/rabbitmq
+[ -f /etc/rabbitmq/rabbitmq.conf ] && . /etc/rabbitmq/rabbitmq.conf
[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=rabbit
@@ -54,6 +54,11 @@ export \
RABBITMQ_SCRIPT_HOME \
RABBITMQ_PIDS_FILE
+# we need to turn off path expansion because some of the vars, notably
+# RABBITMQ_MULTI_ERL_ARGS, may contain terms that look like globs and
+# there is no other way of preventing their expansion.
+set -f
+
exec erl \
-pa "`dirname $0`/../ebin" \
-noinput \
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 572262c97e..6273804f56 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -30,7 +30,7 @@
## Contributor(s): ______________________________________.
##
-[ -f /etc/default/rabbitmq ] && . /etc/default/rabbitmq
+[ -f /etc/rabbitmq/rabbitmq.conf ] && . /etc/rabbitmq/rabbitmq.conf
[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=rabbit
@@ -43,7 +43,7 @@
-kernel inet_default_listen_options [{nodelay,true},{sndbuf,16384},{recbuf,4096}] \
-kernel inet_default_connect_options [{nodelay,true}]"
[ "x" = "x$RABBITMQ_CLUSTER_CONFIG_FILE" ] && RABBITMQ_CLUSTER_CONFIG_FILE=${CLUSTER_CONFIG_FILE}
-[ "x" = "x$RABBITMQ_CLUSTER_CONFIG_FILE" ] && RABBITMQ_CLUSTER_CONFIG_FILE=/etc/default/rabbitmq_cluster.config
+[ "x" = "x$RABBITMQ_CLUSTER_CONFIG_FILE" ] && RABBITMQ_CLUSTER_CONFIG_FILE=/etc/rabbitmq/rabbitmq_cluster.config
[ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE}
[ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=/var/log/rabbitmq
[ "x" = "x$RABBITMQ_MNESIA_BASE" ] && RABBITMQ_MNESIA_BASE=${MNESIA_BASE}
@@ -73,6 +73,11 @@ fi
RABBITMQ_START_RABBIT=
[ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT='-noinput -s rabbit'
+# we need to turn off path expansion because some of the vars, notably
+# RABBITMQ_SERVER_ERL_ARGS, contain terms that look like globs and
+# there is no other way of preventing their expansion.
+set -f
+
exec erl \
-pa "`dirname $0`/../ebin" \
${RABBITMQ_START_RABBIT} \
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 41064c772c..97bbdd9936 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -182,6 +182,10 @@ start(normal, []) ->
fun () ->
ok = start_child(rabbit_persister)
end},
+ {"guid generator",
+ fun () ->
+ ok = start_child(rabbit_guid)
+ end},
{"builtin applications",
fun () ->
{ok, DefaultVHost} = application:get_env(default_vhost),
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index ca2782c77d..4bf2f44602 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -265,7 +265,7 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
%% certain to want to look at delivery-mode and priority.
DecodedContent = rabbit_binary_parser:ensure_content_decoded(Content),
PersistentKey = case is_message_persistent(DecodedContent) of
- true -> rabbit_misc:guid();
+ true -> rabbit_guid:guid();
false -> none
end,
{noreply, publish(Mandatory, Immediate,
@@ -338,7 +338,7 @@ handle_method(#'basic.consume'{queue = QueueNameBin,
QueueName = expand_queue_name_shortcut(QueueNameBin, State),
ActualConsumerTag =
case ConsumerTag of
- <<>> -> rabbit_misc:binstring_guid("amq.ctag");
+ <<>> -> rabbit_guid:binstring_guid("amq.ctag");
Other -> Other
end,
@@ -550,7 +550,7 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
{error, not_found} ->
ActualNameBin =
case QueueNameBin of
- <<>> -> rabbit_misc:binstring_guid("amq.gen");
+ <<>> -> rabbit_guid:binstring_guid("amq.gen");
Other -> check_name('queue', Other)
end,
QueueName = rabbit_misc:r(VHostPath, queue, ActualNameBin),
@@ -751,7 +751,7 @@ ack(ProxyPid, TxnKey, UAQ) ->
[QPid | L]
end, [], UAQ).
-make_tx_id() -> rabbit_misc:guid().
+make_tx_id() -> rabbit_guid:guid().
new_tx(State) ->
State#ch{transaction_id = make_tx_id(),
diff --git a/src/rabbit_guid.erl b/src/rabbit_guid.erl
new file mode 100644
index 0000000000..51c1665bbb
--- /dev/null
+++ b/src/rabbit_guid.erl
@@ -0,0 +1,126 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developers of the Original Code are LShift Ltd,
+%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+%%
+%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+%% Technologies LLC, and Rabbit Technologies Ltd.
+%%
+%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+%% Ltd. Portions created by Cohesive Financial Technologies LLC are
+%% Copyright (C) 2007-2009 Cohesive Financial Technologies
+%% LLC. Portions created by Rabbit Technologies Ltd are Copyright
+%% (C) 2007-2009 Rabbit Technologies Ltd.
+%%
+%% All Rights Reserved.
+%%
+%% Contributor(s): ______________________________________.
+%%
+
+-module(rabbit_guid).
+
+-include("rabbit.hrl").
+
+-behaviour(gen_server).
+
+-export([start_link/0]).
+-export([guid/0, string_guid/1, binstring_guid/1]).
+
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+ terminate/2, code_change/3]).
+
+-define(SERVER, ?MODULE).
+
+-record(state, {serial}).
+
+%%----------------------------------------------------------------------------
+
+-ifdef(use_specs).
+
+-spec(start_link/0 :: () -> {'ok', pid()} | 'ignore' | {'error', any()}).
+-spec(guid/0 :: () -> guid()).
+-spec(string_guid/1 :: (any()) -> string()).
+-spec(binstring_guid/1 :: (any()) -> binary()).
+
+-endif.
+
+%%----------------------------------------------------------------------------
+
+start_link() ->
+ %% The persister can get heavily loaded, and we don't want that to
+ %% impact guid generation. We therefore keep the serial in a
+ %% separate process rather than calling rabbit_persister:serial/0
+ %% directly in the functions below.
+ gen_server:start_link({local, ?SERVER}, ?MODULE,
+ [rabbit_persister:serial()], []).
+
+%% generate a guid that is monotonically increasing per process.
+%%
+%% The id is only unique within a single cluster and as long as the
+%% persistent message store hasn't been deleted.
+guid() ->
+ %% We don't use erlang:now() here because a) it may return
+ %% duplicates when the system clock has been rewound prior to a
+ %% restart, or ids were generated at a high rate (which causes
+ %% now() to move ahead of the system time), and b) it is really
+ %% slow since it takes a global lock and makes a system call.
+ %%
+ %% rabbit_persister:serial/0, in combination with self/0 (which
+ %% includes the node name) uniquely identifies a process in space
+ %% and time. We combine that with a process-local counter to give
+ %% us a GUID that is monotonically increasing per process.
+ G = case get(guid) of
+ undefined -> {{gen_server:call(?SERVER, serial), self()}, 0};
+ {S, I} -> {S, I+1}
+ end,
+ put(guid, G),
+ G.
+
+%% generate a readable string representation of a guid. Note that any
+%% monotonicity of the guid is not preserved in the encoding.
+string_guid(Prefix) ->
+ %% we use the (undocumented) ssl_base64 module here because it is
+ %% present throughout OTP R11 and R12 whereas base64 only becomes
+ %% available in R11B-4.
+ %%
+ %% TODO: once debian stable and EPEL have moved from R11B-2 to
+ %% R11B-4 or later we should change this to use base64.
+ Prefix ++ "-" ++ ssl_base64:encode(erlang:md5(term_to_binary(guid()))).
+
+binstring_guid(Prefix) ->
+ list_to_binary(string_guid(Prefix)).
+
+%%----------------------------------------------------------------------------
+
+init([Serial]) ->
+ {ok, #state{serial = Serial}}.
+
+handle_call(serial, _From, State = #state{serial = Serial}) ->
+ {reply, Serial, State};
+
+handle_call(_Request, _From, State) ->
+ {noreply, State}.
+
+handle_cast(_Msg, State) ->
+ {noreply, State}.
+
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+terminate(_Reason, _State) ->
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 973e163b7a..053bde54cc 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -46,7 +46,6 @@
-export([ensure_ok/2]).
-export([localnode/1, tcp_name/3]).
-export([intersperse/2, upmap/2, map_in_order/2]).
--export([guid/0, string_guid/1, binstring_guid/1]).
-export([dirty_read_all/1, dirty_foreach_key/2, dirty_dump_log/1]).
-export([append_file/2, ensure_parent_dirs_exist/1]).
-export([format_stderr/2]).
@@ -98,9 +97,6 @@
-spec(intersperse/2 :: (A, [A]) -> [A]).
-spec(upmap/2 :: (fun ((A) -> B), [A]) -> [B]).
-spec(map_in_order/2 :: (fun ((A) -> B), [A]) -> [B]).
--spec(guid/0 :: () -> guid()).
--spec(string_guid/1 :: (any()) -> string()).
--spec(binstring_guid/1 :: (any()) -> binary()).
-spec(dirty_read_all/1 :: (atom()) -> [any()]).
-spec(dirty_foreach_key/2 :: (fun ((any()) -> any()), atom()) ->
'ok' | 'aborted').
@@ -299,42 +295,6 @@ map_in_order(F, L) ->
lists:reverse(
lists:foldl(fun (E, Acc) -> [F(E) | Acc] end, [], L)).
-%% generate a guid that is monotonically increasing per process.
-%%
-%% The id is only unique within a single cluster and as the persistent
-%% message store hasn't been deleted.
-guid() ->
- %% We don't use erlang:now() here because a) it may return
- %% duplicates when the system clock has been rewound prior to a
- %% restart, or ids were generated at a high rate (which causes
- %% now() to move ahead of the system time), and b) it is really
- %% slow since it takes a global lock and makes a system call.
- %%
- %% rabbit_persister:serial/0, in combination with self/0 (which
- %% includes the node name) uniquely identifies a process in space
- %% and time. We combine that with a process-local counter to give
- %% us a GUID that is monotonically increasing per process.
- G = case get(guid) of
- undefined -> {{rabbit_persister:serial(), self()}, 0};
- {S, I} -> {S, I+1}
- end,
- put(guid, G),
- G.
-
-%% generate a readable string representation of a guid. Note that any
-%% monotonicity of the guid is not preserved in the encoding.
-string_guid(Prefix) ->
- %% we use the (undocumented) ssl_base64 module here because it is
- %% present throughout OTP R11 and R12 whereas base64 only becomes
- %% available in R11B-4.
- %%
- %% TODO: once debian stable and EPEL have moved from R11B-2 to
- %% R11B-4 or later we should change this to use base64.
- Prefix ++ "-" ++ ssl_base64:encode(erlang:md5(term_to_binary(guid()))).
-
-binstring_guid(Prefix) ->
- list_to_binary(string_guid(Prefix)).
-
dirty_read_all(TableName) ->
mnesia:dirty_select(TableName, [{'$1',[],['$1']}]).
diff --git a/src/rabbit_persister.erl b/src/rabbit_persister.erl
index c34ad85100..94033a4f3d 100644
--- a/src/rabbit_persister.erl
+++ b/src/rabbit_persister.erl
@@ -92,7 +92,7 @@ start_link() ->
transaction(MessageList) ->
?LOGDEBUG("transaction ~p~n", [MessageList]),
- TxnKey = rabbit_misc:guid(),
+ TxnKey = rabbit_guid:guid(),
gen_server:call(?SERVER, {transaction, TxnKey, MessageList}).
extend_transaction(TxnKey, MessageList) ->