diff --git a/crates/libs/core/src/runtime/stateful.rs b/crates/libs/core/src/runtime/stateful.rs index 440380b2..d2b726c0 100644 --- a/crates/libs/core/src/runtime/stateful.rs +++ b/crates/libs/core/src/runtime/stateful.rs @@ -9,7 +9,7 @@ use mssf_com::FabricRuntime::IFabricStatefulServicePartition; use crate::sync::CancellationToken; use crate::types::{LoadMetric, LoadMetricListRef, ReplicaRole}; -use crate::types::{Epoch, OpenMode, ReplicaInformation, ReplicaSetConfig, ReplicaSetQuarumMode}; +use crate::types::{Epoch, OpenMode, ReplicaInformation, ReplicaSetConfig, ReplicaSetQuorumMode}; /// Represents a stateful service factory that is responsible for creating replicas /// of a specific type of stateful service. Stateful service factories are registered with @@ -135,7 +135,7 @@ pub trait LocalPrimaryReplicator: Replicator { ) -> crate::Result<()>; async fn wait_for_catch_up_quorum( &self, - catchupmode: ReplicaSetQuarumMode, + catchupmode: ReplicaSetQuorumMode, cancellation_token: CancellationToken, ) -> crate::Result<()>; fn update_current_replica_set_configuration( diff --git a/crates/libs/core/src/runtime/stateful_bridge.rs b/crates/libs/core/src/runtime/stateful_bridge.rs index e790c06a..4abf34bb 100644 --- a/crates/libs/core/src/runtime/stateful_bridge.rs +++ b/crates/libs/core/src/runtime/stateful_bridge.rs @@ -429,6 +429,7 @@ where catchupmode: FABRIC_REPLICA_SET_QUORUM_MODE, callback: ::core::option::Option<&super::IFabricAsyncOperationCallback>, ) -> crate::Result { + let catchupmode = catchupmode.into(); info!( "IFabricPrimaryReplicatorBridge::BeginWaitForCatchUpQuorum: mode {:?}", catchupmode @@ -436,9 +437,7 @@ where let inner = self.inner.clone(); let (ctx, token) = BridgeContext3::make(callback); ctx.spawn(&self.rt, async move { - inner - .wait_for_catch_up_quorum(catchupmode.into(), token) - .await + inner.wait_for_catch_up_quorum(catchupmode, token).await }) } @@ -488,7 +487,7 @@ where } fn RemoveReplica(&self, replicaid: i64) -> crate::Result<()> { - info!("IFabricPrimaryReplicatorBridge::RemoveReplica"); + info!("IFabricPrimaryReplicatorBridge::RemoveReplica: replicaid {replicaid}"); self.inner.remove_replica(replicaid) } } diff --git a/crates/libs/core/src/runtime/stateful_proxy.rs b/crates/libs/core/src/runtime/stateful_proxy.rs index 5ceadf19..c6a27360 100644 --- a/crates/libs/core/src/runtime/stateful_proxy.rs +++ b/crates/libs/core/src/runtime/stateful_proxy.rs @@ -24,7 +24,7 @@ use crate::{ use super::stateful::{ PrimaryReplicator, Replicator, StatefulServicePartition, StatefulServiceReplica, }; -use crate::types::{Epoch, OpenMode, ReplicaInformation, ReplicaSetConfig, ReplicaSetQuarumMode}; +use crate::types::{Epoch, OpenMode, ReplicaInformation, ReplicaSetConfig, ReplicaSetQuorumMode}; pub struct StatefulServiceReplicaProxy { com_impl: IFabricStatefulServiceReplica, @@ -259,10 +259,10 @@ impl PrimaryReplicator for PrimaryReplicatorProxy { } async fn wait_for_catch_up_quorum( &self, - catchupmode: ReplicaSetQuarumMode, + catchupmode: ReplicaSetQuorumMode, cancellation_token: CancellationToken, ) -> crate::Result<()> { - info!("PrimaryReplicatorProxy::wait_for_catch_up_quorum"); + info!("PrimaryReplicatorProxy::wait_for_catch_up_quorum: catchupmode {catchupmode:?}"); let com1 = &self.com_impl; let com2 = self.com_impl.clone(); let rx = fabric_begin_end_proxy2( diff --git a/crates/libs/core/src/types/runtime/stateful.rs b/crates/libs/core/src/types/runtime/stateful.rs index 8950bb32..6b03bb75 100644 --- a/crates/libs/core/src/types/runtime/stateful.rs +++ b/crates/libs/core/src/types/runtime/stateful.rs @@ -259,29 +259,30 @@ impl ReplicaInformation { } // FABRIC_REPLICA_SET_QUORUM_MODE -pub enum ReplicaSetQuarumMode { +#[derive(Debug, Clone, PartialEq)] +pub enum ReplicaSetQuorumMode { All, Invalid, Write, } -impl From for ReplicaSetQuarumMode { +impl From for ReplicaSetQuorumMode { fn from(r: FABRIC_REPLICA_SET_QUORUM_MODE) -> Self { match r { - FABRIC_REPLICA_SET_QUORUM_ALL => ReplicaSetQuarumMode::All, - FABRIC_REPLICA_SET_QUORUM_INVALID => ReplicaSetQuarumMode::Invalid, - FABRIC_REPLICA_SET_WRITE_QUORUM => ReplicaSetQuarumMode::Write, - _ => ReplicaSetQuarumMode::Invalid, + FABRIC_REPLICA_SET_QUORUM_ALL => ReplicaSetQuorumMode::All, + FABRIC_REPLICA_SET_QUORUM_INVALID => ReplicaSetQuorumMode::Invalid, + FABRIC_REPLICA_SET_WRITE_QUORUM => ReplicaSetQuorumMode::Write, + _ => ReplicaSetQuorumMode::Invalid, } } } -impl From for FABRIC_REPLICA_SET_QUORUM_MODE { - fn from(val: ReplicaSetQuarumMode) -> Self { +impl From for FABRIC_REPLICA_SET_QUORUM_MODE { + fn from(val: ReplicaSetQuorumMode) -> Self { match val { - ReplicaSetQuarumMode::All => FABRIC_REPLICA_SET_QUORUM_ALL, - ReplicaSetQuarumMode::Invalid => FABRIC_REPLICA_SET_QUORUM_INVALID, - ReplicaSetQuarumMode::Write => FABRIC_REPLICA_SET_WRITE_QUORUM, + ReplicaSetQuorumMode::All => FABRIC_REPLICA_SET_QUORUM_ALL, + ReplicaSetQuorumMode::Invalid => FABRIC_REPLICA_SET_QUORUM_INVALID, + ReplicaSetQuorumMode::Write => FABRIC_REPLICA_SET_WRITE_QUORUM, } } } diff --git a/crates/samples/echomain-stateful2/src/statefulstore.rs b/crates/samples/echomain-stateful2/src/statefulstore.rs index 98a8a189..6eb98950 100644 --- a/crates/samples/echomain-stateful2/src/statefulstore.rs +++ b/crates/samples/echomain-stateful2/src/statefulstore.rs @@ -12,7 +12,7 @@ use mssf_core::{ }, }, types::{ - Epoch, OpenMode, ReplicaInformation, ReplicaRole, ReplicaSetConfig, ReplicaSetQuarumMode, + Epoch, OpenMode, ReplicaInformation, ReplicaRole, ReplicaSetConfig, ReplicaSetQuorumMode, }, }; use mssf_core::{Error, HSTRING}; @@ -122,7 +122,7 @@ impl PrimaryReplicator for AppFabricReplicator { async fn wait_for_catch_up_quorum( &self, - _catchupmode: ReplicaSetQuarumMode, + _catchupmode: ReplicaSetQuorumMode, _: CancellationToken, ) -> mssf_core::Result<()> { info!("AppFabricReplicator2::PrimaryReplicator::wait_for_catch_up_quorum");