Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StateMachine rewrite #172

Merged
merged 31 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
13c2b0f
StateMachine refactoring
mfateev Aug 7, 2020
0c08449
PR feedback and broken unit test
mfateev Aug 8, 2020
250f70d
Fixed workflow task failure reporting
mfateev Aug 8, 2020
68db6c6
WorkflowTaskResult now is created through a Builder
mfateev Aug 8, 2020
1b1254b
StateMachine nomenclature cleanup
mfateev Aug 8, 2020
8243071
Merge branch 'master' of github.com:temporalio/temporal-java-sdk into…
mfateev Aug 9, 2020
4df71d6
initial command refactoring
mfateev Aug 9, 2020
e1e3fa6
Added ActivityStateMachineTest and fixed cancellation failure
mfateev Aug 9, 2020
190f3f1
Added more activity state machine tests
mfateev Aug 9, 2020
f6ed96a
Created StateMachineDefinition
mfateev Aug 10, 2020
f94e9ec
missing final
mfateev Aug 10, 2020
ef3e870
Added state diagram coverage diagram
mfateev Aug 10, 2020
eb1dfd9
100% coverage of ActivityStateMachine
mfateev Aug 10, 2020
24e6d7f
PR comments
mfateev Aug 10, 2020
49713bd
UnsupportedVersion exception. Cleanup
mfateev Aug 10, 2020
8a22826
Updated order of state transition in activity state machine
mfateev Aug 11, 2020
a8ba786
Sort of the PlantUML diagrams
mfateev Aug 11, 2020
5397c17
PR feedback
mfateev Aug 11, 2020
731f902
Added coverage to LocalActivityStateMachineTest
mfateev Aug 11, 2020
088cbcf
Added coverage to versionStateMachineTest
mfateev Aug 11, 2020
0b7bc47
Cancelled->canceled
mfateev Aug 11, 2020
dd642f0
Simplified local activity handling
mfateev Aug 12, 2020
1cc7b0c
allOf, anyOf and iterator
mfateev Aug 12, 2020
abf241c
event loop
mfateev Aug 12, 2020
65ffd00
Refactored ReplayWorkflowExecutor
mfateev Aug 13, 2020
919cad6
Renamed StatefulTaskHandler to WorkflowRunTaskHandler
mfateev Aug 13, 2020
d6918a0
Fixed local activity retries
mfateev Aug 13, 2020
92a3e36
PR comments
mfateev Aug 13, 2020
0a4dc38
PR feedback
mfateev Aug 13, 2020
81a5fb3
Fixed Saga defaults
mfateev Aug 13, 2020
4ddab73
Fixed sticky task and cache invalidation
mfateev Aug 14, 2020
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
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ configurations.all {

license {
header rootProject.file('license-header.txt')
exclude 'io/temporal/proto/**.java' // generated code
exclude '**/*.puml'
}

task initSubmodules(type: Exec) {
Expand Down Expand Up @@ -170,8 +170,8 @@ protobuf {

idea {
module {
sourceDirs += file("$buildDir/generated/main/java");
sourceDirs += file("$buildDir/generated/main/grpc");
sourceDirs += file("$buildDir/generated/main/java")
sourceDirs += file("$buildDir/generated/main/grpc")
}
}

Expand Down Expand Up @@ -327,15 +327,15 @@ allprojects {
// add a testlistener to all tasks of type Test
tasks.withType(Test) {
afterTest { TestDescriptor descriptor, TestResult result ->
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
if (result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE) {
failedTests << ["${descriptor.className}::${descriptor.name}"]
}
}
}

// print out tracked failed tests when the build has finished
gradle.buildFinished {
if(!failedTests.empty){
if (!failedTests.empty) {
println "Failed tests for ${project.name}:"
failedTests.each { failedTest ->
println failedTest
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/temporal/activity/ActivityOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public ActivityOptions validateAndBuildWithDefaults() {
taskQueue,
retryOptions,
contextPropagators,
cancellationType);
cancellationType == null ? ActivityCancellationType.TRY_CANCEL : cancellationType);
mastermanu marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/temporal/client/WorkflowOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ public WorkflowOptions validateBuildWithDefaults() {

private final String taskQueue;

private RetryOptions retryOptions;
private final RetryOptions retryOptions;

private String cronSchedule;
private final String cronSchedule;

private Map<String, Object> memo;
private final Map<String, Object> memo;

private Map<String, Object> searchAttributes;
private final Map<String, Object> searchAttributes;

private List<ContextPropagator> contextPropagators;
private final List<ContextPropagator> contextPropagators;

private WorkflowOptions(
String workflowId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public final class EncodedValues implements Values {
private Optional<Payloads> payloads;
private DataConverter converter;
private Object[] values;
private final Object[] values;

public EncodedValues(Optional<Payloads> payloads, DataConverter converter) {
this.payloads = Objects.requireNonNull(payloads);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,6 @@ void registerSignal(
void upsertSearchAttributes(Map<String, Object> searchAttributes);

Object newThread(Runnable runnable, boolean detached, String name);

long currentTimeMillis();
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ public void upsertSearchAttributes(Map<String, Object> searchAttributes) {
public Object newThread(Runnable runnable, boolean detached, String name) {
return next.newThread(runnable, detached, name);
}

@Override
public long currentTimeMillis() {
return next.currentTimeMillis();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void setDataConverter(DataConverter converter) {
}

private static String getMessage(String message, String type, boolean nonRetryable) {
return (Strings.isNullOrEmpty(message) ? "" : "message='" + message + "\', ")
return (Strings.isNullOrEmpty(message) ? "" : "message='" + message + "', ")
+ "type='"
+ type
+ '\''
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/temporal/failure/CanceledFailure.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import io.temporal.common.converter.DataConverter;
import io.temporal.common.converter.EncodedValues;
import io.temporal.common.converter.Values;
import java.util.Objects;

public final class CanceledFailure extends TemporalFailure {
private final Values details;

public CanceledFailure(String message, Values details, Throwable cause) {
super(message, message, cause);
this.details = details;
this.details = Objects.requireNonNull(details);
}

public CanceledFailure(String message, Object details) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/temporal/failure/FailureConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public class FailureConverter {

private static final Pattern TRACE_ELEMENT_PATTERN = Pattern.compile(TRACE_ELEMENT_REGEXP);

public static Exception failureToException(Failure failure, DataConverter dataConverter) {
public static RuntimeException failureToException(Failure failure, DataConverter dataConverter) {
if (failure == null) {
return null;
}
Exception result = failureToExceptionImpl(failure, dataConverter);
RuntimeException result = failureToExceptionImpl(failure, dataConverter);
if (result instanceof TemporalFailure) {
((TemporalFailure) result).setFailure(failure);
}
Expand All @@ -81,8 +81,9 @@ public static Exception failureToException(Failure failure, DataConverter dataCo
return result;
}

private static Exception failureToExceptionImpl(Failure failure, DataConverter dataConverter) {
Exception cause =
private static RuntimeException failureToExceptionImpl(
Failure failure, DataConverter dataConverter) {
RuntimeException cause =
failure.hasCause() ? failureToException(failure.getCause(), dataConverter) : null;
switch (failure.getFailureInfoCase()) {
case APPLICATION_FAILURE_INFO:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class WorkflowExecutionUtils {

private static final Logger log = LoggerFactory.getLogger(WorkflowExecutionUtils.class);

private static RpcRetryOptions retryParameters =
private static final RpcRetryOptions retryParameters =
RpcRetryOptions.newBuilder()
.setBackoffCoefficient(2)
.setInitialInterval(Duration.ofMillis(500))
Expand Down Expand Up @@ -813,6 +813,7 @@ public static boolean isCommandEvent(HistoryEvent event) {
return result;
}

/** Returns event that corresponds to a command. */
public static EventType getEventTypeForCommand(CommandType commandType) {
switch (commandType) {
case COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK:
Expand All @@ -830,7 +831,7 @@ public static EventType getEventTypeForCommand(CommandType commandType) {
case COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION:
return EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED;
case COMMAND_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION:
return EventType.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED;
return EventType.EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED;
case COMMAND_TYPE_RECORD_MARKER:
return EventType.EVENT_TYPE_MARKER_RECORDED;
case COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/** This class holds the current set of context propagators */
public class ContextThreadLocal {

private static WorkflowThreadLocal<List<ContextPropagator>> contextPropagators =
private static final WorkflowThreadLocal<List<ContextPropagator>> contextPropagators =
WorkflowThreadLocal.withInitial(
new Supplier<List<ContextPropagator>>() {
@Override
Expand Down
Loading