Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ data kept by the data plane, and no query-time result kept across
evaluations. For example `{"raw_data_retained": false}` makes the Planner
build every input at ingestion time.

Collector views (docs/design/collector-sketch-ingest.md): with
`--collector-capabilities caps.json` (what the collector prints with
`asap_sketches --print-capabilities`) and `--emit-collector-views cv.json`,
the control plane also writes the part of the plan the collector runs: the views it builds instead of the data plane, the plan id, which metrics the
data plane still reads raw (the collector stops forwarding the others), and
prints why each other node is not on the collector. `--plan plan.json` reads a plan written
before instead of planning `--workload`. The data
plane started with `--collector-views cv.json` does not build those views:
their states arrive from the collector on `/v1/metrics`, in metrics named
`<metric>.asap_view.<node id>`, and each window is committed when the
request carrying its states ends; later states of a committed window merge
into it within retention (`asap_collector_states_*` on `/metrics`). It
refuses a file of another plan.

`--cost-inputs costs.json` replaces the Planner's default `CostInputs`
(Stage 3's cost model, resource speed and measured operation costs); an
omitted field keeps its default, cost model 1 with illustrative unit costs.
Expand Down
2 changes: 2 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ asap-types.workspace = true
# `FallbackClient` is used as `Arc<dyn …>`, so its async method must be
# object safe; native `async fn` in traits is not.
async-trait.workspace = true
# The collector-views file (`CollectorViewsFile`) is read and written as JSON.
serde.workspace = true
thiserror.workspace = true
30 changes: 30 additions & 0 deletions crates/common/src/collector_views_file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! The collector-views file (docs/design/collector-sketch-ingest.md, §2):
//! the part of the installed plan the collector runs, which the control
//! plane writes and both the collector and the data plane load. Here
//! because the control plane writes it and the data plane reads it.

use std::collections::BTreeMap;

use asap_types::plan::physical_asap_dag::PhysicalASAPDAG;
use serde::{Deserialize, Serialize};

use crate::PhysicalASAPNodeId;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct CollectorViewsFile {
/// `INSTALLABLE_PLAN_WIRE_VERSION` of the planner that wrote `dag`.
pub planner_wire_version: u32,
/// `PhysicalASAPDAG::plan_id()` of the installed plan.
pub plan_id: String,
/// Per metric a `Scan` of the plan reads: whether the backend still
/// reads its raw samples (a `Scan` of it feeds a node off the
/// collector, or runs at query time).
pub backend_reads_raw: BTreeMap<String, bool>,
/// The collector views: the sub-DAG's outputs whose states the backend
/// ingests.
pub outputs: Vec<PhysicalASAPNodeId>,
/// The collector sub-DAG, nodes and edges as in the installed plan;
/// `roots = outputs`.
pub dag: PhysicalASAPDAG,
}
7 changes: 5 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
//! The data plane's boundary types and the `FallbackClient` trait, with the
//! names and shapes of ASAPQuery's engine-boundary design
//! (docs/design/repo-layout.md). Adapters and engines meet here; this crate
//! holds no implementation.
//! (docs/design/repo-layout.md). Adapters and engines meet here, and the
//! control plane meets the data plane in the collector-views file it writes
//! (`CollectorViewsFile`); this crate holds no implementation.
//!
//! It names ASAPPlanner's plan types only (`InstallablePlan`, the DAG's node
//! ids, `QueryLanguage`) and no executor item.
//! `asap-planner`, which defines `InstallablePlan`, still brings the
//! executor and the frontends in at compile time.

mod collector_views_file;
mod fallback;
mod plan;
mod query_engine;
mod query_request;
mod query_result;
mod view_states;

pub use collector_views_file::CollectorViewsFile;
pub use fallback::{FallbackClient, FallbackError, FallbackResponse};
pub use plan::{InstallError, InstalledPlan, PlanId};
pub use query_engine::{AnswerSource, EngineQueryResult, QueryEngineError};
Expand Down
4 changes: 4 additions & 0 deletions crates/control-plane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ test-support = []

[dependencies]
asap-planner.workspace = true
# The plan IR the collector view rule reads (operators, predicates,
# summary inputs), which `asap-planner` does not re-export.
asap-types.workspace = true
common.workspace = true
futures = "0.3"
serde.workspace = true
serde_json.workspace = true
Expand Down
Loading