Skip to content

Commit c0322fc

Browse files
authored
Decision to WorkflowTask or Command renaming (#150)
1 parent 9150871 commit c0322fc

File tree

108 files changed

+2856
-2798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2856
-2798
lines changed

build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ dependencies {
113113
testImplementation group: 'junit', name: 'junit', version: '4.13'
114114
}
115115

116+
configurations.all {
117+
// Conflicts with logback
118+
exclude group: 'org.slf4j', module: 'slf4j-simple'
119+
}
120+
116121
license {
117122
header rootProject.file('license-header.txt')
118123
exclude 'io/temporal/proto/**.java' // generated code
@@ -217,6 +222,12 @@ javadoc {
217222
}
218223
}
219224

225+
// Needed to include generated fils into the source jar
226+
task sourceJar(type: Jar) {
227+
from sourceSets.main.allSource, file("$buildDir/generated/main/java")
228+
classifier "sources"
229+
}
230+
220231
task registerNamespace(type: JavaExec) {
221232
main = 'io.temporal.RegisterTestNamespace'
222233
classpath = sourceSets.test.runtimeClasspath

src/main/java/io/temporal/client/WorkflowFailedException.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,35 @@
2929
public final class WorkflowFailedException extends WorkflowException {
3030

3131
private final RetryState retryState;
32-
private final long decisionTaskCompletedEventId;
32+
private final long workflowTaskCompletedEventId;
3333

3434
public WorkflowFailedException(
3535
WorkflowExecution workflowExecution,
3636
String workflowType,
37-
long decisionTaskCompletedEventId,
37+
long workflowTaskCompletedEventId,
3838
RetryState retryState,
3939
Throwable cause) {
4040
super(
41-
getMessage(workflowExecution, workflowType, decisionTaskCompletedEventId, retryState),
41+
getMessage(workflowExecution, workflowType, workflowTaskCompletedEventId, retryState),
4242
workflowExecution,
4343
workflowType,
4444
cause);
4545
this.retryState = retryState;
46-
this.decisionTaskCompletedEventId = decisionTaskCompletedEventId;
46+
this.workflowTaskCompletedEventId = workflowTaskCompletedEventId;
4747
}
4848

4949
public RetryState getRetryState() {
5050
return retryState;
5151
}
5252

53-
public long getDecisionTaskCompletedEventId() {
54-
return decisionTaskCompletedEventId;
53+
public long getWorkflowTaskCompletedEventId() {
54+
return workflowTaskCompletedEventId;
5555
}
5656

5757
public static String getMessage(
5858
WorkflowExecution workflowExecution,
5959
String workflowType,
60-
long decisionTaskCompletedEventId,
60+
long workflowTaskCompletedEventId,
6161
RetryState retryState) {
6262
return "workflowId='"
6363
+ workflowExecution.getWorkflowId()
@@ -66,7 +66,7 @@ public static String getMessage(
6666
+ (workflowType == null ? "'" : "', workflowType='" + workflowType + '\'')
6767
+ ", retryState="
6868
+ retryState
69-
+ ", decisionTaskCompletedEventId="
70-
+ decisionTaskCompletedEventId;
69+
+ ", workflowTaskCompletedEventId="
70+
+ workflowTaskCompletedEventId;
7171
}
7272
}

src/main/java/io/temporal/client/WorkflowOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ public Builder setWorkflowExecutionTimeout(Duration workflowExecutionTimeout) {
168168
return this;
169169
}
170170

171-
/** Maximum execution time of a single decision task. Default is 10 seconds. */
171+
/** Maximum execution time of a single workflow task. Default is 10 seconds. */
172172
public Builder setWorkflowTaskTimeout(Duration workflowTaskTimeout) {
173173
this.workflowTaskTimeout = workflowTaskTimeout;
174174
return this;
175175
}
176176

177177
/**
178-
* Task queue to use for decision tasks. It should match a task queue specified when creating a
178+
* Task queue to use for workflow tasks. It should match a task queue specified when creating a
179179
* {@link io.temporal.worker.Worker} that hosts the workflow code.
180180
*/
181181
public Builder setTaskQueue(String taskQueue) {

src/main/java/io/temporal/common/converter/JacksonJsonPayloadConverter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public JacksonJsonPayloadConverter() {
4343
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
4444
}
4545

46+
public JacksonJsonPayloadConverter(ObjectMapper mapper) {
47+
this.mapper = mapper;
48+
}
49+
4650
@Override
4751
public String getEncodingType() {
4852
return EncodingKeys.METADATA_ENCODING_JSON_NAME;

src/main/java/io/temporal/failure/FailureConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class FailureConverter {
5858
private static final ImmutableSet<String> CUTOFF_METHOD_NAMES =
5959
ImmutableSet.of(
6060
"io.temporal.internal.worker.POJOActivityImplementationFactory$POJOActivityImplementation.execute",
61-
"io.temporal.internal.sync.POJODecisionTaskHandler$POJOWorkflowImplementation.execute");
61+
"io.temporal.internal.sync.POJOWorkflowTaskHandler$POJOWorkflowImplementation.execute");
6262

6363
/** Used to parse a stack trace line. */
6464
private static final String TRACE_ELEMENT_REGEXP =

src/main/java/io/temporal/internal/common/LocalActivityMarkerData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import io.temporal.api.workflowservice.v1.RespondActivityTaskCanceledRequest;
3030
import io.temporal.api.workflowservice.v1.RespondActivityTaskFailedRequest;
3131
import io.temporal.common.converter.DataConverter;
32-
import io.temporal.internal.replay.ClockDecisionContext;
32+
import io.temporal.internal.replay.ReplayClockContext;
3333
import java.time.Duration;
3434
import java.util.Optional;
3535

@@ -182,7 +182,7 @@ public HistoryEvent toEvent(DataConverter converter) {
182182
Payloads data = converter.toPayloads(this.data).get();
183183
MarkerRecordedEventAttributes.Builder attributes =
184184
MarkerRecordedEventAttributes.newBuilder()
185-
.setMarkerName(ClockDecisionContext.LOCAL_ACTIVITY_MARKER_NAME)
185+
.setMarkerName(ReplayClockContext.LOCAL_ACTIVITY_MARKER_NAME)
186186
.putDetails(MARKER_DATA_KEY, data);
187187
if (result.isPresent()) {
188188
attributes.putDetails(MARKER_RESULT_KEY, result.get());

src/main/java/io/temporal/internal/common/WorkflowExecutionFailedException.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@
2525
/** Framework level exception. Do not throw or catch in the application level code. */
2626
public final class WorkflowExecutionFailedException extends RuntimeException {
2727

28-
private final long decisionTaskCompletedEventId;
28+
private final long workflowTaskCompletedEventId;
2929
private final Failure failure;
3030
private final RetryState retryState;
3131

3232
WorkflowExecutionFailedException(
33-
Failure failure, long decisionTaskCompletedEventId, RetryState retryState) {
33+
Failure failure, long workflowTaskCompletedEventId, RetryState retryState) {
3434
this.failure = failure;
35-
this.decisionTaskCompletedEventId = decisionTaskCompletedEventId;
35+
this.workflowTaskCompletedEventId = workflowTaskCompletedEventId;
3636
this.retryState = retryState;
3737
}
3838

3939
public Failure getFailure() {
4040
return failure;
4141
}
4242

43-
public long getDecisionTaskCompletedEventId() {
44-
return decisionTaskCompletedEventId;
43+
public long getWorkflowTaskCompletedEventId() {
44+
return workflowTaskCompletedEventId;
4545
}
4646

4747
public RetryState getRetryState() {

src/main/java/io/temporal/internal/common/WorkflowExecutionUtils.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
import com.uber.m3.tally.Scope;
3434
import io.grpc.Deadline;
3535
import io.grpc.Status;
36+
import io.temporal.api.command.v1.Command;
3637
import io.temporal.api.common.v1.Payloads;
3738
import io.temporal.api.common.v1.WorkflowExecution;
38-
import io.temporal.api.decision.v1.Decision;
39-
import io.temporal.api.enums.v1.DecisionType;
39+
import io.temporal.api.enums.v1.CommandType;
4040
import io.temporal.api.enums.v1.EventType;
4141
import io.temporal.api.enums.v1.HistoryEventFilterType;
4242
import io.temporal.api.enums.v1.RetryState;
@@ -88,7 +88,7 @@
8888
public class WorkflowExecutionUtils {
8989

9090
/**
91-
* Indentation for history and decisions pretty printing. Do not change it from 2 spaces. The gson
91+
* Indentation for history and commands pretty printing. Do not change it from 2 spaces. The gson
9292
* pretty printer has it hardcoded and changing it breaks the indentation of exception stack
9393
* traces.
9494
*/
@@ -173,7 +173,7 @@ private static Optional<Payloads> getResultFromCloseEvent(
173173
WorkflowExecutionFailedEventAttributes failed =
174174
closeEvent.getWorkflowExecutionFailedEventAttributes();
175175
throw new WorkflowExecutionFailedException(
176-
failed.getFailure(), failed.getDecisionTaskCompletedEventId(), failed.getRetryState());
176+
failed.getFailure(), failed.getWorkflowTaskCompletedEventId(), failed.getRetryState());
177177
case EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED:
178178
WorkflowExecutionTerminatedEventAttributes terminated =
179179
closeEvent.getWorkflowExecutionTerminatedEventAttributes();
@@ -413,13 +413,13 @@ public static boolean isWorkflowExecutionCompletedEvent(HistoryEventOrBuilder ev
413413
|| event.getEventType() == EventType.EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED));
414414
}
415415

416-
public static boolean isWorkflowExecutionCompleteDecision(Decision decision) {
417-
return ((decision != null)
418-
&& (decision.getDecisionType() == DecisionType.DECISION_TYPE_COMPLETE_WORKFLOW_EXECUTION
419-
|| decision.getDecisionType() == DecisionType.DECISION_TYPE_CANCEL_WORKFLOW_EXECUTION
420-
|| decision.getDecisionType() == DecisionType.DECISION_TYPE_FAIL_WORKFLOW_EXECUTION
421-
|| decision.getDecisionType()
422-
== DecisionType.DECISION_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION));
416+
public static boolean isWorkflowExecutionCompleteCommand(Command command) {
417+
return ((command != null)
418+
&& (command.getCommandType() == CommandType.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION
419+
|| command.getCommandType() == CommandType.COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION
420+
|| command.getCommandType() == CommandType.COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION
421+
|| command.getCommandType()
422+
== CommandType.COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION));
423423
}
424424

425425
public static boolean isActivityTaskClosedEvent(HistoryEvent event) {
@@ -678,7 +678,7 @@ public static String prettyPrintHistory(
678678
/**
679679
* Returns workflow instance history in a human readable format.
680680
*
681-
* @param showWorkflowTasks when set to false workflow task events (decider events) are not
681+
* @param showWorkflowTasks when set to false workflow task events (command events) are not
682682
* included
683683
* @param metricsScope
684684
*/
@@ -731,7 +731,7 @@ private void getNextPage() {
731731
/**
732732
* Returns workflow instance history in a human readable format.
733733
*
734-
* @param showWorkflowTasks when set to false workflow task events (decider events) are not
734+
* @param showWorkflowTasks when set to false workflow task events (command events) are not
735735
* included
736736
* @param history Workflow instance history
737737
*/
@@ -752,10 +752,10 @@ public static String prettyPrintHistory(
752752
return result.toString();
753753
}
754754

755-
public static String prettyPrintDecisions(Iterable<Decision> decisions) {
755+
public static String prettyPrintCommands(Iterable<Command> commands) {
756756
StringBuilder result = new StringBuilder();
757-
for (Decision decision : decisions) {
758-
result.append(prettyPrintObject(decision));
757+
for (Command command : commands) {
758+
result.append(prettyPrintObject(command));
759759
}
760760
return result.toString();
761761
}
@@ -791,8 +791,8 @@ private static void fixStackTrace(JsonElement json, String stackIndentation) {
791791
}
792792
}
793793

794-
/** Is this an event that was created to mirror a decision? */
795-
public static boolean isDecisionEvent(HistoryEvent event) {
794+
/** Is this an event that was created to mirror a command? */
795+
public static boolean isCommandEvent(HistoryEvent event) {
796796
EventType eventType = event.getEventType();
797797
boolean result =
798798
((event != null)
@@ -815,36 +815,36 @@ public static boolean isDecisionEvent(HistoryEvent event) {
815815
return result;
816816
}
817817

818-
public static EventType getEventTypeForDecision(DecisionType decisionType) {
819-
switch (decisionType) {
820-
case DECISION_TYPE_SCHEDULE_ACTIVITY_TASK:
818+
public static EventType getEventTypeForCommand(CommandType commandType) {
819+
switch (commandType) {
820+
case COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK:
821821
return EventType.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED;
822-
case DECISION_TYPE_REQUEST_CANCEL_ACTIVITY_TASK:
822+
case COMMAND_TYPE_REQUEST_CANCEL_ACTIVITY_TASK:
823823
return EventType.EVENT_TYPE_ACTIVITY_TASK_CANCEL_REQUESTED;
824-
case DECISION_TYPE_START_TIMER:
824+
case COMMAND_TYPE_START_TIMER:
825825
return EventType.EVENT_TYPE_TIMER_STARTED;
826-
case DECISION_TYPE_COMPLETE_WORKFLOW_EXECUTION:
826+
case COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION:
827827
return EventType.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED;
828-
case DECISION_TYPE_FAIL_WORKFLOW_EXECUTION:
828+
case COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION:
829829
return EventType.EVENT_TYPE_WORKFLOW_EXECUTION_FAILED;
830-
case DECISION_TYPE_CANCEL_TIMER:
830+
case COMMAND_TYPE_CANCEL_TIMER:
831831
return EventType.EVENT_TYPE_TIMER_CANCELED;
832-
case DECISION_TYPE_CANCEL_WORKFLOW_EXECUTION:
832+
case COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION:
833833
return EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED;
834-
case DECISION_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION:
834+
case COMMAND_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION:
835835
return EventType.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED;
836-
case DECISION_TYPE_RECORD_MARKER:
836+
case COMMAND_TYPE_RECORD_MARKER:
837837
return EventType.EVENT_TYPE_MARKER_RECORDED;
838-
case DECISION_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION:
838+
case COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION:
839839
return EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CONTINUED_AS_NEW;
840-
case DECISION_TYPE_START_CHILD_WORKFLOW_EXECUTION:
840+
case COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION:
841841
return EventType.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED;
842-
case DECISION_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION:
842+
case COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION:
843843
return EventType.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED;
844-
case DECISION_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES:
844+
case COMMAND_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES:
845845
return EventType.EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES;
846846
}
847-
throw new IllegalArgumentException("Unknown decisionType");
847+
throw new IllegalArgumentException("Unknown commandType");
848848
}
849849

850850
public static WorkflowExecutionHistory readHistoryFromResource(String resourceFileName)

src/main/java/io/temporal/internal/grpc/GrpcTracingInterceptor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class GrpcTracingInterceptor implements ClientInterceptor {
3636
private static final Logger log = LoggerFactory.getLogger(GrpcTracingInterceptor.class);
3737

3838
/**
39-
* Separate logger for PollForDecisionTask reply which includes history. It is separate to allow
40-
* disabling independently through configuration.
39+
* Separate logger for PollWorkflowTaskQueue reply which includes history. It is separate to allow
40+
* disabling this noisy log independently through configuration.
4141
*/
42-
private static final Logger decision_task_log =
42+
private static final Logger workflow_task_log =
4343
LoggerFactory.getLogger(GrpcTracingInterceptor.class.getName() + ":history");
4444

4545
@Override
@@ -61,9 +61,9 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
6161
@Override
6262
public void onMessage(RespT message) {
6363
// Skip printing the whole history
64-
if (method == WorkflowServiceGrpc.getPollForDecisionTaskMethod()) {
65-
if (decision_task_log.isTraceEnabled()) {
66-
decision_task_log.trace(
64+
if (method == WorkflowServiceGrpc.getPollWorkflowTaskQueueMethod()) {
65+
if (workflow_task_log.isTraceEnabled()) {
66+
workflow_task_log.trace(
6767
"Returned \""
6868
+ method.getServiceName()
6969
+ "\" of \""
@@ -91,6 +91,6 @@ public void onMessage(RespT message) {
9191
}
9292

9393
public boolean isEnabled() {
94-
return log.isTraceEnabled() || decision_task_log.isTraceEnabled();
94+
return log.isTraceEnabled() || workflow_task_log.isTraceEnabled();
9595
}
9696
}

src/main/java/io/temporal/internal/grpc/LongPollUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class LongPollUtil {
2828

2929
static <ReqT, RespT> boolean isLongPoll(
3030
MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) {
31-
if (method == WorkflowServiceGrpc.getPollForDecisionTaskMethod()
32-
|| method == WorkflowServiceGrpc.getPollForActivityTaskMethod()) {
31+
if (method == WorkflowServiceGrpc.getPollWorkflowTaskQueueMethod()
32+
|| method == WorkflowServiceGrpc.getPollActivityTaskQueueMethod()) {
3333
return true;
3434
}
3535
if (method == WorkflowServiceGrpc.getGetWorkflowExecutionHistoryMethod()) {

0 commit comments

Comments
 (0)