@@ -15,10 +15,14 @@ import (
1515
1616 "github.com/cockroachdb/cockroach/pkg/roachpb"
1717 "github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb"
18+ "github.com/cockroachdb/redact"
1819)
1920
2021// RangeController provides flow control for replication traffic in KV, for a
2122// range at the leader.
23+ //
24+ // None of the methods are called with Replica.mu held. The caller should
25+ // typically order its mutexes before Replica.mu.
2226type RangeController interface {
2327 // WaitForEval seeks admission to evaluate a request at the given priority.
2428 // This blocks until there are positive tokens available for the request to
@@ -37,10 +41,10 @@ type RangeController interface {
3741 //
3842 // Requires replica.raftMu to be held.
3943 HandleSchedulerEventRaftMuLocked (ctx context.Context ) error
40- // SetReplicasLocked sets the replicas of the range.
44+ // SetReplicasRaftMuLocked sets the replicas of the range.
4145 //
42- // Requires replica.raftMu and replica.mu to be held.
43- SetReplicasLocked (ctx context.Context , replicas roachpb. ReplicaSet ) error
46+ // Requires replica.raftMu to be held.
47+ SetReplicasRaftMuLocked (ctx context.Context , replicas ReplicaSet ) error
4448 // SetLeaseholderRaftMuLocked sets the leaseholder of the range.
4549 //
4650 // Requires raftMu to be held.
@@ -54,3 +58,27 @@ type RangeController interface {
5458// TODO(pav-kv): This struct is a placeholder for the interface or struct
5559// containing raft entries. Replace this as part of #128019.
5660type RaftEvent struct {}
61+
62+ // NoReplicaID is a special value of roachpb.ReplicaID, which can never be a
63+ // valid ID.
64+ const NoReplicaID roachpb.ReplicaID = 0
65+
66+ type ReplicaSet map [roachpb.ReplicaID ]roachpb.ReplicaDescriptor
67+
68+ // SafeFormat implements the redact.SafeFormatter interface.
69+ func (rs ReplicaSet ) SafeFormat (w redact.SafePrinter , _ rune ) {
70+ w .Printf ("[" )
71+ i := 0
72+ for _ , desc := range rs {
73+ if i > 0 {
74+ w .Printf ("," )
75+ }
76+ w .Printf ("%v" , desc )
77+ i ++
78+ }
79+ w .Printf ("]" )
80+ }
81+
82+ func (rs ReplicaSet ) String () string {
83+ return redact .StringWithoutMarkers (rs )
84+ }
0 commit comments