@@ -543,7 +543,7 @@ where
543
543
544
544
// --- data ---
545
545
current_term : st. vote_ref ( ) . term ( ) ,
546
- vote : st. io_state ( ) . log_progress . flushed ( ) . map ( |io_id| io_id. to_vote ( ) ) . unwrap_or_default ( ) ,
546
+ vote : st. log_progress ( ) . flushed ( ) . map ( |io_id| io_id. to_vote ( ) ) . unwrap_or_default ( ) ,
547
547
last_log_index : st. last_log_id ( ) . index ( ) ,
548
548
last_applied : st. io_applied ( ) . cloned ( ) ,
549
549
snapshot : st. io_snapshot_last_log_id ( ) . cloned ( ) ,
@@ -575,7 +575,7 @@ where
575
575
576
576
let server_metrics = RaftServerMetrics {
577
577
id : self . id . clone ( ) ,
578
- vote : st. io_state ( ) . log_progress . flushed ( ) . map ( |io_id| io_id. to_vote ( ) ) . unwrap_or_default ( ) ,
578
+ vote : st. log_progress ( ) . flushed ( ) . map ( |io_id| io_id. to_vote ( ) ) . unwrap_or_default ( ) ,
579
579
state : st. server_state ,
580
580
current_leader,
581
581
membership_config,
@@ -861,7 +861,7 @@ where
861
861
tracing:: debug!(
862
862
"RAFT_stats id={:<2} log_io: {}" ,
863
863
self . id,
864
- self . engine. state. io_state . log_progress
864
+ self . engine. state. log_progress( )
865
865
) ;
866
866
867
867
// In each loop, it does not have to check rx_shutdown and flush metrics for every RaftMsg
@@ -1368,7 +1368,7 @@ where
1368
1368
}
1369
1369
1370
1370
Notification :: LocalIO { io_id } => {
1371
- self . engine . state . io_state . log_progress . flush ( io_id. clone ( ) ) ;
1371
+ self . engine . state . log_progress_mut ( ) . flush ( io_id. clone ( ) ) ;
1372
1372
1373
1373
match io_id {
1374
1374
IOId :: Log ( log_io_id) => {
@@ -1448,16 +1448,18 @@ where
1448
1448
func_name!( )
1449
1449
) ;
1450
1450
1451
- self . engine . state . io_state_mut ( ) . log_progress . flush ( io_id) ;
1451
+ self . engine . state . log_progress_mut ( ) . flush ( io_id) ;
1452
1452
1453
1453
if let Some ( meta) = meta {
1454
+ if let Some ( last) = & meta. last_log_id {
1455
+ self . engine . state . apply_progress_mut ( ) . flush ( last. clone ( ) ) ;
1456
+ }
1454
1457
let st = self . engine . state . io_state_mut ( ) ;
1455
- st. update_applied ( meta. last_log_id . clone ( ) ) ;
1456
1458
st. update_snapshot ( meta. last_log_id ) ;
1457
1459
}
1458
1460
}
1459
1461
sm:: Response :: Apply ( res) => {
1460
- self . engine . state . io_state_mut ( ) . update_applied ( Some ( res. last_applied . clone ( ) ) ) ;
1462
+ self . engine . state . apply_progress_mut ( ) . flush ( res. last_applied ) ;
1461
1463
}
1462
1464
}
1463
1465
}
@@ -1613,7 +1615,7 @@ where
1613
1615
if let Some ( condition) = condition {
1614
1616
match condition {
1615
1617
Condition :: IOFlushed { io_id } => {
1616
- let curr = self . engine . state . io_state ( ) . log_progress . flushed ( ) ;
1618
+ let curr = self . engine . state . log_progress ( ) . flushed ( ) ;
1617
1619
if curr < Some ( & io_id) {
1618
1620
tracing:: debug!(
1619
1621
"io_id: {} has not yet flushed, currently flushed: {} postpone cmd: {}" ,
@@ -1625,7 +1627,7 @@ where
1625
1627
}
1626
1628
}
1627
1629
Condition :: LogFlushed { log_id } => {
1628
- let curr = self . engine . state . io_state ( ) . log_progress . flushed ( ) ;
1630
+ let curr = self . engine . state . log_progress ( ) . flushed ( ) ;
1629
1631
let curr = curr. and_then ( |x| x. last_log_id ( ) ) ;
1630
1632
if curr < log_id. as_ref ( ) {
1631
1633
tracing:: debug!(
@@ -1664,7 +1666,7 @@ where
1664
1666
1665
1667
match cmd {
1666
1668
Command :: UpdateIOProgress { io_id, .. } => {
1667
- self . engine . state . io_state . log_progress . submit ( io_id. clone ( ) ) ;
1669
+ self . engine . state . log_progress_mut ( ) . submit ( io_id. clone ( ) ) ;
1668
1670
1669
1671
let notify = Notification :: LocalIO { io_id : io_id. clone ( ) } ;
1670
1672
@@ -1689,13 +1691,13 @@ where
1689
1691
//
1690
1692
// The `submit` state must be updated before calling `append()`,
1691
1693
// because `append()` may call the callback before returning.
1692
- self . engine . state . io_state . log_progress . submit ( io_id) ;
1694
+ self . engine . state . log_progress_mut ( ) . submit ( io_id) ;
1693
1695
1694
1696
// Submit IO request, do not wait for the response.
1695
1697
self . log_store . append ( entries, callback) . await ?;
1696
1698
}
1697
1699
Command :: SaveVote { vote } => {
1698
- self . engine . state . io_state_mut ( ) . log_progress . submit ( IOId :: new ( & vote) ) ;
1700
+ self . engine . state . log_progress_mut ( ) . submit ( IOId :: new ( & vote) ) ;
1699
1701
self . log_store . save_vote ( & vote) . await ?;
1700
1702
1701
1703
let _ = self . tx_notification . send ( Notification :: LocalIO {
@@ -1758,7 +1760,7 @@ where
1758
1760
already_committed,
1759
1761
upto,
1760
1762
} => {
1761
- self . engine . state . io_state . apply_progress . submit ( upto. clone ( ) ) ;
1763
+ self . engine . state . apply_progress_mut ( ) . submit ( upto. clone ( ) ) ;
1762
1764
let first = self . engine . state . get_log_id ( already_committed. next_index ( ) ) . unwrap ( ) ;
1763
1765
self . apply_to_state_machine ( first, upto) . await ?;
1764
1766
}
@@ -1786,15 +1788,15 @@ where
1786
1788
self . heartbeat_handle . spawn_workers ( & mut self . network_factory , & self . tx_notification , nodes) . await ;
1787
1789
}
1788
1790
Command :: StateMachine { command } => {
1789
- let io_id = command. get_submit_io ( ) ;
1791
+ let io_id = command. get_log_progress ( ) ;
1790
1792
1791
1793
if let Some ( io_id) = io_id {
1792
- self . engine . state . io_state . log_progress . submit ( io_id) ;
1794
+ self . engine . state . log_progress_mut ( ) . submit ( io_id) ;
1793
1795
}
1794
1796
1795
1797
// If this command update the last-applied log id, mark it as submitted(to state machine).
1796
1798
if let Some ( log_id) = command. get_apply_progress ( ) {
1797
- self . engine . state . io_state . apply_progress . submit ( log_id) ;
1799
+ self . engine . state . apply_progress_mut ( ) . submit ( log_id) ;
1798
1800
}
1799
1801
1800
1802
// Just forward a state machine command to the worker.
0 commit comments