Skip to main content

Module dev

Module dev 

Source
Expand description

Local cluster orchestrator: S, P, O, string-registry, and compute.

waratah start spawns the four storage-side processes from their own binaries (waratah-partition, waratah-registry) at the addresses in the static ClusterConfig, then runs the compute coordinator in this process behind an RDF4J HTTP facade (waratah_api) by default. It daemonizes itself unless --foreground is given (see crate::daemon).

waratah standalone skips spawn: this process opens waratah_partition::PartitionService Γ—3 and waratah_registry::RegistryService and injects them into compute (same SPARQL / HTTP session, no gRPC). Always foreground.

Nothing here is a production supervisor β€” restarts, health checks, and address discovery belong to the gossip/etcd work in Phase 10.

StructsΒ§

DevOptions
Options for start.
SpawnedCluster πŸ”’
Child processes, killed when this value is dropped.
WarmGate πŸ”’
Startup cache-warm gating handed to a session: the shared tracker (standalone mode; /health returns 503 with the pending walk names until it drains) plus any orchestrator warnings (RPC mode; a child walk outlived the readiness wait). Both surface in the /health body.

EnumsΒ§

Backend
Backend for the spawned hexastore partitions.
WarmProbe πŸ”’
One storage child’s Health probe (the two tonic client types differ, so the poll matches on which it holds).

ConstantsΒ§

DEFAULT_HTTP_ADDR
Default RDF4J HTTP listen address (/rdf4j under this host:port).
DEMO_COMMIT_TS πŸ”’
Commit timestamp of the demo load (Phase 8 assigns these from a TSO).
DEV_PID_FILE πŸ”’
Pidfile name: next to the data dir when one is set, otherwise in the working directory (memory-backend daemons). waratah stop reads it to SIGTERM us.
HTTP_DRAIN_TIMEOUT πŸ”’
How long outstanding HTTP work gets to drain after the shutdown signal before remaining connections (kernel websockets) are force-closed. Kept well under waratah stop’s SIGKILL deadline so the sidecar’s own graceful kernel shutdown (waratah_notebook SHUTDOWN_GRACE) still gets to run.
STARTUP_TIMEOUT πŸ”’
How long to wait for a spawned process to accept connections.

FunctionsΒ§

another_server_using_storage πŸ”’
Whether another waratah server is already serving THIS data dir: the pidfile there names a live pid that is not ours. The pidfile is the existing cross-process channel (waratah start and standalone write one and remove it on exit), so a live foreign pid is a server on the same storage. A memory backend shares no storage β€” each process owns its store β€” so None finds nothing to detect. Our own pid is the pidfile this process just wrote, not a peer.
binary πŸ”’
data_dir πŸ”’
demo_dataset
Weather/city dataset behind the demo SELECT, extended with the schema triples the AI-context endpoint demonstrates against: an rdfs:label on every subject and a two-level rdfs:subClassOf hierarchy (Person β†’ Agent β†’ Thing, City β†’ Place β†’ Thing). The parent classes deliberately have no instances β€” they surface only via the transitive superClasses closure, which is exactly the shape the endpoint must get right.
demo_queries
Built-in query library published under --load-demo when no --queries-dir is configured. Every query returns rows over demo_dataset, so the console Query library works out of the box. Entries keep this declaration order on the wire (the (order, id) sort belongs to the directory source, not the inline one).
is_tmpfs πŸ”’
Whether path sits on a tmpfs mount (Linux only; other platforms report false and skip the check).
log_spill_root πŸ”’
Log the resolved spill root and warn when spilled pages would stay in RAM.
pidfile_dir πŸ”’
Directory the pidfile lives in: the data dir when one is set, otherwise the working directory (memory-backend daemons write one there so waratah stop without --data-dir can find them).
pidfile_path πŸ”’
Full pidfile path for a data-dir choice: {data_dir}/waratah-dev.pid, or ./waratah-dev.pid for the memory backend.
print_query_results πŸ”’
process_alive πŸ”’
Whether pid has a live process. Signal-0 probe plus a zombie check: an exited-but-unreaped child (its parent has not waited yet) still answers kill(pid, 0), which would make waratah stop wait out its whole deadline on a process that is already gone.
remove_pidfile πŸ”’
remove_pidfile_if_names πŸ”’
Remove path only when it still names pid β€” never a file that has been overwritten by (or always belonged to) another cluster. A pidfile IS the waratah stop handle, so deleting someone else’s leaves their live cluster unstoppable. Returns whether a file was removed.
repl πŸ”’
Read one query per line from stdin until EOF, quit, or shutdown signal.
run_query πŸ”’
run_session πŸ”’
serve_http_until πŸ”’
Serve HTTP on an already-bound listener until the listener fails or shutdown is signalled, then give outstanding requests a bounded drain before force-closing what is left.
spawn_compute_admin πŸ”’
start
Spawn the storage-side processes (unless the waratah standalone command set options.standalone), then run compute.
stop
waratah stop [--data-dir DIR]: SIGTERM the orchestrator recorded in {data_dir}/waratah-dev.pid (or ./waratah-dev.pid without a data dir β€” where memory-backend daemons put it) β€” its signal handler kills the storage children and the notebook sidecar’s process group β€” wait, then SIGKILL as a last resort.
wait_cluster_warm πŸ”’
Poll every storage child’s Health RPC until its cache-warm walk finishes (warm_ready), so the HTTP server β€” and the benchmark’s start signal β€” only comes up after first queries can no longer race the warm pass.
wait_until_listening πŸ”’
Poll addr until the process accepts a connection or the timeout expires.
write_pidfile πŸ”’
Claim the pidfile for this process. Refuses the start when the file already names a LIVE foreign pid: overwriting it would leave that cluster with no waratah stop handle. A stale file (dead pid, or our own pid from a restarted run) is overwritten.