diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2013-03-22 15:07:53 -0500 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2014-07-23 17:56:26 +0100 |
commit | 837f0457a0e4e280fed6741af33e6a61c5fbf016 (patch) | |
tree | aebcdba55612782083e624be862f760fad7f3919 | |
parent | f5907c4b89456d3120a4d1e1080d9203e6522816 (diff) | |
download | couchdb-837f0457a0e4e280fed6741af33e6a61c5fbf016.tar.gz |
[2/3] Start a rexi_server per remote node
Switch sending rexi messages to the rexi_server handling requests for
the local node. This replaces the use of the singleton rexi_server
process with a rexi_server instance for each node.
The only slight gotchya in the switch is that we need to send kill
messages to both the per-node and singleton instances during the
transition because we can't tell which process may have generated the
job. The extra kill message will be removed in the next commit.
-rw-r--r-- | src/rexi.erl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rexi.erl b/src/rexi.erl index a4c786dc3..c970f8051 100644 --- a/src/rexi.erl +++ b/src/rexi.erl @@ -19,8 +19,6 @@ -include_lib("rexi/include/rexi.hrl"). --define(SERVER, rexi_server). - start() -> application:start(rexi). @@ -47,7 +45,7 @@ cast(Node, MFA) -> cast(Node, Caller, MFA) -> Ref = make_ref(), Msg = cast_msg({doit, {Caller, Ref}, get(nonce), MFA}), - rexi_utils:send({?SERVER, Node}, Msg), + rexi_utils:send(rexi_utils:server_pid(Node), Msg), Ref. %% @doc Executes apply(M, F, A) on Node. @@ -61,7 +59,7 @@ cast(Node, Caller, MFA, Options) -> true -> Ref = make_ref(), Msg = cast_msg({doit, {Caller, Ref}, get(nonce), MFA}), - erlang:send({?SERVER, Node}, Msg), + erlang:send(rexi_utils:server_pid(Node), Msg), Ref; false -> cast(Node, Caller, MFA) @@ -71,7 +69,10 @@ cast(Node, Caller, MFA, Options) -> %% No rexi_EXIT message will be sent. -spec kill(node(), reference()) -> ok. kill(Node, Ref) -> - rexi_utils:send({?SERVER, Node}, cast_msg({kill, Ref})), + % This first version is to tide us over during the upgrade. We'll + % remove it in the next commit that will be in a separate release. + rexi_utils:send({rexi_server, Node}, cast_msg({kill, Ref})), + rexi_utils:send(rexi_utils:server_pid(Node), cast_msg({kill, Ref})), ok. %% @equiv async_server_call(Server, self(), Request) |