瀏覽代碼

Remove Component from error logging.

Jing Yang 4 年之前
父節點
當前提交
578a607a6c
共有 2 個文件被更改,包括 2 次插入24 次删除
  1. 1 22
      src/daemon_env.rs
  2. 1 2
      src/lib.rs

+ 1 - 22
src/daemon_env.rs

@@ -8,10 +8,9 @@ use crate::{Peer, RaftState, State, Term};
 
 #[macro_export]
 macro_rules! check_or_record {
-    ($daemon_env:expr, $condition:expr, $component:expr, $error_kind:expr, $message:expr, $rf:expr) => {
+    ($daemon_env:expr, $condition:expr, $error_kind:expr, $message:expr, $rf:expr) => {
         if !$condition {
             $daemon_env.record_error(
-                $component,
                 $error_kind,
                 $message,
                 $rf,
@@ -35,7 +34,6 @@ struct DaemonEnvData<T> {
 
 #[derive(Debug)]
 pub(crate) struct Error {
-    component: Component,
     error_kind: ErrorKind,
     message: String,
     raft_state: StrippedRaftState,
@@ -47,34 +45,15 @@ pub(crate) enum ErrorKind {
     RollbackCommitted(usize),
 }
 
-#[allow(dead_code)]
-#[derive(Debug)]
-pub(crate) enum Component {
-    // Daemon threads.
-    Election,
-    SyncLogEntry,
-    ApplyCommand,
-    Snapshot,
-    // Daemon tasks
-    VoteCountingTask,
-    SyncLogEntryTask,
-    // RPC handlers
-    InstallSnapshot,
-    AppendEntries,
-    RequestVote,
-}
-
 impl<T> DaemonEnv<T> {
     pub fn record_error<S: AsRef<str>>(
         &self,
-        component: Component,
         error_kind: ErrorKind,
         message: S,
         raft_state: &RaftState<T>,
         file_line: &'static str,
     ) {
         self.data.lock().errors.push(Error {
-            component,
             error_kind,
             message: message.as_ref().into(),
             raft_state: Self::strip_data(raft_state),

+ 1 - 2
src/lib.rs

@@ -18,7 +18,7 @@ use rand::{thread_rng, Rng};
 
 use crate::apply_command::ApplyCommandFnMut;
 pub use crate::apply_command::ApplyCommandMessage;
-use crate::daemon_env::{Component, DaemonEnv, ErrorKind};
+use crate::daemon_env::{DaemonEnv, ErrorKind};
 use crate::index_term::IndexTerm;
 use crate::install_snapshot::InstallSnapshotArgs;
 use crate::persister::PersistedRaftState;
@@ -315,7 +315,6 @@ where
                     check_or_record!(
                         self.daemon_env,
                         index > rf.commit_index,
-                        Component::AppendEntries,
                         ErrorKind::RollbackCommitted(index),
                         "Entries before commit index should never be rolled back",
                         &rf