Retire unadmitted Model Atlas daemons
This commit is contained in:
parent
57cfd762e7
commit
56267201b7
6 changed files with 24 additions and 352 deletions
|
|
@ -1,100 +0,0 @@
|
|||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use epiphany_core::{
|
||||
AtlasImpactIngressRunConfig, AtlasImpactIngressRunOutcome, AtlasRepositoryIdentity,
|
||||
run_atlas_impact_ingress_once,
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let (args, switches) = arguments()?;
|
||||
let once = switches.contains("--once");
|
||||
let running = Arc::new(AtomicBool::new(true));
|
||||
let stop = running.clone();
|
||||
ctrlc::set_handler(move || stop.store(false, Ordering::SeqCst))?;
|
||||
while running.load(Ordering::SeqCst) {
|
||||
let config = AtlasImpactIngressRunConfig {
|
||||
local_repository: AtlasRepositoryIdentity::new(
|
||||
required(&args, "--swarm-id")?,
|
||||
required(&args, "--workspace-id")?,
|
||||
)?,
|
||||
projector_repository: AtlasRepositoryIdentity::new(
|
||||
required(&args, "--projector-swarm-id")?,
|
||||
required(&args, "--projector-workspace-id")?,
|
||||
)?,
|
||||
runtime_id: required(&args, "--runtime-id")?.into(),
|
||||
runtime_mind_store: path(&args, "--mind-store")?,
|
||||
local_verse_store: path(&args, "--verse-store")?,
|
||||
projector_store: path(&args, "--projector-store")?,
|
||||
impact_store: path(&args, "--impact-store")?,
|
||||
resident_self_store: path(&args, "--resident-self-store")?,
|
||||
cooldown_after_completion_ms: args
|
||||
.get("--cooldown-ms")
|
||||
.map(|value| value.parse())
|
||||
.transpose()?
|
||||
.unwrap_or(30_000),
|
||||
now_unix_ms: now_unix_ms()?,
|
||||
};
|
||||
match run_atlas_impact_ingress_once(&config)? {
|
||||
AtlasImpactIngressRunOutcome::HeldByBrake {
|
||||
brake_id,
|
||||
last_projection,
|
||||
} => println!(
|
||||
"atlas impact ingress held by brake {brake_id}; last projection remains read-only: {}",
|
||||
last_projection.is_some()
|
||||
),
|
||||
AtlasImpactIngressRunOutcome::Evaluated {
|
||||
admitted_impacts,
|
||||
scheduled_pressures,
|
||||
held_impacts,
|
||||
} => println!(
|
||||
"atlas impact ingress admitted {admitted_impacts}, scheduled {scheduled_pressures}, held {held_impacts}"
|
||||
),
|
||||
}
|
||||
if once {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn arguments() -> Result<(BTreeMap<String, String>, BTreeSet<String>)> {
|
||||
let mut values = BTreeMap::new();
|
||||
let mut switches = BTreeSet::new();
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(name) = args.next() {
|
||||
if name == "--once" {
|
||||
switches.insert(name);
|
||||
continue;
|
||||
}
|
||||
if !name.starts_with("--") {
|
||||
bail!("unexpected Atlas impact argument {name}")
|
||||
}
|
||||
values.insert(
|
||||
name.clone(),
|
||||
args.next()
|
||||
.ok_or_else(|| anyhow::anyhow!("{name} requires a value"))?,
|
||||
);
|
||||
}
|
||||
Ok((values, switches))
|
||||
}
|
||||
|
||||
fn required<'a>(args: &'a BTreeMap<String, String>, name: &str) -> Result<&'a str> {
|
||||
args.get(name)
|
||||
.map(String::as_str)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing required {name}"))
|
||||
}
|
||||
fn path(args: &BTreeMap<String, String>, name: &str) -> Result<PathBuf> {
|
||||
Ok(PathBuf::from(required(args, name)?))
|
||||
}
|
||||
fn now_unix_ms() -> Result<u64> {
|
||||
Ok(SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)?
|
||||
.as_millis()
|
||||
.try_into()?)
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use epiphany_core::{
|
||||
ATLAS_PUBLISHER_HEARTBEAT_INTERVAL_MS, AtlasPublisherRunConfig, AtlasPublisherRunOutcome,
|
||||
AtlasRepositoryIdentity, run_atlas_publisher_once,
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let (args, switches) = arguments()?;
|
||||
let once = switches.contains("--once");
|
||||
let running = Arc::new(AtomicBool::new(true));
|
||||
let stop = running.clone();
|
||||
ctrlc::set_handler(move || stop.store(false, Ordering::SeqCst))?;
|
||||
while running.load(Ordering::SeqCst) {
|
||||
let config = AtlasPublisherRunConfig {
|
||||
repository: AtlasRepositoryIdentity::new(
|
||||
required(&args, "--swarm-id")?,
|
||||
required(&args, "--workspace-id")?,
|
||||
)?,
|
||||
runtime_id: required(&args, "--runtime-id")?.into(),
|
||||
runtime_incarnation_id: required(&args, "--runtime-incarnation-id")?.into(),
|
||||
runtime_mind_store: path(&args, "--mind-store")?,
|
||||
local_verse_store: path(&args, "--verse-store")?,
|
||||
publisher_store: path(&args, "--publisher-store")?,
|
||||
publisher_cultmesh_store: path(&args, "--cultmesh-store")?,
|
||||
identity_store: path(&args, "--identity-store")?,
|
||||
trust_anchor_store: path(&args, "--trust-anchor-store")?,
|
||||
odin_endpoint: required(&args, "--odin-endpoint")?.parse()?,
|
||||
now_unix_ms: now_unix_ms()?,
|
||||
};
|
||||
match run_atlas_publisher_once(&config)? {
|
||||
AtlasPublisherRunOutcome::HeldByBrake { brake_id } => {
|
||||
println!("atlas publisher held by brake {brake_id}")
|
||||
}
|
||||
AtlasPublisherRunOutcome::Published {
|
||||
new_publications,
|
||||
transported_publications,
|
||||
} => println!(
|
||||
"atlas publisher committed {new_publications} new records and transported {transported_publications} immutable records"
|
||||
),
|
||||
}
|
||||
if once {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(ATLAS_PUBLISHER_HEARTBEAT_INTERVAL_MS));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn arguments() -> Result<(BTreeMap<String, String>, BTreeSet<String>)> {
|
||||
let mut values = BTreeMap::new();
|
||||
let mut switches = BTreeSet::new();
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(name) = args.next() {
|
||||
if name == "--once" {
|
||||
switches.insert(name);
|
||||
continue;
|
||||
}
|
||||
if !name.starts_with("--") {
|
||||
bail!("unexpected Atlas publisher argument {name}")
|
||||
}
|
||||
values.insert(
|
||||
name.clone(),
|
||||
args.next()
|
||||
.ok_or_else(|| anyhow::anyhow!("{name} requires a value"))?,
|
||||
);
|
||||
}
|
||||
Ok((values, switches))
|
||||
}
|
||||
|
||||
fn required<'a>(args: &'a BTreeMap<String, String>, name: &str) -> Result<&'a str> {
|
||||
args.get(name)
|
||||
.map(String::as_str)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing required {name}"))
|
||||
}
|
||||
|
||||
fn path(args: &BTreeMap<String, String>, name: &str) -> Result<PathBuf> {
|
||||
Ok(PathBuf::from(required(args, name)?))
|
||||
}
|
||||
|
||||
fn now_unix_ms() -> Result<u64> {
|
||||
Ok(SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)?
|
||||
.as_millis()
|
||||
.try_into()?)
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use epiphany_core::{
|
||||
AtlasProjectorRunConfig, AtlasProjectorRunOutcome, AtlasRepositoryIdentity,
|
||||
AtlasStoreWriteOutcome, pin_atlas_publisher_trust_anchor, run_atlas_projector_once,
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let (args, switches, command) = arguments()?;
|
||||
let projector = AtlasRepositoryIdentity::new(
|
||||
required(&args, "--swarm-id")?,
|
||||
required(&args, "--workspace-id")?,
|
||||
)?;
|
||||
if command == "pin-trust" {
|
||||
let publisher = AtlasRepositoryIdentity::new(
|
||||
required(&args, "--publisher-swarm-id")?,
|
||||
required(&args, "--publisher-workspace-id")?,
|
||||
)?;
|
||||
let expected_revision = args
|
||||
.get("--expected-revision")
|
||||
.map(|value| value.parse())
|
||||
.transpose()?;
|
||||
let outcome = pin_atlas_publisher_trust_anchor(
|
||||
&path(&args, "--projector-store")?,
|
||||
projector,
|
||||
publisher,
|
||||
&path(&args, "--trust-anchor")?,
|
||||
expected_revision,
|
||||
now_unix_ms()?,
|
||||
)?;
|
||||
if outcome == AtlasStoreWriteOutcome::Conflict {
|
||||
bail!("Atlas trust pin CAS conflicted")
|
||||
}
|
||||
println!("Atlas publisher trust pin admitted: {outcome:?}");
|
||||
return Ok(());
|
||||
}
|
||||
if command != "run" {
|
||||
bail!("Atlas projector command must be `run` or `pin-trust`")
|
||||
}
|
||||
let once = switches.contains("--once");
|
||||
let running = Arc::new(AtomicBool::new(true));
|
||||
let stop = running.clone();
|
||||
ctrlc::set_handler(move || stop.store(false, Ordering::SeqCst))?;
|
||||
while running.load(Ordering::SeqCst) {
|
||||
let config = AtlasProjectorRunConfig {
|
||||
projector_repository: projector.clone(),
|
||||
runtime_id: required(&args, "--runtime-id")?.into(),
|
||||
local_verse_store: path(&args, "--verse-store")?,
|
||||
projector_store: path(&args, "--projector-store")?,
|
||||
projector_cultmesh_store: path(&args, "--cultmesh-store")?,
|
||||
odin_endpoint: required(&args, "--odin-endpoint")?.parse()?,
|
||||
now_unix_ms: now_unix_ms()?,
|
||||
};
|
||||
match run_atlas_projector_once(&config)? {
|
||||
AtlasProjectorRunOutcome::HeldByBrake {
|
||||
brake_id,
|
||||
last_projection,
|
||||
} => println!(
|
||||
"atlas projector held by brake {brake_id}; last projection remains read-only: {}",
|
||||
last_projection.is_some()
|
||||
),
|
||||
AtlasProjectorRunOutcome::Projected {
|
||||
projection,
|
||||
accepted_publications,
|
||||
rejected_publications,
|
||||
} => println!(
|
||||
"atlas projector {} accepted {accepted_publications}, rejected {rejected_publications}, derived {} edges and {} cycles",
|
||||
projection.projection_sha256,
|
||||
projection.entanglements.len(),
|
||||
projection.cycles.len()
|
||||
),
|
||||
}
|
||||
if once {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn arguments() -> Result<(BTreeMap<String, String>, BTreeSet<String>, String)> {
|
||||
let mut raw = std::env::args().skip(1);
|
||||
let command = raw.next().unwrap_or_else(|| "run".into());
|
||||
let mut values = BTreeMap::new();
|
||||
let mut switches = BTreeSet::new();
|
||||
while let Some(name) = raw.next() {
|
||||
if name == "--once" {
|
||||
switches.insert(name);
|
||||
continue;
|
||||
}
|
||||
if !name.starts_with("--") {
|
||||
bail!("unexpected Atlas projector argument {name}")
|
||||
}
|
||||
values.insert(
|
||||
name.clone(),
|
||||
raw.next()
|
||||
.ok_or_else(|| anyhow::anyhow!("{name} requires a value"))?,
|
||||
);
|
||||
}
|
||||
Ok((values, switches, command))
|
||||
}
|
||||
|
||||
fn required<'a>(args: &'a BTreeMap<String, String>, name: &str) -> Result<&'a str> {
|
||||
args.get(name)
|
||||
.map(String::as_str)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing required {name}"))
|
||||
}
|
||||
fn path(args: &BTreeMap<String, String>, name: &str) -> Result<PathBuf> {
|
||||
Ok(PathBuf::from(required(args, name)?))
|
||||
}
|
||||
fn now_unix_ms() -> Result<u64> {
|
||||
Ok(SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)?
|
||||
.as_millis()
|
||||
.try_into()?)
|
||||
}
|
||||
Reference in a new issue