@@ -47,22 +47,22 @@ func MakeFortificationTracker(
47
47
48
48
// FortificationEnabled returns whether the raft fortification protocol is
49
49
// enabled or not.
50
- func (st * FortificationTracker ) FortificationEnabled () bool {
51
- return st .storeLiveness .SupportFromEnabled ()
50
+ func (ft * FortificationTracker ) FortificationEnabled () bool {
51
+ return ft .storeLiveness .SupportFromEnabled ()
52
52
}
53
53
54
- // RecordFortification records that the node with the given id supported this
55
- // Raft instance until the supplied timestamp .
56
- func (st * FortificationTracker ) RecordFortification (id pb.PeerID , epoch pb.Epoch ) {
54
+ // RecordFortification records fortification of the given peer for the supplied
55
+ // epoch .
56
+ func (ft * FortificationTracker ) RecordFortification (id pb.PeerID , epoch pb.Epoch ) {
57
57
// The supported epoch should never regress. Guard against out of order
58
58
// delivery of fortify responses by using max.
59
- st .fortification [id ] = max (st .fortification [id ], epoch )
59
+ ft .fortification [id ] = max (ft .fortification [id ], epoch )
60
60
}
61
61
62
62
// Reset clears out any previously tracked fortification.
63
- func (st * FortificationTracker ) Reset () {
64
- clear (st .fortification )
65
- // TODO(arul): when we introduce st .LeadSupportUntil we need to make sure it
63
+ func (ft * FortificationTracker ) Reset () {
64
+ clear (ft .fortification )
65
+ // TODO(arul): when we introduce ft .LeadSupportUntil we need to make sure it
66
66
// isn't reset here, because we don't want it to regress when a leader steps
67
67
// down.
68
68
}
@@ -71,15 +71,15 @@ func (st *FortificationTracker) Reset() {
71
71
// If the follower's store doesn't support the leader's store in the store
72
72
// liveness fabric, then both isSupported and isFortified will be false.
73
73
// If isFortified is true, it implies that isSupported is also true.
74
- func (st * FortificationTracker ) IsFortifiedBy (id pb.PeerID ) (isFortified bool , isSupported bool ) {
75
- supportEpoch , curExp := st .storeLiveness .SupportFrom (id )
76
- if st .storeLiveness .SupportExpired (curExp ) {
74
+ func (ft * FortificationTracker ) IsFortifiedBy (id pb.PeerID ) (isFortified bool , isSupported bool ) {
75
+ supportEpoch , curExp := ft .storeLiveness .SupportFrom (id )
76
+ if ft .storeLiveness .SupportExpired (curExp ) {
77
77
return false , false
78
78
}
79
79
80
80
// At this point we know that the follower's store is providing support
81
81
// at the store liveness fabric.
82
- fortificationEpoch , exist := st .fortification [id ]
82
+ fortificationEpoch , exist := ft .fortification [id ]
83
83
if ! exist {
84
84
// We don't know that the follower is fortified.
85
85
return false , true
@@ -96,12 +96,12 @@ func (st *FortificationTracker) IsFortifiedBy(id pb.PeerID) (isFortified bool, i
96
96
// LeadSupportUntil returns the timestamp until which the leader is guaranteed
97
97
// fortification until based on the fortification being tracked for it by its
98
98
// peers.
99
- func (st * FortificationTracker ) LeadSupportUntil () hlc.Timestamp {
99
+ func (ft * FortificationTracker ) LeadSupportUntil () hlc.Timestamp {
100
100
// TODO(arul): avoid this map allocation as we're calling LeadSupportUntil
101
101
// from hot paths.
102
102
supportExpMap := make (map [pb.PeerID ]hlc.Timestamp )
103
- for id , supportEpoch := range st .fortification {
104
- curEpoch , curExp := st .storeLiveness .SupportFrom (id )
103
+ for id , supportEpoch := range ft .fortification {
104
+ curEpoch , curExp := ft .storeLiveness .SupportFrom (id )
105
105
// NB: We can't assert that supportEpoch <= curEpoch because there may be a
106
106
// race between a successful MsgFortifyLeaderResp and the store liveness
107
107
// heartbeat response that lets the leader know the follower's store is
@@ -111,28 +111,28 @@ func (st *FortificationTracker) LeadSupportUntil() hlc.Timestamp {
111
111
supportExpMap [id ] = curExp
112
112
}
113
113
}
114
- return st .config .Voters .LeadSupportExpiration (supportExpMap )
114
+ return ft .config .Voters .LeadSupportExpiration (supportExpMap )
115
115
}
116
116
117
117
// QuorumActive returns whether the leader is currently supported by a quorum or
118
118
// not.
119
- func (st * FortificationTracker ) QuorumActive () bool {
120
- return ! st .storeLiveness .SupportExpired (st .LeadSupportUntil ())
119
+ func (ft * FortificationTracker ) QuorumActive () bool {
120
+ return ! ft .storeLiveness .SupportExpired (ft .LeadSupportUntil ())
121
121
}
122
122
123
- func (st * FortificationTracker ) String () string {
124
- if len (st .fortification ) == 0 {
123
+ func (ft * FortificationTracker ) String () string {
124
+ if len (ft .fortification ) == 0 {
125
125
return "empty"
126
126
}
127
127
// Print the map in sorted order as we assert on its output in tests.
128
- ids := make ([]pb.PeerID , 0 , len (st .fortification ))
129
- for id := range st .fortification {
128
+ ids := make ([]pb.PeerID , 0 , len (ft .fortification ))
129
+ for id := range ft .fortification {
130
130
ids = append (ids , id )
131
131
}
132
132
slices .Sort (ids )
133
133
var buf strings.Builder
134
134
for _ , id := range ids {
135
- fmt .Fprintf (& buf , "%d : %d\n " , id , st .fortification [id ])
135
+ fmt .Fprintf (& buf , "%d : %d\n " , id , ft .fortification [id ])
136
136
}
137
137
return buf .String ()
138
138
}
0 commit comments