Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions service/matching/tasklist/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type (
UpdateTaskListPartitionConfig(context.Context, *types.TaskListPartitionConfig) error
RefreshTaskListPartitionConfig(context.Context, *types.TaskListPartitionConfig) error
LoadBalancerHints() *types.LoadBalancerHints
QueriesPerSecond() float64
ReleaseBlockedPollers() error
}

Expand Down
14 changes: 14 additions & 0 deletions service/matching/tasklist/interfaces_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/matching/tasklist/shard_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ func (sp *shardProcessorImpl) getShardLoad() float64 {
// we need to sum the rps for each of the tasklist to calculate the load.
for _, tlMgr := range sp.taskLists {
if tlMgr.TaskListID().name == sp.shardID {
lbh := tlMgr.LoadBalancerHints()
if lbh != nil {
load = load + lbh.RatePerSecond
}
qps := tlMgr.QueriesPerSecond()
load = load + qps
}
}
return load
Expand Down
4 changes: 4 additions & 0 deletions service/matching/tasklist/task_list_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ func (c *taskListManagerImpl) LoadBalancerHints() *types.LoadBalancerHints {
}
}

func (c *taskListManagerImpl) QueriesPerSecond() float64 {
return c.qpsTracker.QPS()
}

func isTaskListPartitionConfigEqual(a types.TaskListPartitionConfig, b types.TaskListPartitionConfig) bool {
a.Version = b.Version
return reflect.DeepEqual(a, b)
Expand Down
40 changes: 40 additions & 0 deletions service/matching/tasklist/task_list_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,46 @@ func TestDescribeTaskList(t *testing.T) {
}
}

func TestQueriesPerSecond(t *testing.T) {
testCases := []struct {
name string
mockSetup func(ctrl *gomock.Controller, tlm *taskListManagerImpl)
expectedQPS float64
}{
{
name: "returns QPS from tracker",
mockSetup: func(ctrl *gomock.Controller, tlm *taskListManagerImpl) {
mockQPS := stats.NewMockQPSTrackerGroup(ctrl)
mockQPS.EXPECT().QPS().Return(float64(42.5))
tlm.qpsTracker = mockQPS
},
expectedQPS: 42.5,
},
{
name: "returns zero QPS",
mockSetup: func(ctrl *gomock.Controller, tlm *taskListManagerImpl) {
mockQPS := stats.NewMockQPSTrackerGroup(ctrl)
mockQPS.EXPECT().QPS().Return(float64(0))
tlm.qpsTracker = mockQPS
},
expectedQPS: 0,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
logger := testlogger.New(t)
tlm := createTestTaskListManager(t, logger, ctrl)

tc.mockSetup(ctrl, tlm)

actualQPS := tlm.QueriesPerSecond()
assert.Equal(t, tc.expectedQPS, actualQPS)
})
}
}

func TestCheckIdleTaskList(t *testing.T) {
defer goleak.VerifyNone(t)
cfg := config.NewConfig(dynamicconfig.NewNopCollection(), "some random hostname", commonConfig.RPC{}, getIsolationgroupsHelper)
Expand Down
Loading