Skip to content

Commit

Permalink
Fix ListTaskListPartition command (#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
anish531213 committed Jun 16, 2020
1 parent 6d1be81 commit 13f4100
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions service/matching/matchingEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,17 +571,17 @@ func (e *matchingEngineImpl) ListTaskListPartitions(ctx context.Context, request
if err != nil {
return nil, err
}
resp := workflow.ListTaskListPartitionsResponse{
resp := &workflow.ListTaskListPartitionsResponse{
ActivityTaskListPartitions: activityTaskListInfo,
DecisionTaskListPartitions: decisionTaskListInfo,
}
return &resp, nil

return resp, nil
}

func (e *matchingEngineImpl) listTaskListPartitions(request *m.ListTaskListPartitionsRequest, taskListType int) ([]*workflow.TaskListPartitionMetadata, error) {
partitions, err := e.getAllPartitions(
request.GetDomain(),
*request.TaskList,
request,
taskListType,
)
if err != nil {
Expand All @@ -593,13 +593,12 @@ func (e *matchingEngineImpl) listTaskListPartitions(request *m.ListTaskListParti
return nil, err
}
for _, partition := range partitions {
if host, err := e.getHostInfo(partition); err != nil {
partitionHostInfo = append(partitionHostInfo,
&workflow.TaskListPartitionMetadata{
Key: common.StringPtr(partition),
OwnerHostName: common.StringPtr(host),
})
}
host, _ := e.getHostInfo(partition)
partitionHostInfo = append(partitionHostInfo,
&workflow.TaskListPartitionMetadata{
Key: common.StringPtr(partition),
OwnerHostName: common.StringPtr(host),
})
}
return partitionHostInfo, nil
}
Expand All @@ -613,22 +612,22 @@ func (e *matchingEngineImpl) getHostInfo(partitionKey string) (string, error) {
}

func (e *matchingEngineImpl) getAllPartitions(
domain string,
taskList workflow.TaskList,
request *m.ListTaskListPartitionsRequest,
taskListType int,
) ([]string, error) {
var partitionKeys []string
domainID, err := e.domainCache.GetDomainID(domain)
domainID, err := e.domainCache.GetDomainID(request.GetDomain())
if err != nil {
return partitionKeys, err
}
taskListID, err := newTaskListID(domainID, taskList.GetName(), persistence.TaskListTypeDecision)
taskList := request.GetTaskList()
taskListID, err := newTaskListID(domainID, taskList.GetName(), taskListType)
rootPartition := taskListID.GetRoot()

partitionKeys = append(partitionKeys, rootPartition)

nWritePartitions := e.config.GetTasksBatchSize
n := nWritePartitions(domain, rootPartition, taskListType)
nWritePartitions := e.config.NumTasklistWritePartitions
n := nWritePartitions(request.GetDomain(), rootPartition, taskListType)
if n <= 0 {
return partitionKeys, nil
}
Expand Down

0 comments on commit 13f4100

Please sign in to comment.