Skip to content

Commit bd66dc4

Browse files
committed
asim: add AllocatorSync to asim queues
This commit populates the AllocatorSync field in asim queues. It will be used in future commits to coordinate changes with mma. Epic: none Release note: none
1 parent f4975dd commit bd66dc4

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

pkg/kv/kvserver/asim/asim.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func (s *Simulator) addStore(storeID state.StoreID, tick time.Time) {
145145
s.changer,
146146
s.settings,
147147
allocator,
148+
s.state.Node(store.NodeID()).AllocatorSync(),
148149
storePool,
149150
tick,
150151
)
@@ -154,6 +155,7 @@ func (s *Simulator) addStore(storeID state.StoreID, tick time.Time) {
154155
s.changer,
155156
s.settings,
156157
allocator,
158+
s.state.Node(store.NodeID()).AllocatorSync(),
157159
storePool,
158160
tick,
159161
)

pkg/kv/kvserver/asim/queue/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ go_library(
1616
"//pkg/kv/kvpb",
1717
"//pkg/kv/kvserver/allocator",
1818
"//pkg/kv/kvserver/allocator/allocatorimpl",
19+
"//pkg/kv/kvserver/allocator/mmaprototypehelpers",
1920
"//pkg/kv/kvserver/allocator/plan",
2021
"//pkg/kv/kvserver/allocator/storepool",
2122
"//pkg/kv/kvserver/asim/config",

pkg/kv/kvserver/asim/queue/lease_queue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
15+
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/mmaprototypehelpers"
1516
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/plan"
1617
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool"
1718
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/config"
@@ -28,6 +29,7 @@ type leaseQueue struct {
2829
planner plan.ReplicationPlanner
2930
clock *hlc.Clock
3031
settings *config.SimulationSettings
32+
as *mmaprototypehelpers.AllocatorSync
3133
}
3234

3335
// NewLeaseQueue returns a new lease queue.
@@ -37,6 +39,7 @@ func NewLeaseQueue(
3739
stateChanger state.Changer,
3840
settings *config.SimulationSettings,
3941
allocator allocatorimpl.Allocator,
42+
allocatorSync *mmaprototypehelpers.AllocatorSync,
4043
storePool storepool.AllocatorStorePool,
4144
start time.Time,
4245
) RangeQueue {
@@ -52,6 +55,7 @@ func NewLeaseQueue(
5255
planner: plan.NewLeasePlanner(allocator, storePool),
5356
storePool: storePool,
5457
clock: storePool.Clock(),
58+
as: allocatorSync,
5559
}
5660
lq.AddLogTag("lease", nil)
5761
lq.AddLogTag(fmt.Sprintf("n%ds%d", nodeID, storeID), "")

pkg/kv/kvserver/asim/queue/lease_queue_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func TestLeaseQueue(t *testing.T) {
144144
changer,
145145
testSettings,
146146
s.Allocator(store.StoreID()),
147+
s.Node(store.NodeID()).AllocatorSync(),
147148
s.StorePool(store.StoreID()),
148149
start,
149150
)

pkg/kv/kvserver/asim/queue/replicate_queue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
15+
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/mmaprototypehelpers"
1516
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/plan"
1617
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool"
1718
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/config"
@@ -26,6 +27,7 @@ type replicateQueue struct {
2627
planner plan.ReplicationPlanner
2728
clock *hlc.Clock
2829
settings *config.SimulationSettings
30+
as *mmaprototypehelpers.AllocatorSync
2931
}
3032

3133
// NewReplicateQueue returns a new replicate queue.
@@ -35,6 +37,7 @@ func NewReplicateQueue(
3537
stateChanger state.Changer,
3638
settings *config.SimulationSettings,
3739
allocator allocatorimpl.Allocator,
40+
allocatorSync *mmaprototypehelpers.AllocatorSync,
3841
storePool storepool.AllocatorStorePool,
3942
start time.Time,
4043
) RangeQueue {
@@ -50,6 +53,7 @@ func NewReplicateQueue(
5053
planner: plan.NewReplicaPlanner(
5154
allocator, storePool, plan.ReplicaPlannerTestingKnobs{}),
5255
clock: storePool.Clock(),
56+
as: allocatorSync,
5357
}
5458
rq.AddLogTag("replica", nil)
5559
rq.AddLogTag(fmt.Sprintf("n%ds%d", nodeID, storeID), "")

pkg/kv/kvserver/asim/queue/replicate_queue_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ func TestReplicateQueue(t *testing.T) {
293293
changer,
294294
testSettings,
295295
s.Allocator(store.StoreID()),
296+
s.Node(store.NodeID()).AllocatorSync(),
296297
s.StorePool(store.StoreID()),
297298
start,
298299
)

0 commit comments

Comments
 (0)