-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,049 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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,19 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] | ||
pub struct IndexDBTailerConfig { | ||
pub enable: bool, | ||
pub batch_size: usize, | ||
} | ||
|
||
impl Default for IndexDBTailerConfig { | ||
fn default() -> Self { | ||
Self { | ||
enable: false, | ||
batch_size: 10_000, | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
pub mod backup_restore; | ||
pub mod runtime; | ||
pub mod table_info_service; | ||
pub mod tailer_service; |
This file contains 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 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
64 changes: 64 additions & 0 deletions
64
ecosystem/indexer-grpc/indexer-grpc-table-info/src/tailer_service.rs
This file contains 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,64 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use aptos_config::config::NodeConfig; | ||
use aptos_db_indexer::{db_ops::open_db, db_tailer::DBTailer}; | ||
use aptos_indexer_grpc_utils::counters::{log_grpc_step, IndexerGrpcStep}; | ||
use aptos_storage_interface::DbReader; | ||
use std::sync::Arc; | ||
|
||
const SERVICE_TYPE: &str = "db_tailer_service"; | ||
const INDEX_ASYNC_DB_TAILER: &str = "index_async_db_tailer"; | ||
|
||
pub struct TailerService { | ||
pub db_tailer: Arc<DBTailer>, | ||
} | ||
|
||
impl TailerService { | ||
pub fn new(db_reader: Arc<dyn DbReader>, node_config: &NodeConfig) -> Self { | ||
let db_path = node_config | ||
.storage | ||
.get_dir_paths() | ||
.default_root_path() | ||
.join(INDEX_ASYNC_DB_TAILER); | ||
let rocksdb_config = node_config.storage.rocksdb_configs.index_db_config; | ||
let db = Arc::new( | ||
open_db(db_path, &rocksdb_config) | ||
.expect("Failed to open up indexer db tailer initially"), | ||
); | ||
|
||
let indexer_db_tailer = | ||
Arc::new(DBTailer::new(db, db_reader, &node_config.index_db_tailer)); | ||
Self { | ||
db_tailer: indexer_db_tailer, | ||
} | ||
} | ||
|
||
pub fn get_db_tailer(&self) -> Arc<DBTailer> { | ||
Arc::clone(&self.db_tailer) | ||
} | ||
|
||
pub async fn run(&mut self) { | ||
let mut start_version = self.db_tailer.get_last_version(); | ||
loop { | ||
let start_time: std::time::Instant = std::time::Instant::now(); | ||
let cur_version = self | ||
.db_tailer | ||
.process_a_batch(Some(start_version)) | ||
.expect("Failed to run indexer db tailer"); | ||
start_version = cur_version; | ||
log_grpc_step( | ||
SERVICE_TYPE, | ||
IndexerGrpcStep::DBTailerProcessed, | ||
None, | ||
None, | ||
None, | ||
None, | ||
Some(start_time.elapsed().as_secs_f64()), | ||
None, | ||
Some(cur_version as i64), | ||
None, | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.