9
9
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
10
10
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator"
11
11
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/mmaprototype"
12
- "github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool"
13
12
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
14
13
"github.com/cockroachdb/cockroach/pkg/roachpb"
15
14
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
@@ -26,6 +25,28 @@ func (id SyncChangeID) IsValid() bool {
26
25
27
26
type SyncChangeID uint64
28
27
28
+ // storePool is an interface that defines the methods that the allocator sync
29
+ // needs to call on the store pool. Using an interface to simplify testing.
30
+ type storePool interface {
31
+ // UpdateLocalStoresAfterLeaseTransfer is called by the allocator sync to
32
+ // update the store pool after a lease transfer operation.
33
+ UpdateLocalStoresAfterLeaseTransfer (transferFrom , transferTo roachpb.StoreID , usage allocator.RangeUsageInfo )
34
+ // UpdateLocalStoreAfterRebalance is called by the allocator sync to update
35
+ // the store pool after a rebalance operation.
36
+ UpdateLocalStoreAfterRebalance (storeID roachpb.StoreID , rangeUsageInfo allocator.RangeUsageInfo , changeType roachpb.ReplicaChangeType )
37
+ }
38
+
39
+ // mmaAllocator is an interface that defines the methods that the allocator sync
40
+ // needs to call on the mma. Using an interface to simplify testing.
41
+ type mmaAllocator interface {
42
+ // RegisterExternalChanges is called by the allocator sync to register
43
+ // external changes with the mma.
44
+ RegisterExternalChanges (changes []mmaprototype.ReplicaChange ) []mmaprototype.ChangeID
45
+ // AdjustPendingChangesDisposition is called by the allocator sync to adjust
46
+ // the disposition of pending changes.
47
+ AdjustPendingChangesDisposition (changeIDs []mmaprototype.ChangeID , success bool )
48
+ }
49
+
29
50
// TODO(wenyihu6): make sure allocator sync can tolerate cluster setting
30
51
// changes not happening consistently or atomically across components. (For
31
52
// example, replicate queue may call into allocator sync when mma is enabled but
@@ -37,9 +58,9 @@ type SyncChangeID uint64
37
58
// disabled, its sole purpose is to track and apply changes to the store pool
38
59
// upon success.
39
60
type AllocatorSync struct {
40
- sp * storepool. StorePool
61
+ sp storePool
41
62
st * cluster.Settings
42
- mmaAllocator mmaprototype. Allocator
63
+ mmaAllocator mmaAllocator
43
64
mu struct {
44
65
syncutil.Mutex
45
66
// changeSeqGen is a monotonically increasing sequence number for
@@ -54,7 +75,7 @@ type AllocatorSync struct {
54
75
}
55
76
56
77
func NewAllocatorSync (
57
- sp * storepool. StorePool , mmaAllocator mmaprototype. Allocator , st * cluster.Settings ,
78
+ sp storePool , mmaAllocator mmaAllocator , st * cluster.Settings ,
58
79
) * AllocatorSync {
59
80
as := & AllocatorSync {
60
81
sp : sp ,
0 commit comments