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§
- Cluster
Change - One pending cluster-membership mutation.
- Join
Plan - Plan returned by
ClusterAdmin::cluster_joinandClusterAdmin::cluster_leave. - Noop
Cluster Admin ClusterAdminthat always reports an empty cluster and rejects mutations. Used by callers that have not wired the real admin surface.- Peer
Snapshot - 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.
- Peer
Spec - Description of a peer to add to the cluster.
- Pool
Cluster Admin ClusterAdminbacked by anArc<ServerPool>.
Enums§
- Cluster
Change Kind - Direction of a staged
ClusterChange. - Cluster
Error - Errors produced by the cluster admin layer.
Traits§
- Cluster
Admin - Cluster-membership admin surface.