-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from doyoubi/MigrationStats
Add migration stats
- Loading branch information
Showing
9 changed files
with
238 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod manager; | ||
pub mod scan_migration; | ||
mod scan_task; | ||
pub mod stats; | ||
pub mod task; | ||
|
||
pub use self::scan_task::MAX_REDIRECTIONS; |
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,54 @@ | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
|
||
macro_rules! atomic_usize_stats { | ||
(pub struct $struct_name:ident { | ||
$(pub $field_name:ident: AtomicUsize,)* | ||
}) => { | ||
pub struct $struct_name { | ||
$(pub $field_name: AtomicUsize,)* | ||
} | ||
|
||
impl Default for $struct_name { | ||
fn default() -> Self { | ||
Self { | ||
$($field_name: AtomicUsize::new(0),)* | ||
} | ||
} | ||
} | ||
|
||
impl $struct_name { | ||
pub fn to_lines_str(&self) -> Vec<(String, usize)> { | ||
vec![ | ||
$((stringify!($field_name).to_string(), self.$field_name.load(Ordering::Relaxed))),* | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
atomic_usize_stats! { | ||
pub struct MigrationStats { | ||
pub migrating_src_redis_conn: AtomicUsize, | ||
pub migrating_dst_redis_conn: AtomicUsize, | ||
pub migrating_active_sync_lock_success: AtomicUsize, | ||
pub migrating_active_sync_lock_failed: AtomicUsize, | ||
pub migrating_scan_lock_success: AtomicUsize, | ||
pub migrating_scan_lock_failed: AtomicUsize, | ||
pub importing_blocking_migration_commands: AtomicUsize, | ||
pub importing_non_blocking_migration_commands: AtomicUsize, | ||
pub importing_umsync_lock_success: AtomicUsize, | ||
pub importing_umsync_lock_failed: AtomicUsize, | ||
pub importing_umsync_lock_failed_again: AtomicUsize, | ||
pub importing_umsync_failed: AtomicUsize, | ||
pub importing_dst_key_existed: AtomicUsize, | ||
pub importing_dst_key_not_existed: AtomicUsize, | ||
pub importing_lock_success: AtomicUsize, | ||
pub importing_lock_failed: AtomicUsize, | ||
pub importing_resend_exists: AtomicUsize, | ||
pub importing_resend_exists_failed: AtomicUsize, | ||
pub importing_lock_loop_retry: AtomicUsize, | ||
pub importing_src_key_existed: AtomicUsize, | ||
pub importing_src_key_not_existed: AtomicUsize, | ||
pub importing_src_failed: AtomicUsize, | ||
} | ||
} |
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
Oops, something went wrong.