Skip to content

Add CronoverlapPolicy support to java client #1018

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
29 changes: 26 additions & 3 deletions src/main/java/com/uber/cadence/client/WorkflowOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static WorkflowOptions merge(
.setRetryOptions(RetryOptions.merge(methodRetry, o.getRetryOptions()))
.setCronSchedule(OptionsUtils.merge(cronAnnotation, o.getCronSchedule(), String.class))
.setMemo(o.getMemo())
.setCronOverlapPolicy(o.cronOverlapPolicy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use getter

.setSearchAttributes(o.getSearchAttributes())
.setContextPropagators(o.getContextPropagators())
.setDelayStart(o.delayStart)
Expand All @@ -86,6 +87,8 @@ public static final class Builder {

private String cronSchedule;

private int cronOverlapPolicy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use thrift entity similar to WorkflowIdReusePolicy


private Map<String, Object> memo;

private Map<String, Object> searchAttributes;
Expand All @@ -107,6 +110,7 @@ public Builder(WorkflowOptions o) {
this.taskList = o.taskList;
this.retryOptions = o.retryOptions;
this.cronSchedule = o.cronSchedule;
this.cronOverlapPolicy = o.cronOverlapPolicy;
this.memo = o.memo;
this.searchAttributes = o.searchAttributes;
this.contextPropagators = o.contextPropagators;
Expand Down Expand Up @@ -194,6 +198,11 @@ public Builder setCronSchedule(String cronSchedule) {
return this;
}

public Builder setCronOverlapPolicy(int cronOverlapPolicy) {
this.cronOverlapPolicy = cronOverlapPolicy;
return this;
}

/**
* Specifies additional non-indexed information in result of list workflow. The type of value
* can be any object that are serializable by {@link com.uber.cadence.converter.DataConverter}
Expand Down Expand Up @@ -235,7 +244,8 @@ public WorkflowOptions build() {
memo,
searchAttributes,
contextPropagators,
delayStart);
delayStart,
cronOverlapPolicy);
}

/**
Expand Down Expand Up @@ -290,7 +300,8 @@ public WorkflowOptions validateBuildWithDefaults() {
memo,
searchAttributes,
contextPropagators,
delayStart);
delayStart,
cronOverlapPolicy);
}
}

Expand All @@ -308,6 +319,8 @@ public WorkflowOptions validateBuildWithDefaults() {

private String cronSchedule;

private int cronOverlapPolicy;

private Map<String, Object> memo;

private Map<String, Object> searchAttributes;
Expand All @@ -327,7 +340,8 @@ private WorkflowOptions(
Map<String, Object> memo,
Map<String, Object> searchAttributes,
List<ContextPropagator> contextPropagators,
Duration delayStart) {
Duration delayStart,
int cronOverlapPolicy) {
this.workflowId = workflowId;
this.workflowIdReusePolicy = workflowIdReusePolicy;
this.executionStartToCloseTimeout = executionStartToCloseTimeout;
Expand All @@ -339,6 +353,7 @@ private WorkflowOptions(
this.searchAttributes = searchAttributes;
this.contextPropagators = contextPropagators;
this.delayStart = delayStart;
this.cronOverlapPolicy = cronOverlapPolicy;
}

public String getWorkflowId() {
Expand Down Expand Up @@ -369,6 +384,10 @@ public String getCronSchedule() {
return cronSchedule;
}

public int getCronOverlapPolicy() {
return cronOverlapPolicy;
}

public Map<String, Object> getMemo() {
return memo;
}
Expand Down Expand Up @@ -397,6 +416,7 @@ public boolean equals(Object o) {
&& Objects.equals(taskList, that.taskList)
&& Objects.equals(retryOptions, that.retryOptions)
&& Objects.equals(cronSchedule, that.cronSchedule)
&& cronOverlapPolicy == that.cronOverlapPolicy
&& Objects.equals(memo, that.memo)
&& Objects.equals(searchAttributes, that.searchAttributes)
&& Objects.equals(contextPropagators, that.contextPropagators)
Expand All @@ -413,6 +433,7 @@ public int hashCode() {
taskList,
retryOptions,
cronSchedule,
cronOverlapPolicy,
memo,
searchAttributes,
contextPropagators,
Expand All @@ -439,6 +460,8 @@ public String toString() {
+ ", cronSchedule='"
+ cronSchedule
+ '\''
+ ", cronOverlapPolicy="
+ cronOverlapPolicy
+ ", memo='"
+ memo
+ '\''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public final class StartWorkflowExecutionParameters {

private Duration delayStart;

private int cronOverlapPolicy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use thrift entity


/**
* Returns the value of the WorkflowId property for this object.
*
Expand Down Expand Up @@ -317,6 +319,14 @@ public Duration getDelayStart() {
return delayStart;
}

public int getCronOverlapPolicy() {
return cronOverlapPolicy;
}

public void setCronOverlapPolicy(int cronOverlapPolicy) {
this.cronOverlapPolicy = cronOverlapPolicy;
}

public StartWorkflowExecutionParameters withRetryParameters(RetryParameters retryParameters) {
this.retryParameters = retryParameters;
return this;
Expand Down Expand Up @@ -352,6 +362,7 @@ public static StartWorkflowExecutionParameters fromWorkflowOptions(WorkflowOptio
if (options.getCronSchedule() != null) {
parameters.setCronSchedule(options.getCronSchedule());
}
parameters.setCronOverlapPolicy(options.getCronOverlapPolicy());
return parameters;
}

Expand Down Expand Up @@ -386,6 +397,8 @@ public String toString() {
+ ", cronSchedule='"
+ cronSchedule
+ '\''
+ ", cronOverlapPolicy="
+ cronOverlapPolicy
+ ", memo='"
+ memo
+ '\''
Expand Down Expand Up @@ -413,6 +426,7 @@ public boolean equals(Object o) {
&& workflowIdReusePolicy == that.workflowIdReusePolicy
&& Objects.equals(retryParameters, that.retryParameters)
&& Objects.equals(cronSchedule, that.cronSchedule)
&& cronOverlapPolicy == that.cronOverlapPolicy
&& Objects.equals(memo, that.memo)
&& Objects.equals(searchAttributes, that.searchAttributes)
&& Objects.equals(context, that.context)
Expand All @@ -431,6 +445,7 @@ public int hashCode() {
workflowIdReusePolicy,
retryParameters,
cronSchedule,
cronOverlapPolicy,
memo,
searchAttributes,
context,
Expand All @@ -452,6 +467,7 @@ public StartWorkflowExecutionParameters copy() {
result.setRetryParameters(retryParameters.copy());
}
result.setCronSchedule(cronSchedule);
result.setCronOverlapPolicy(cronOverlapPolicy);
result.setMemo(memo);
result.setSearchAttributes(searchAttributes);
result.setContext(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static final class Builder {

private String cronSchedule;

private int cronOverlapPolicy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use thrift entity


private Map<String, Object> memo;

private Map<String, Object> searchAttributes;
Expand Down Expand Up @@ -115,6 +117,11 @@ public Builder setCronSchedule(String cronSchedule) {
return this;
}

public Builder setCronOverlapPolicy(int cronOverlapPolicy) {
this.cronOverlapPolicy = cronOverlapPolicy;
return this;
}

public Builder setMemo(Map<String, Object> memo) {
this.memo = memo;
return this;
Expand Down Expand Up @@ -148,6 +155,7 @@ public StartChildWorkflowExecutionParameters build() {
workflowIdReusePolicy,
retryParameters,
cronSchedule,
cronOverlapPolicy,
memo,
searchAttributes,
context,
Expand Down Expand Up @@ -177,6 +185,8 @@ public StartChildWorkflowExecutionParameters build() {

private final String cronSchedule;

private final int cronOverlapPolicy;

private Map<String, Object> memo;

private Map<String, Object> searchAttributes;
Expand All @@ -197,6 +207,7 @@ private StartChildWorkflowExecutionParameters(
WorkflowIdReusePolicy workflowIdReusePolicy,
RetryParameters retryParameters,
String cronSchedule,
int cronOverlapPolicy,
Map<String, Object> memo,
Map<String, Object> searchAttributes,
Map<String, byte[]> context,
Expand All @@ -212,6 +223,7 @@ private StartChildWorkflowExecutionParameters(
this.workflowIdReusePolicy = workflowIdReusePolicy;
this.retryParameters = retryParameters;
this.cronSchedule = cronSchedule;
this.cronOverlapPolicy = cronOverlapPolicy;
this.memo = memo;
this.searchAttributes = searchAttributes;
this.context = context;
Expand Down Expand Up @@ -262,6 +274,10 @@ public String getCronSchedule() {
return cronSchedule;
}

public int getCronOverlapPolicy() {
return cronOverlapPolicy;
}

public Map<String, Object> getMemo() {
return memo;
}
Expand All @@ -278,6 +294,28 @@ public ParentClosePolicy getParentClosePolicy() {
return parentClosePolicy;
}

public StartChildWorkflowExecutionParameters copy() {
StartChildWorkflowExecutionParameters result =
new StartChildWorkflowExecutionParameters(
domain,
input,
control,
executionStartToCloseTimeoutSeconds,
taskList,
taskStartToCloseTimeoutSeconds,
workflowId,
workflowType,
workflowIdReusePolicy,
retryParameters,
cronSchedule,
cronOverlapPolicy,
memo,
searchAttributes,
context,
parentClosePolicy);
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -286,18 +324,19 @@ public boolean equals(Object o) {
return executionStartToCloseTimeoutSeconds == that.executionStartToCloseTimeoutSeconds
&& taskStartToCloseTimeoutSeconds == that.taskStartToCloseTimeoutSeconds
&& Objects.equals(domain, that.domain)
&& Objects.equals(control, that.control)
&& Arrays.equals(input, that.input)
&& Objects.equals(control, that.control)
&& Objects.equals(taskList, that.taskList)
&& Objects.equals(workflowId, that.workflowId)
&& Objects.equals(workflowType, that.workflowType)
&& workflowIdReusePolicy == that.workflowIdReusePolicy
&& Objects.equals(retryParameters, that.retryParameters)
&& Objects.equals(cronSchedule, that.cronSchedule)
&& cronOverlapPolicy == that.cronOverlapPolicy
&& Objects.equals(memo, that.memo)
&& Objects.equals(searchAttributes, that.searchAttributes)
&& Objects.equals(context, that.context)
&& Objects.equals(parentClosePolicy, that.parentClosePolicy);
&& parentClosePolicy == that.parentClosePolicy;
}

@Override
Expand All @@ -314,6 +353,7 @@ public int hashCode() {
workflowIdReusePolicy,
retryParameters,
cronSchedule,
cronOverlapPolicy,
memo,
searchAttributes,
context,
Expand Down Expand Up @@ -349,13 +389,16 @@ public String toString() {
+ workflowIdReusePolicy
+ ", retryParameters="
+ retryParameters
+ ", cronSchedule="
+ ", cronSchedule='"
+ cronSchedule
+ '\''
+ ", cronOverlapPolicy="
+ cronOverlapPolicy
+ ", memo="
+ memo
+ ", searchAttributes="
+ searchAttributes
+ ", context='"
+ ", context="
+ context
+ ", parentClosePolicy="
+ parentClosePolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ private Promise<byte[]> executeChildWorkflowOnce(
.setWorkflowIdReusePolicy(options.getWorkflowIdReusePolicy())
.setRetryParameters(retryParameters)
.setCronSchedule(options.getCronSchedule())
.setCronOverlapPolicy(options.getCronOverlapPolicy())
.setMemo(options.getMemo())
.setSearchAttributes(options.getSearchAttributes())
.setContext(extractContextsAndConvertToBytes(propagators))
Expand Down
Loading