-
Notifications
You must be signed in to change notification settings - Fork 92
feat(compression-coordinator): Complete S3 compression job handle implementation. #2420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
b07a473
47d677b
0ef11ac
8a6be0a
1a2a2ec
107d3cb
75f236c
72e8c5a
abf8912
93aee60
b2cee3a
8ca1e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| use serde::Deserialize; | ||
|
|
||
| use crate::clp_config::{AwsAuthentication, S3Config}; | ||
| use crate::{ | ||
| clp_config::{AwsAuthentication, S3Config}, | ||
| dataset::resolve_dataset_name, | ||
| }; | ||
|
|
||
| /// Mirror of `clp_py_utils.clp_config.ClpConfig`. | ||
| /// | ||
|
|
@@ -89,14 +92,54 @@ pub struct Database { | |
| pub host: String, | ||
| pub port: u16, | ||
| pub names: ClpDbNames, | ||
|
|
||
| #[serde(skip)] | ||
| pub table_prefix: String, | ||
| } | ||
|
|
||
| impl Database { | ||
| /// # Returns | ||
| /// | ||
| /// The archives table name `<prefix><dataset>_archives`, where a `None` dataset resolves to | ||
| /// `default`. | ||
| #[must_use] | ||
| pub fn archives_table_name(&self, dataset: Option<&str>) -> String { | ||
| self.archive_metadata_table_name("archives", dataset) | ||
| } | ||
|
|
||
| /// # Returns | ||
| /// | ||
| /// The column-metadata table name `<prefix><dataset>_column_metadata`, where a `None` dataset | ||
| /// resolves to `default`. | ||
| #[must_use] | ||
| pub fn column_metadata_table_name(&self, dataset: Option<&str>) -> String { | ||
| self.archive_metadata_table_name("column_metadata", dataset) | ||
| } | ||
|
|
||
| /// Builds a per-dataset archive-metadata table name. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// `<prefix><dataset>_<suffix>`, where `dataset` defaults to the `CLP_S` default. | ||
| fn archive_metadata_table_name(&self, suffix: &str, dataset: Option<&str>) -> String { | ||
| format!( | ||
| "{}{}_{suffix}", | ||
| self.table_prefix, | ||
| resolve_dataset_name(dataset) | ||
| ) | ||
| } | ||
| } | ||
|
LinZhihao-723 marked this conversation as resolved.
|
||
|
|
||
| impl Default for Database { | ||
| fn default() -> Self { | ||
| /// Mirror of `clp_py_utils.clp_config.CLP_METADATA_TABLE_PREFIX`. | ||
| const CLP_METADATA_TABLE_PREFIX: &str = "clp_"; | ||
|
|
||
| Self { | ||
| host: "localhost".to_owned(), | ||
| port: 3306, | ||
| names: ClpDbNames::default(), | ||
| table_prefix: CLP_METADATA_TABLE_PREFIX.to_owned(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in #2406. |
||
| } | ||
| } | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in #2406. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,46 @@ | ||
| //! The crate-level error type for the compression coordinator. | ||
|
|
||
| use clp_rust_utils::{job_config::ingestion::JobId as IngestionJobId, s3::S3ObjectMetadataId}; | ||
|
|
||
| /// Errors returned by the compression coordinator. | ||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum Error { | ||
| #[error( | ||
| "duplicate S3 object metadata IDs {ids:?} requested for ingestion job {ingestion_job_id}" | ||
| )] | ||
| DuplicateS3ObjectMetadata { | ||
| ingestion_job_id: IngestionJobId, | ||
| ids: Vec<S3ObjectMetadataId>, | ||
| }, | ||
|
|
||
| #[error("S3 object metadata {id} has an empty `{field}`")] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Label |
||
| EmptyS3ObjectMetadataField { | ||
| id: S3ObjectMetadataId, | ||
| field: &'static str, | ||
| }, | ||
|
|
||
| #[error("invalid dataset: {0}")] | ||
| InvalidDataset(String), | ||
|
|
||
| #[error("failed to create metadata table `{table}`: {source}")] | ||
| MetadataTableCreation { | ||
| table: String, | ||
| #[source] | ||
| source: sqlx::Error, | ||
| }, | ||
|
|
||
| #[error("missing S3 object metadata {id} for ingestion job {ingestion_job_id}")] | ||
| MissingS3ObjectMetadata { | ||
| ingestion_job_id: IngestionJobId, | ||
| id: S3ObjectMetadataId, | ||
|
Comment on lines
+34
to
+35
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| }, | ||
|
|
||
| #[error("no S3 object metadata was requested for ingestion job {0}")] | ||
| NoS3ObjectMetadata(IngestionJobId), | ||
|
|
||
| #[error("no S3 objects were partitioned into compression task inputs")] | ||
| NoTaskInputs, | ||
|
|
||
| #[error("S3 bucket mismatch: expected `{0}`, but got `{1}`")] | ||
| S3BucketMismatch(String, String), | ||
|
|
||
|
|
@@ -26,6 +61,9 @@ pub enum Error { | |
| #[error("failed to serialize a task input: {0}")] | ||
| TaskInputSerialization(#[from] rmp_serde::encode::Error), | ||
|
|
||
| #[error("number of compression tasks {0} exceeds `i32::MAX`")] | ||
| TooManyCompressionTasks(usize), | ||
|
|
||
| #[error("unsupported input config")] | ||
| UnsupportedInputConfig, | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've splitted this to #2421.