Skip to content
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

refactor: remove read state #857

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/curp-external-api/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ where
async fn reset(&self, snapshot: Option<(Snapshot, LogIndex)>) -> Result<(), C::Error>;

/// Trigger the barrier of the given trigger id (based on propose id) and log index.
fn trigger(&self, id: InflightId, index: LogIndex);
fn trigger(&self, id: InflightId);
}

/// Codec for encoding and decoding data into/from the Protobuf format
Expand Down
2 changes: 1 addition & 1 deletion crates/curp-test-utils/src/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl CommandExecutor<TestCommand> for TestCE {
Ok(())
}

fn trigger(&self, _id: InflightId, _index: LogIndex) {}
fn trigger(&self, _id: InflightId) {}
}

impl TestCE {
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/server/cmd_worker/conflict_checked_mpmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl<C: Command, CE: CommandExecutor<C>> Filter<C, CE> {
None
}
Err(err) => {
self.cmd_executor.trigger(entry.inflight_id(), entry.index);
self.cmd_executor.trigger(entry.inflight_id());
Some(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/curp/src/server/cmd_worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async fn worker_exe<C: Command, CE: CommandExecutor<C>, RC: RoleChange>(
| EntryData::SetNodeState(_, _, _) => true,
};
if !success {
ce.trigger(entry.inflight_id(), entry.index);
ce.trigger(entry.inflight_id());
}
success
}
Expand Down Expand Up @@ -240,7 +240,7 @@ async fn worker_as<C: Command, CE: CommandExecutor<C>, RC: RoleChange>(
}
EntryData::Empty => true,
};
ce.trigger(entry.inflight_id(), entry.index);
ce.trigger(entry.inflight_id());
success
}

Expand Down
113 changes: 0 additions & 113 deletions crates/xline/src/server/barriers.rs

This file was deleted.

12 changes: 3 additions & 9 deletions crates/xline/src/server/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use xlineapi::{
AlarmAction, AlarmRequest, AlarmType,
};

use super::barriers::IndexBarrier;
use crate::{
revision_number::RevisionNumberGenerator,
rpc::{RequestBackend, RequestWrapper},
Expand Down Expand Up @@ -73,8 +72,6 @@ pub(crate) struct CommandExecutor {
alarm_storage: Arc<AlarmStore>,
/// persistent storage
db: Arc<DB>,
/// Barrier for applied index
index_barrier: Arc<IndexBarrier>,
/// Barrier for propose id
id_barrier: Arc<IdBarrier<InflightId>>,
/// Revision Number generator for KV request and Lease request
Expand Down Expand Up @@ -225,7 +222,6 @@ impl CommandExecutor {
lease_storage: Arc<LeaseStore>,
alarm_storage: Arc<AlarmStore>,
db: Arc<DB>,
index_barrier: Arc<IndexBarrier>,
id_barrier: Arc<IdBarrier<InflightId>>,
general_rev: Arc<RevisionNumberGenerator>,
auth_rev: Arc<RevisionNumberGenerator>,
Expand All @@ -240,7 +236,6 @@ impl CommandExecutor {
lease_storage,
alarm_storage,
db,
index_barrier,
id_barrier,
general_rev,
auth_rev,
Expand Down Expand Up @@ -293,14 +288,14 @@ impl CurpCommandExecutor<Command> for CommandExecutor {
let revision = match wrapper.backend() {
RequestBackend::Auth => {
if wrapper.skip_auth_revision() {
-1
self.auth_rev.get()
} else {
self.auth_rev.next()
}
}
RequestBackend::Kv | RequestBackend::Lease => {
if wrapper.skip_general_revision() {
-1
self.general_rev.get()
} else {
self.general_rev.next()
}
Expand Down Expand Up @@ -406,9 +401,8 @@ impl CurpCommandExecutor<Command> for CommandExecutor {
Ok(u64::from_le_bytes(buf))
}

fn trigger(&self, id: InflightId, index: LogIndex) {
fn trigger(&self, id: InflightId) {
self.id_barrier.trigger(&id);
self.index_barrier.trigger(index);
}
}

Expand Down
Loading
Loading