-
Notifications
You must be signed in to change notification settings - Fork 419
feat: introduce the Noop WAL provider for datanode #7105
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ | |
pub mod error; | ||
pub mod kafka; | ||
pub mod metrics; | ||
pub mod noop; | ||
pub mod raft_engine; | ||
pub mod test_util; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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. | ||
|
||
pub mod log_store; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// 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. | ||
|
||
use std::collections::HashMap; | ||
|
||
use futures::stream; | ||
use store_api::logstore::entry::{Entry, NaiveEntry}; | ||
use store_api::logstore::provider::Provider; | ||
use store_api::logstore::{AppendBatchResponse, EntryId, LogStore, SendableEntryStream, WalIndex}; | ||
use store_api::storage::RegionId; | ||
|
||
use crate::error::{Error, Result}; | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct NoopLogStore; | ||
|
||
#[async_trait::async_trait] | ||
impl LogStore for NoopLogStore { | ||
type Error = Error; | ||
|
||
async fn stop(&self) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn append_batch(&self, entries: Vec<Entry>) -> Result<AppendBatchResponse> { | ||
let last_entry_ids = entries | ||
.iter() | ||
.map(|entry| (entry.region_id(), 0)) | ||
.collect::<HashMap<RegionId, EntryId>>(); | ||
Ok(AppendBatchResponse { last_entry_ids }) | ||
} | ||
|
||
async fn read( | ||
&self, | ||
_provider: &Provider, | ||
_entry_id: EntryId, | ||
_index: Option<WalIndex>, | ||
) -> Result<SendableEntryStream<'static, Entry, Self::Error>> { | ||
Ok(Box::pin(stream::empty())) | ||
} | ||
|
||
async fn create_namespace(&self, _ns: &Provider) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn delete_namespace(&self, _ns: &Provider) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn list_namespaces(&self) -> Result<Vec<Provider>> { | ||
Ok(vec![]) | ||
} | ||
|
||
fn entry( | ||
&self, | ||
data: Vec<u8>, | ||
entry_id: EntryId, | ||
region_id: RegionId, | ||
provider: &Provider, | ||
) -> Result<Entry> { | ||
Ok(Entry::Naive(NaiveEntry { | ||
provider: provider.clone(), | ||
region_id, | ||
entry_id, | ||
data, | ||
})) | ||
} | ||
|
||
async fn obsolete( | ||
&self, | ||
_provider: &Provider, | ||
_region_id: RegionId, | ||
_entry_id: EntryId, | ||
) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
fn latest_entry_id(&self, _provider: &Provider) -> Result<EntryId> { | ||
Ok(0) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[tokio::test] | ||
async fn test_append_batch() { | ||
let log_store = NoopLogStore; | ||
let entries = vec![Entry::Naive(NaiveEntry { | ||
provider: Provider::noop_provider(), | ||
region_id: RegionId::new(1, 1), | ||
entry_id: 1, | ||
data: vec![1], | ||
})]; | ||
|
||
let last_entry_ids = log_store | ||
.append_batch(entries) | ||
.await | ||
.unwrap() | ||
.last_entry_ids; | ||
assert_eq!(last_entry_ids.len(), 1); | ||
assert_eq!(last_entry_ids[&(RegionId::new(1, 1))], 0); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.