Roberto Ostinelli 10 лет назад
Родитель
Сommit
6d7f8febcb
4 измененных файлов с 18 добавлено и 18 удалено
  1. 4 4
      README.md
  2. 9 9
      src/syn_netsplits.erl
  3. 2 2
      test/syn-test.config
  4. 3 3
      test/syn_netsplits_SUITE.erl

+ 4 - 4
README.md

@@ -151,7 +151,7 @@ Options can be set in the environment variable `syn`. You're probably best off u
     {process_exit_callback, [module1, function1]},
 
     %% define callback function on conflicting process (instead of kill)
-    {netsplit_conflicting_process_callback, [module2, function2]}
+    {conflicting_process_callback, [module2, function2]}
 ]}
 ```
 These options are explained here below.
@@ -196,7 +196,7 @@ After a net split, when nodes reconnect, Syn will merge the data from all the no
 
 If the same Key was used to register a process on different nodes during a netsplit, then there will be a conflict. By default, Syn will discard the processes running on the node the conflict is being resolved on, and will kill it by sending a `kill` signal with `exit(Pid, kill)`.
 
-If this is not desired, you can set the `netsplit_conflicting_process_callback` option to instruct Syn to trigger a callback, so that you can perform custom operations (such as a graceful shutdown). In this case, the process will not be killed by Syn, and you'll have to decide what to do with it. This callback will be called only on the node where the process is running.
+If this is not desired, you can set the `conflicting_process_callback` option to instruct Syn to trigger a callback, so that you can perform custom operations (such as a graceful shutdown). In this case, the process will not be killed by Syn, and you'll have to decide what to do with it. This callback will be called only on the node where the process is running.
 
 The callback function is defined as:
 ```erlang
@@ -213,7 +213,7 @@ For instance, if you want to send a `shutdown` message to the discarded process:
 ```erlang
 -module(my_callback).
 
-callback_on_netsplit_conflicting_process(_Key, Pid) ->
+callback_on_conflicting_process(_Key, Pid) ->
 	Pid ! shutdown
 ```
 
@@ -221,7 +221,7 @@ Set it in the options:
 ```erlang
 {syn, [
 	%% define callback function
-	{netsplit_conflicting_process_callback, [my_callback, callback_on_netsplit_conflicting_process]}
+	{conflicting_process_callback, [my_callback, callback_on_conflicting_process]}
 ]}
 ```
 

+ 9 - 9
src/syn_netsplits.erl

@@ -41,8 +41,8 @@
 
 %% records
 -record(state, {
-    netsplit_conflicting_process_callback_module = undefined :: atom(),
-    netsplit_conflicting_process_callback_function = undefined :: atom()
+    conflicting_process_callback_module = undefined :: atom(),
+    conflicting_process_callback_function = undefined :: atom()
 }).
 
 %% include
@@ -73,14 +73,14 @@ init([]) ->
     %% monitor mnesia events
     mnesia:subscribe(system),
     %% get options
-    {ok, [NetsplitConflictingProcessCallbackModule, NetsplitConflictingProcessCallbackFunction]} = syn_utils:get_env_value(
-        netsplit_conflicting_process_callback,
+    {ok, [ConflictingProcessCallbackModule, ConflictingProcessCallbackFunction]} = syn_utils:get_env_value(
+        conflicting_process_callback,
         [undefined, undefined]
     ),
     %% build state
     {ok, #state{
-        netsplit_conflicting_process_callback_module = NetsplitConflictingProcessCallbackModule,
-        netsplit_conflicting_process_callback_function = NetsplitConflictingProcessCallbackFunction
+        conflicting_process_callback_module = ConflictingProcessCallbackModule,
+        conflicting_process_callback_function = ConflictingProcessCallbackFunction
     }}.
 
 %% ----------------------------------------------------------------------------------------------------------
@@ -119,11 +119,11 @@ handle_cast(Msg, State) ->
     {stop, Reason :: any(), #state{}}.
 
 handle_info({mnesia_system_event, {inconsistent_database, Context, Node}}, #state{
-    netsplit_conflicting_process_callback_module = NetsplitConflictingProcessCallbackModule,
-    netsplit_conflicting_process_callback_function = NetsplitConflictingProcessCallbackFunction
+    conflicting_process_callback_module = ConflictingProcessCallbackModule,
+    conflicting_process_callback_function = ConflictingProcessCallbackFunction
 } = State) ->
     error_logger:warning_msg("MNESIA signalled an inconsistent database on node: ~p with context: ~p, initiating automerge~n", [Node, Context]),
-    automerge(Node, NetsplitConflictingProcessCallbackModule, NetsplitConflictingProcessCallbackFunction),
+    automerge(Node, ConflictingProcessCallbackModule, ConflictingProcessCallbackFunction),
     {noreply, State};
 
 handle_info({mnesia_system_event, {mnesia_down, Node}}, State) when Node =/= node() ->

+ 2 - 2
test/syn-test.config

@@ -16,10 +16,10 @@
         %% If the same Key was used to register a process on different nodes during a net split, then there will be a conflict.
         %% By default, Syn will discard the processes running on the node the conflict is being resolved on,
         %% and will kill it by sending a `kill` signal with `exit(Pid, kill)`.
-        %% If this is not desired, you can set the netsplit_conflicting_process_callback option here below to instruct Syn
+        %% If this is not desired, you can set the conflicting_process_callback option here below to instruct Syn
         %% to trigger a callback, so that you can perform custom operations (such as a graceful shutdown).
 
-        {netsplit_conflicting_process_callback, [syn_netsplits_SUITE, netsplit_conflicting_process_callback_dummy]}
+        {conflicting_process_callback, [syn_netsplits_SUITE, conflicting_process_callback_dummy]}
 
     ]}
 

+ 3 - 3
test/syn_netsplits_SUITE.erl

@@ -46,7 +46,7 @@
 
 %% internal
 -export([process_reply_main/0]).
--export([netsplit_conflicting_process_callback_dummy/2]).
+-export([conflicting_process_callback_dummy/2]).
 
 %% include
 -include_lib("common_test/include/ct.hrl").
@@ -325,7 +325,7 @@ two_nodes_netsplit_callback_resolution_when_there_are_conflicts(Config) ->
     SlaveNode = proplists:get_value(slave_node, Config),
     CurrentNode = node(),
 
-    %% load configuration variables from syn-test.config => this sets the netsplit_conflicting_process_callback option
+    %% load configuration variables from syn-test.config => this sets the conflicting_process_callback option
     syn_test_suite_helper:set_environment_variables(),
     syn_test_suite_helper:set_environment_variables(SlaveNode),
 
@@ -476,5 +476,5 @@ process_reply_main() ->
             global:send(syn_netsplits_SUITE_result, {exited, self()})
     end.
 
-netsplit_conflicting_process_callback_dummy(_Key, Pid) ->
+conflicting_process_callback_dummy(_Key, Pid) ->
     Pid ! shutdown.