View Source partisan_monitor (partisan v5.0.0-beta.14)

This module is responsible for monitoring processes on remote nodes.

YOU SHOULD NEVER USE the functions in this module. Use the related functions in partisan instead.

NOTICE

At the moment this only works for partisan_pluggable_peer_service_manager backend.

Also, certain partisan_peer_service_manager implementations might not support the partisan_peer_service_manager:on_up/2 and partisan_peer_service_manager:on_down/2 callbacks which we need for node monitoring, so in those cases this module will not work.

Link to this section Summary

Functions

Failure:
  • notalive if the partisan_monitor process is not alive.
  • not_implemented if the partisan peer service manager does not support the required capabilities required for monitoring.
  • badarg if any of the arguments is invalid.

When you attempt to monitor a remote process, it is not guaranteed that you will receive the DOWN message. A few reasons for not receiving the message are message loss, tree reconfiguration and the node is no longer reachable. The monitor options Opts are currently ignored.

Monitor the status of the node Node. If Flag is true, monitoring is turned on. If Flag is false, monitoring is turned off.

The calling process subscribes or unsubscribes to node status change messages. A nodeup message is delivered to all subscribing processes when a new node is connected, and a nodedown message is delivered when a node is disconnected. If Flag is true, a new subscription is started. If Flag is false, all previous subscriptions started with the same Options are stopped. Two option lists are considered the same if they contain the same set of options.

Starts the partisan monitor server.

Link to this section Types

-type demonitor_opts() :: [flush | info].
-type monitor_opts() :: list().
-type node_monitor() :: {node(), pid()}.
-type nodes_monitor() :: {{Owner :: pid(), Hash :: integer()}, nodes_monitor_opts()}.
-type nodes_monitor_opts() :: {Type :: all | visible | hidden, InclReason :: boolean()}.
-type process_monitor() ::
    {Mref :: reference(),
     MPid :: pid(),
     Owner :: partisan_remote_ref:p() | partisan_remote_ref:n()}.
Link to this type

process_monitor_cache/0

View Source
-type process_monitor_cache() ::
    {Node :: node(),
     Mref :: reference(),
     MPid :: partisan_remote_ref:p() | partisan_remote_ref:n(),
     Owner :: pid()}.
-type process_monitor_idx() :: {node(), reference()}.

Link to this section Functions

Link to this function

code_change(OldVsn, State, Extra)

View Source
Link to this function

demonitor(RemoteRef, Opts)

View Source
-spec demonitor(RemoteRef :: partisan_remote_ref:r(), Opts :: demonitor_opts()) ->
             boolean() | no_return().
Failure:
  • notalive if the partisan_monitor process is not alive.
  • not_implemented if the partisan peer service manager does not support the required capabilities required for monitoring.
  • badarg if any of the arguments is invalid.
Link to this function

handle_call(Msg, From, State)

View Source
Link to this function

monitor(RemoteRef, Opts)

View Source
-spec monitor(RemoteRef :: partisan_remote_ref:p() | partisan_remote_ref:n(), Opts :: monitor_opts()) ->
           partisan_remote_ref:r() | no_return().

When you attempt to monitor a remote process, it is not guaranteed that you will receive the DOWN message. A few reasons for not receiving the message are message loss, tree reconfiguration and the node is no longer reachable. The monitor options Opts are currently ignored.

Failure:
  • notalive if the partisan_monitor process is not alive.
  • not_implemented if the partisan peer service manager does not support the required capabilities required for monitoring.
  • badarg if any of the arguments is invalid.
Link to this function

monitor_node(Node, Flag)

View Source
-spec monitor_node(node() | partisan:node_spec(), boolean()) -> true.

Monitor the status of the node Node. If Flag is true, monitoring is turned on. If Flag is false, monitoring is turned off.

Making several calls to monitor_node(Node, true) for the same Node is not an error; it results in as many independent monitoring instances as the number of different calling processes i.e. If a process has made two calls to monitor_node(Node, true) and Node terminates, only one nodedown message is delivered to the process (this differs from erlang:monitor_node/2).

If Node fails or does not exist, the message {nodedown, Node} is delivered to the calling process. If there is no connection to Node, a nodedown message is delivered. As a result when using a membership strategy that uses a partial view, you cannot monitor nodes that are not members of the view.

Failure:
  • notalive if the partisan_monitor process is not alive.
  • not_implemented if the partisan peer service manager does not support the required capabilities required for monitoring.
  • badarg if any of the arguments is invalid.
Link to this function

monitor_nodes(Flag, Opts0)

View Source
-spec monitor_nodes(Flag :: boolean(), [partisan:monitor_nodes_opt()]) ->
                 ok | error | {error, notalive | not_implemented | badarg}.

The calling process subscribes or unsubscribes to node status change messages. A nodeup message is delivered to all subscribing processes when a new node is connected, and a nodedown message is delivered when a node is disconnected. If Flag is true, a new subscription is started. If Flag is false, all previous subscriptions started with the same Options are stopped. Two option lists are considered the same if they contain the same set of options.

Notice that the following two disterl guarantees are NOT yet provided by Partisan:
  • nodeup messages are delivered before delivery of any message from the remote node passed through the newly established connection.
  • nodedown messages are not delivered until all messages from the remote node that have been passed through the connection have been delivered.
Starts the partisan monitor server.
Link to this function

terminate(Reason, State)

View Source