Skip to main content

Module admin_rpc

Module admin_rpc 

Source
Expand description

Cluster admin RPC surface.

This module defines the trait ClusterAdmin that the dyniak PBC server invokes when an operator drives one of the cluster-list, cluster-join, cluster-leave, cluster-plan, or cluster-commit admin commands. These mutations are surfaced through this trait so the same staging-then-commit semantics can be exercised from tests and from the CLI without forcing a real DNODE round-trip.

The default in-process implementation is PoolClusterAdmin: it owns an Arc<ServerPool> and a lock-protected list of staged ClusterChange entries. cluster_join and cluster_leave push a change onto the staging list and return the JoinPlan so the caller can print it; cluster_commit applies every staged change in order under the pool’s existing peer / auto-eject RwLocks and rebuilds the token continuum on the way out.

§Examples

use std::net::SocketAddr;
use std::sync::Arc;

use dynomite::cluster::admin_rpc::{ClusterAdmin, PoolClusterAdmin};
use dynomite::cluster::peer::{Peer, PeerEndpoint};
use dynomite::cluster::pool::{PoolConfig, ServerPool};
use dynomite::hashkit::DynToken;

let cfg = PoolConfig {
    dc: "dc1".into(),
    rack: "r1".into(),
    ..PoolConfig::default()
};
let local = Peer::new(
    0, PeerEndpoint::tcp("127.0.0.1".into(), 8101), "r1".into(), "dc1".into(),
    vec![DynToken::from_u32(0)], true, true, false,
);
let pool = Arc::new(ServerPool::new(cfg, vec![local]));
let admin = PoolClusterAdmin::new(pool);
assert_eq!(admin.list_peers().len(), 1);
let target: SocketAddr = "127.0.0.1:8102".parse().unwrap();
let plan = admin.cluster_join(target).unwrap();
assert!(plan.change.peer.is_some());
assert_eq!(admin.cluster_plan_pending().len(), 1);
admin.cluster_commit().unwrap();
assert_eq!(admin.list_peers().len(), 2);

Structs§

ClusterChange
One pending cluster-membership mutation.
JoinPlan
Plan returned by ClusterAdmin::cluster_join and ClusterAdmin::cluster_leave.
NoopClusterAdmin
ClusterAdmin that always reports an empty cluster and rejects mutations. Used by callers that have not wired the real admin surface.
PeerSnapshot
Snapshot of one peer the admin layer reports back over the PBC. The shape is intentionally small and self-describing so the wire format can serialise every field with no further lookups.
PeerSpec
Description of a peer to add to the cluster.
PoolClusterAdmin
ClusterAdmin backed by an Arc<ServerPool>.

Enums§

ClusterChangeKind
Direction of a staged ClusterChange.
ClusterError
Errors produced by the cluster admin layer.

Traits§

ClusterAdmin
Cluster-membership admin surface.