# `ExFdbmonitor.MgmtServer`
[🔗](https://github.com/foundationdb-beam/ex_fdbmonitor/blob/main/lib/ex_fdbmonitor/mgmt_server.ex#L3)

A DGen.Server that serializes actions across all nodes.

Nodes submit fdbcli commands via `exec/1`. The DGen.Server processes
them one at a time, ensuring commands from different nodes don't
interleave on a cluster that is still being configured.

# `adopt_node`

Register `node_name` as the node for `machine_id`, unless that machine_id
already belongs to a different node.

For a node that was not registered at bootstrap, such as one in a cluster
bootstrapped before MgmtServer existed. Returns `:ok` if the node is now
registered, or was already, and `{:error, {:machine_id_taken, other_node}}`
if another node holds the machine_id, as when a node's name has changed.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `exclude`

Exclude all FDB processes belonging to `node_name` from the cluster.

Raises if the node has no registered machine_id.

# `exec`

Execute `fdbcli_args` through the serialized server.

# `get_machine_id`

Look up the machine_id for a given node name.

# `include`

Include all FDB processes belonging to `node_name` back into the cluster.

Returns `{:error, {:unknown_node, node_name}}` if the node has no registered machine_id.

# `register_node`

Register a mapping from `machine_id` to `node_name` in the server state.

# `scale_down`

Gracefully remove `nodes_to_exclude` from the cluster.

Automatically determines the appropriate redundancy mode for the
surviving nodes and downgrades if necessary. Executes under the
DGen.Server lock:
1. `configure <mode>` (only if downgrade needed)
2. Set coordinators to surviving nodes
3. `exclude` each departing node (blocks until data moved)

The caller is responsible for stopping workers on the removed nodes
after this call returns.

# `scale_up`

Declare the desired redundancy mode and configure when ready.

When `target_mode` is non-nil it is stored as the redundancy ceiling.
When `target_mode` is nil the previously stored mode is used (also
nil is fine — the call becomes a no-op).

`nodes_to_include` is a list of node names to `include` back into FDB
before configuring (e.g. after a previous `exclude`).

If enough nodes are registered (`@min_nodes`), acquires the lock and
runs `include` → `coordinators auto` → `configure <mode>`.  Calls
before the threshold is met are no-ops.

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
