diff --git a/src/mito2/src/engine.rs b/src/mito2/src/engine.rs index 011cf4136c..0bc0b64a51 100644 --- a/src/mito2/src/engine.rs +++ b/src/mito2/src/engine.rs @@ -80,7 +80,6 @@ use snafu::{ensure, OptionExt, ResultExt}; use store_api::codec::PrimaryKeyEncoding; use store_api::logstore::provider::Provider; use store_api::logstore::LogStore; -use store_api::manifest::ManifestVersion; use store_api::metadata::RegionMetadataRef; use store_api::metric_engine_consts::MANIFEST_INFO_EXTENSION_KEY; use store_api::region_engine::{ @@ -89,6 +88,7 @@ use store_api::region_engine::{ }; use store_api::region_request::{AffectedRows, RegionOpenRequest, RegionRequest}; use store_api::storage::{RegionId, ScanRequest, SequenceNumber}; +use store_api::ManifestVersion; use tokio::sync::{oneshot, Semaphore}; use crate::cache::CacheStrategy; diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 7915ee09d6..b1ae251753 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -28,8 +28,8 @@ use object_store::ErrorKind; use prost::DecodeError; use snafu::{Location, Snafu}; use store_api::logstore::provider::Provider; -use store_api::manifest::ManifestVersion; use store_api::storage::RegionId; +use store_api::ManifestVersion; use tokio::time::error::Elapsed; use crate::cache::file_cache::FileType; diff --git a/src/mito2/src/manifest/action.rs b/src/mito2/src/manifest/action.rs index 29b18ad554..ec28b88d14 100644 --- a/src/mito2/src/manifest/action.rs +++ b/src/mito2/src/manifest/action.rs @@ -19,9 +19,9 @@ use std::time::Duration; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt}; -use store_api::manifest::ManifestVersion; use store_api::metadata::RegionMetadataRef; use store_api::storage::{RegionId, SequenceNumber}; +use store_api::ManifestVersion; use strum::Display; use crate::error::{RegionMetadataNotFoundSnafu, Result, SerdeJsonSnafu, Utf8Snafu}; diff --git a/src/mito2/src/manifest/checkpointer.rs b/src/mito2/src/manifest/checkpointer.rs index c9ca65bfdd..f0c2b196b5 100644 --- a/src/mito2/src/manifest/checkpointer.rs +++ b/src/mito2/src/manifest/checkpointer.rs @@ -17,8 +17,8 @@ use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::Arc; use common_telemetry::{error, info}; -use store_api::manifest::{ManifestVersion, MIN_VERSION}; use store_api::storage::RegionId; +use store_api::{ManifestVersion, MIN_VERSION}; use crate::manifest::action::{RegionCheckpoint, RegionManifest}; use crate::manifest::manager::RegionManifestOptions; diff --git a/src/mito2/src/manifest/manager.rs b/src/mito2/src/manifest/manager.rs index 2590d7ae6c..d237bdbc70 100644 --- a/src/mito2/src/manifest/manager.rs +++ b/src/mito2/src/manifest/manager.rs @@ -20,8 +20,8 @@ use common_telemetry::{debug, info}; use futures::TryStreamExt; use object_store::ObjectStore; use snafu::{ensure, OptionExt, ResultExt}; -use store_api::manifest::{ManifestVersion, MAX_VERSION, MIN_VERSION}; use store_api::metadata::RegionMetadataRef; +use store_api::{ManifestVersion, MAX_VERSION, MIN_VERSION}; use crate::error::{ self, InstallManifestToSnafu, NoCheckpointSnafu, NoManifestsSnafu, RegionStoppedSnafu, Result, diff --git a/src/mito2/src/manifest/storage.rs b/src/mito2/src/manifest/storage.rs index 89e23e2cd4..7394f03ed7 100644 --- a/src/mito2/src/manifest/storage.rs +++ b/src/mito2/src/manifest/storage.rs @@ -28,8 +28,8 @@ use object_store::{util, Entry, ErrorKind, Lister, ObjectStore}; use regex::Regex; use serde::{Deserialize, Serialize}; use snafu::{ensure, ResultExt}; -use store_api::manifest::ManifestVersion; use store_api::storage::RegionId; +use store_api::ManifestVersion; use tokio::sync::Semaphore; use crate::error::{ diff --git a/src/mito2/src/region.rs b/src/mito2/src/region.rs index 08863b3b2f..ef3aacb6b0 100644 --- a/src/mito2/src/region.rs +++ b/src/mito2/src/region.rs @@ -28,12 +28,12 @@ use crossbeam_utils::atomic::AtomicCell; use snafu::{ensure, OptionExt}; use store_api::codec::PrimaryKeyEncoding; use store_api::logstore::provider::Provider; -use store_api::manifest::ManifestVersion; use store_api::metadata::RegionMetadataRef; use store_api::region_engine::{ RegionManifestInfo, RegionRole, RegionStatistic, SettableRegionRoleState, }; use store_api::storage::{RegionId, SequenceNumber}; +use store_api::ManifestVersion; use crate::access_layer::AccessLayerRef; use crate::error::{ diff --git a/src/mito2/src/request.rs b/src/mito2/src/request.rs index de86d32a37..2332ea1232 100644 --- a/src/mito2/src/request.rs +++ b/src/mito2/src/request.rs @@ -31,7 +31,6 @@ use prost::Message; use smallvec::SmallVec; use snafu::{ensure, OptionExt, ResultExt}; use store_api::codec::{infer_primary_key_encoding_from_hint, PrimaryKeyEncoding}; -use store_api::manifest::ManifestVersion; use store_api::metadata::{ColumnMetadata, RegionMetadata, RegionMetadataRef}; use store_api::region_engine::{SetRegionRoleStateResponse, SettableRegionRoleState}; use store_api::region_request::{ @@ -40,6 +39,7 @@ use store_api::region_request::{ RegionOpenRequest, RegionRequest, RegionTruncateRequest, }; use store_api::storage::{RegionId, SequenceNumber}; +use store_api::ManifestVersion; use tokio::sync::oneshot::{self, Receiver, Sender}; use crate::error::{ diff --git a/src/store-api/src/lib.rs b/src/store-api/src/lib.rs index 09e8634e43..0552c3c244 100644 --- a/src/store-api/src/lib.rs +++ b/src/store-api/src/lib.rs @@ -20,7 +20,6 @@ pub mod codec; pub mod data_source; pub mod logstore; -pub mod manifest; pub mod metadata; pub mod metric_engine_consts; mod metrics; @@ -29,3 +28,7 @@ pub mod path_utils; pub mod region_engine; pub mod region_request; pub mod storage; + +pub type ManifestVersion = u64; +pub const MIN_VERSION: u64 = 0; +pub const MAX_VERSION: u64 = u64::MAX; diff --git a/src/store-api/src/manifest.rs b/src/store-api/src/manifest.rs deleted file mode 100644 index 985339c694..0000000000 --- a/src/store-api/src/manifest.rs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2023 Greptime Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! metadata service -pub mod action; -mod storage; - -use async_trait::async_trait; -use common_error::ext::ErrorExt; -use serde::de::DeserializeOwned; -use serde::Serialize; - -use crate::manifest::action::{ProtocolAction, ProtocolVersion}; -pub use crate::manifest::storage::*; - -pub type ManifestVersion = u64; -pub const MIN_VERSION: u64 = 0; -pub const MAX_VERSION: u64 = u64::MAX; - -/// The action to alter metadata -pub trait MetaAction: Serialize + DeserializeOwned + Send + Sync + Clone + std::fmt::Debug { - type Error: ErrorExt + Send + Sync; - - /// Set a protocol action into meta action - fn set_protocol(&mut self, action: ProtocolAction); - - /// Set previous valid manifest version. - fn set_prev_version(&mut self, version: ManifestVersion); - - /// Encode this action into a byte vector - fn encode(&self) -> Result, Self::Error>; - - /// Decode self from byte slice with reader protocol version, - /// return error when reader version is not supported. - fn decode( - bs: &[u8], - reader_version: ProtocolVersion, - ) -> Result<(Self, Option), Self::Error>; -} -/// The checkpoint by checkpoint -pub trait Checkpoint: Send + Sync + Clone + std::fmt::Debug { - type Error: ErrorExt + Send + Sync; - - /// Set a protocol action into checkpoint - fn set_protocol(&mut self, action: ProtocolAction); - - /// The last compacted action's version of checkpoint - fn last_version(&self) -> ManifestVersion; - - /// Encode this checkpoint into a byte vector - fn encode(&self) -> Result, Self::Error>; - - /// Decode self from byte slice with reader protocol version, - /// return error when reader version is not supported. - fn decode(bs: &[u8], reader_version: ProtocolVersion) -> Result; -} - -#[async_trait] -pub trait MetaActionIterator { - type MetaAction: MetaAction; - type Error: ErrorExt + Send + Sync; - - async fn next_action( - &mut self, - ) -> Result, Self::Error>; -} - -/// Manifest service -#[async_trait] -pub trait Manifest: Send + Sync + Clone + 'static { - type Error: ErrorExt + Send + Sync; - type MetaAction: MetaAction; - type MetaActionIterator: MetaActionIterator; - type Checkpoint: Checkpoint; - - /// Update metadata by the action - async fn update(&self, action: Self::MetaAction) -> Result; - - /// Scan actions which version in range [start, end) - async fn scan( - &self, - start: ManifestVersion, - end: ManifestVersion, - ) -> Result; - - /// Do a checkpoint, it will create a checkpoint and compact actions. - async fn do_checkpoint(&self) -> Result, Self::Error>; - - /// Returns the last success checkpoint - async fn last_checkpoint(&self) -> Result, Self::Error>; - - /// Returns the last(or latest) manifest version. - fn last_version(&self) -> ManifestVersion; - - /// Start the service - async fn start(&self) -> Result<(), Self::Error> { - Ok(()) - } - /// Stop the service - async fn stop(&self) -> Result<(), Self::Error> { - Ok(()) - } -}