Skip to content

Commit 9b88641

Browse files
authored
Populate tasklistkind in poll request (#859)
1 parent e527afb commit 9b88641

File tree

6 files changed

+81
-9
lines changed

6 files changed

+81
-9
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.internal.worker;
19+
20+
public enum TaskListKind {
21+
TASK_LIST_KIND_NORMAL(0),
22+
TASK_LIST_KIND_STICKY(1);
23+
24+
private final int value;
25+
26+
TaskListKind(int value) {
27+
this.value = value;
28+
}
29+
30+
public com.uber.cadence.TaskListKind toThrift() {
31+
return com.uber.cadence.TaskListKind.findByValue(this.value);
32+
}
33+
}

src/main/java/com/uber/cadence/internal/worker/WorkflowPollTask.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,21 @@ final class WorkflowPollTask implements Poller.PollTask<PollForDecisionTaskRespo
4545
private final IWorkflowService service;
4646
private final String domain;
4747
private final String taskList;
48+
private final TaskListKind taskListKind;
4849
private final String identity;
4950

5051
WorkflowPollTask(
5152
IWorkflowService service,
5253
String domain,
5354
String taskList,
55+
TaskListKind taskListKind,
5456
Scope metricScope,
5557
String identity) {
5658
this.identity = Objects.requireNonNull(identity);
5759
this.service = Objects.requireNonNull(service);
5860
this.domain = Objects.requireNonNull(domain);
5961
this.taskList = Objects.requireNonNull(taskList);
62+
this.taskListKind = Objects.requireNonNull(taskListKind);
6063
this.metricScope = Objects.requireNonNull(metricScope);
6164
}
6265

@@ -70,8 +73,7 @@ public PollForDecisionTaskResponse poll() throws TException {
7073
pollRequest.setIdentity(identity);
7174
pollRequest.setBinaryChecksum(BinaryChecksum.getBinaryChecksum());
7275

73-
TaskList tl = new TaskList();
74-
tl.setName(taskList);
76+
TaskList tl = new TaskList().setName(taskList).setKind(taskListKind.toThrift());
7577
pollRequest.setTaskList(tl);
7678

7779
if (log.isDebugEnabled()) {

src/main/java/com/uber/cadence/internal/worker/WorkflowPollTaskFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,27 @@ public class WorkflowPollTaskFactory
2929
private final IWorkflowService service;
3030
private final String domain;
3131
private final String taskList;
32+
private final TaskListKind taskListKind;
3233
private final Scope metricScope;
3334
private final String identity;
3435

3536
public WorkflowPollTaskFactory(
3637
IWorkflowService service,
3738
String domain,
3839
String taskList,
40+
TaskListKind taskListKind,
3941
Scope metricScope,
4042
String identity) {
4143
this.service = Objects.requireNonNull(service, "service should not be null");
4244
this.domain = Objects.requireNonNull(domain, "domain should not be null");
4345
this.taskList = Objects.requireNonNull(taskList, "taskList should not be null");
46+
this.taskListKind = Objects.requireNonNull(taskListKind, "taskList should not be null");
4447
this.metricScope = Objects.requireNonNull(metricScope, "metricScope should not be null");
4548
this.identity = Objects.requireNonNull(identity, "identity should not be null");
4649
}
4750

4851
@Override
4952
public Poller.PollTask<PollForDecisionTaskResponse> get() {
50-
return new WorkflowPollTask(service, domain, taskList, metricScope, identity);
53+
return new WorkflowPollTask(service, domain, taskList, taskListKind, metricScope, identity);
5154
}
5255
}

src/main/java/com/uber/cadence/internal/worker/WorkflowWorker.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ public void start() {
104104
new Poller<>(
105105
options.getIdentity(),
106106
new WorkflowPollTask(
107-
service, domain, taskList, options.getMetricsScope(), options.getIdentity()),
107+
service,
108+
domain,
109+
taskList,
110+
TaskListKind.TASK_LIST_KIND_NORMAL,
111+
options.getMetricsScope(),
112+
options.getIdentity()),
108113
pollTaskExecutor,
109114
options.getPollerOptions(),
110115
options.getMetricsScope());

src/main/java/com/uber/cadence/worker/WorkerFactory.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
import com.uber.cadence.internal.common.InternalUtils;
2828
import com.uber.cadence.internal.metrics.MetricsTag;
2929
import com.uber.cadence.internal.replay.DeciderCache;
30-
import com.uber.cadence.internal.worker.PollDecisionTaskDispatcher;
31-
import com.uber.cadence.internal.worker.Poller;
32-
import com.uber.cadence.internal.worker.PollerOptions;
33-
import com.uber.cadence.internal.worker.WorkerShutDownHandler;
34-
import com.uber.cadence.internal.worker.WorkflowPollTaskFactory;
30+
import com.uber.cadence.internal.worker.*;
3531
import com.uber.m3.tally.Scope;
3632
import com.uber.m3.util.ImmutableMap;
3733
import java.net.InetAddress;
@@ -131,6 +127,7 @@ public WorkerFactory(WorkflowClient workflowClient, WorkerFactoryOptions factory
131127
workflowClient.getService(),
132128
workflowClient.getOptions().getDomain(),
133129
getStickyTaskListName(),
130+
TaskListKind.TASK_LIST_KIND_STICKY,
134131
stickyScope,
135132
workflowClient.getOptions().getIdentity())
136133
.get(),
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.internal.worker;
19+
20+
import static junit.framework.TestCase.*;
21+
22+
import org.junit.Test;
23+
24+
public class TaskListKindTest {
25+
@Test
26+
public void toThrift() {
27+
assertEquals(
28+
TaskListKind.TASK_LIST_KIND_NORMAL.toThrift(), com.uber.cadence.TaskListKind.NORMAL);
29+
assertEquals(
30+
TaskListKind.TASK_LIST_KIND_STICKY.toThrift(), com.uber.cadence.TaskListKind.STICKY);
31+
}
32+
}

0 commit comments

Comments
 (0)