Beethoven.Tracker (Beethoven v0.2.3)

Module to handle the Beethoven.Tracker mnesia table. This table is used by beethoven to track the state and roles of nodes within the cluster.

Summary

Functions

Add role to a node.

Adds self to BeethovenTracking Mnesia table. Uses a record like this

List of builtin roles used for filtering.

Clear all roles from offline nodes. Returns list of roles cleared.

Clear all roles from a node.

Compares a list of roles to what is hosted in the Tracker. Returns roles that are not hosted in Mnesia, but provided in the argument. Duplicate inputs are allowed and encouraged.

Gets roles hosted in the cluster. Provides list of roles - this list is not deduplicated.

Gets the count of roles held by each node. Provides a list of lists, where each nested list is data from a single record in mnesia.

Gets roles hosted in the cluster by offline nodes. Provides list of roles - this list is not deduplicated.

Checks if a role is hosted on a given node.

Checks if a role is hosted in the cluster. Does not return truthful if the hosting node is offline.

Joins the Beethoven.Tracker mnesia table as a cluster node.

Removes builtin roles from a list of roles provided to the function.

Remove role from a node.

Sets node in tracker offline. Also clears roles on the node.

Starts Beethoven.Tracker Mnesia table

Subscribe to changes to the BeethovenTracking Mnesia table.

Functions

add_role(nodeName, role)

@spec add_role(atom(), atom()) :: :ok

Add role to a node.

add_self(roles \\ [])

@spec add_self(list()) :: :ok

Adds self to BeethovenTracking Mnesia table. Uses a record like this:

{Tracker, node(), roles, :online, DateTime.now!("Etc/UTC")}

builtin_roles()

@spec builtin_roles() :: list()

List of builtin roles used for filtering.

clear_offline_roles()

@spec clear_offline_roles() :: list()

Clear all roles from offline nodes. Returns list of roles cleared.

clear_roles(nodeName)

@spec clear_roles(atom()) :: :ok

Clear all roles from a node.

find_work(role_list)

@spec find_work(list()) :: list()

Compares a list of roles to what is hosted in the Tracker. Returns roles that are not hosted in Mnesia, but provided in the argument. Duplicate inputs are allowed and encouraged.

get_active_roles()

@spec get_active_roles() :: list()

Gets roles hosted in the cluster. Provides list of roles - this list is not deduplicated.

get_active_roles_by_host()

@spec get_active_roles_by_host() :: list()

Gets the count of roles held by each node. Provides a list of lists, where each nested list is data from a single record in mnesia.

get_inactive_roles()

@spec get_inactive_roles() :: list()

Gets roles hosted in the cluster by offline nodes. Provides list of roles - this list is not deduplicated.

is_host_running_role?(nodeName, role)

@spec is_host_running_role?(atom(), atom()) :: boolean()

Checks if a role is hosted on a given node.

is_role_hosted?(role)

@spec is_role_hosted?(atom()) :: boolean()

Checks if a role is hosted in the cluster. Does not return truthful if the hosting node is offline.

join()

@spec join() :: :ok | :not_started | :copy_error

Joins the Beethoven.Tracker mnesia table as a cluster node.

remove_builtins(role_list)

@spec remove_builtins(list()) :: list()

Removes builtin roles from a list of roles provided to the function.

remove_role(nodeName, role)

@spec remove_role(atom(), atom()) :: :ok

Remove role from a node.

set_node_offline(nodeName)

@spec set_node_offline(node()) :: :ok

Sets node in tracker offline. Also clears roles on the node.

start()

@spec start() :: :ok | :copied | :already_exists

Starts Beethoven.Tracker Mnesia table

subscribe()

@spec subscribe() :: {:ok, node()} | {:error, reason :: term()}

Subscribe to changes to the BeethovenTracking Mnesia table.