mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-06-02 13:20:40 +00:00
refactor: remove staled manifest structures (#6382)
* refactor: remove staled manifest structures Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * Update src/store-api/src/lib.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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::{
|
||||
|
||||
@@ -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::{
|
||||
|
||||
@@ -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::{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Vec<u8>, 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<ProtocolAction>), 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<Vec<u8>, 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, Self::Error>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait MetaActionIterator {
|
||||
type MetaAction: MetaAction;
|
||||
type Error: ErrorExt + Send + Sync;
|
||||
|
||||
async fn next_action(
|
||||
&mut self,
|
||||
) -> Result<Option<(ManifestVersion, Self::MetaAction)>, Self::Error>;
|
||||
}
|
||||
|
||||
/// Manifest service
|
||||
#[async_trait]
|
||||
pub trait Manifest: Send + Sync + Clone + 'static {
|
||||
type Error: ErrorExt + Send + Sync;
|
||||
type MetaAction: MetaAction;
|
||||
type MetaActionIterator: MetaActionIterator<Error = Self::Error, MetaAction = Self::MetaAction>;
|
||||
type Checkpoint: Checkpoint;
|
||||
|
||||
/// Update metadata by the action
|
||||
async fn update(&self, action: Self::MetaAction) -> Result<ManifestVersion, Self::Error>;
|
||||
|
||||
/// Scan actions which version in range [start, end)
|
||||
async fn scan(
|
||||
&self,
|
||||
start: ManifestVersion,
|
||||
end: ManifestVersion,
|
||||
) -> Result<Self::MetaActionIterator, Self::Error>;
|
||||
|
||||
/// Do a checkpoint, it will create a checkpoint and compact actions.
|
||||
async fn do_checkpoint(&self) -> Result<Option<Self::Checkpoint>, Self::Error>;
|
||||
|
||||
/// Returns the last success checkpoint
|
||||
async fn last_checkpoint(&self) -> Result<Option<Self::Checkpoint>, 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(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user