Site ID is a random unique identifier of the node that persists between restarts and hostname changes. Each node creates this identifier once and then never changes it.
By default, classy initializes site with a random value.
Business applications can override this behavior by registering a classy:on_node_init/2 hook
containing a call to classy_node:maybe_init_the_site/1:
classy:on_node_init(
fun() ->
classy_node:maybe_init_the_site(MySiteId)
end,
0)
Cluster ID is a unique random identifier of the cluster.
Each site starts in its very own cluster with a random ID. When a site joins a remote node, it inherits the cluster ID of the remote.
Run level is a global system state that indicates “readiness” of the local site.
It is represented by an integer in the range 0..300
and is derived from the configuration and the number of peers.
The run levels are split into the following ranges:
stopped (0..9):
Classy application itself is not running or is not ready.
These run levels are reserved for classy’s own initialization logic,
business applications must not use them.
single (10..99):
Classy application is ready to process cluster membership information,
but the total number of known sites (including the local site)
may be less than n_sites.
These run levels correspond to initialization of a singleton node.
cluster (100..199):
the total number of known sites (including the local site) is at least n_sites,
but the number of connected sites (including the local site) may be less than quorum.
quorum (200..299):
the number of connected sites (including the local site) satisfies the quorum configuration.
ready (300):
final run level.
The site is fully connected and operational.
Unless the whole BEAM VM or the classy application is stopped abruptly
(erlang:halt, kill, power loss),
the run level is stepped in an increasing or decreasing arithmetic progression:
it always advances and regresses in sequence.
When classy:start_system/0 is called for the first time,
the system starts at the stopped run level (0)
and eventually progresses to the ready run level (300).
Effect of classy:stop_system/0 is the opposite.
Business applications can track the run level via classy:on_run_level/2 hook.
This hook can, for example,
activate or deactivate some business applications.
The boot sequence and barriers that can pause the run level progression
are managed by the classy_boot module.