1/* @ajax/mesh-fleetd: meshd's fleet member, wired over the daemon's shared state (main.rs's fleet
2 * thread, peer.rs `run` as the daemon sees it, reconcile.rs `run`, load.rs `perf_report`).
3 *
4 * The fleet area's @ajax/mesh-peer-relay runs the links, the leader, the policies and the lockstep
5 * data plane; it reaches the daemon only through `mpr_host`. This package is that host:
6 * - the status block, the mailbox and the lockstep feed are mesh_shared's (`host`, `mb`,
7 * `lock_feed`, `round_of`, `rtt`, `wait`);
8 * - the reconciler (@ajax/mesh-reconcile's thread) acts through driver commands (`mesh_shared_ask`:
9 * Load, Upgrade, Unload, Rollback, ProgRun, Reset, Task, Place, ViewPut, Inventory), takes images
10 * from the local catalog when they are the committed ones, else from a member (`mpr_fetch_image`),
11 * and migrated views from their source (`mpr_fetch_view`);
12 * - the catalog (`catalog`, `image`) is --programs, read with @ajax/mesh-loader;
13 * - placement frames go to the driver (Cmd PeerPlace / PeerFrame / PeerInput), and the fleet's view
14 * (FleetView) when it changes;
15 * - jobs and blobs go to @ajax/mesh-jobd (`mjd_*`), `job ...` requests as JobEvent::Ctl;
16 * - the texts and the fleet view's records go where the control port reads them (`fleet_text`,
17 * `groups_text`, `sched_*`, `fleet_view`).
18 * Two bridges carry what other threads send the fleet thread through mesh_shared: the `peer`
19 * channel's changes and wakes (control port, driver, jobs thread) become `mpr_change` / `mpr_wake`,
20 * and every member's `link_out` / `bulk_out` queue is written to its link with `mpr_send`.
21 * In a fleet, the load sampler's F_PERF (`mesh_load_perf`) is built here, with the reconciler's
22 * failures, the perf board's echoes and the link RTTs. */
23#ifndef MESH_FLEETD_H
24#define MESH_FLEETD_H
2526#include "mesh/cluster_conf.h"
27#include "mesh/peer_codec.h"
28#include "mesh/peer_relay.h"
29#include "mesh/shared.h"
3031#include <stdbool.h>
32#include <stdint.h>
3334typedef struct mesh_fleetd mesh_fleetd;
3536/* Before anything runs: reads (and checks) the member's fleet state file (NULL: in memory) for system
37 * topo->me; *skip_startup when it holds a committed document (--state / --autoload are for a fresh
38 * fleet). topo is copied. NULL with *err when the file is unusable. */
39mesh_fleetd *mesh_fleetd_open(mesh_shared *sh, const mcc_topology *topo, const char *state_path, bool *skip_startup, char **err);
4041/* This machine's F_JOIN capabilities from the mailbox header (H_CC, H_SMS, ...), its GPU's name,
42 * the architecture and the hostname. */
43mpk_caps mesh_fleetd_caps(mesh_shared *sh, const char *gpu, const char *arch);
4445/* Starts the bridges, the reconciler and (once the driver's startup loads ran: sh->ready) the fleet
46 * thread with its links. Sets mesh_load_perf. A fleet state that cannot be written fail-stops. */
47void mesh_fleetd_start(mesh_fleetd *f, const mpk_caps *caps);
4849/* Stops the fleet thread, the reconciler and the bridges (at exit, after the driver returned). */
50void mesh_fleetd_stop(mesh_fleetd *f);
51void mesh_fleetd_free(mesh_fleetd *f);
5253/* For tests and the control port: the relay once it started (NULL before). */
54mpr_relay *mesh_fleetd_relay(mesh_fleetd *f);
5556#endif