Skip to content

Commit 1d77cea

Browse files
committed
Implement BufferOne CronoverlapPolicy
1 parent 8652ad7 commit 1d77cea

File tree

11 files changed

+599
-7
lines changed

11 files changed

+599
-7
lines changed

src/main/java/com/uber/cadence/client/WorkflowOptions.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public static WorkflowOptions merge(
6464
.setRetryOptions(RetryOptions.merge(methodRetry, o.getRetryOptions()))
6565
.setCronSchedule(OptionsUtils.merge(cronAnnotation, o.getCronSchedule(), String.class))
6666
.setMemo(o.getMemo())
67+
.setCronOverlapPolicy(o.cronOverlapPolicy)
6768
.setSearchAttributes(o.getSearchAttributes())
6869
.setContextPropagators(o.getContextPropagators())
6970
.setDelayStart(o.delayStart)
@@ -86,6 +87,8 @@ public static final class Builder {
8687

8788
private String cronSchedule;
8889

90+
private int cronOverlapPolicy;
91+
8992
private Map<String, Object> memo;
9093

9194
private Map<String, Object> searchAttributes;
@@ -107,6 +110,7 @@ public Builder(WorkflowOptions o) {
107110
this.taskList = o.taskList;
108111
this.retryOptions = o.retryOptions;
109112
this.cronSchedule = o.cronSchedule;
113+
this.cronOverlapPolicy = o.cronOverlapPolicy;
110114
this.memo = o.memo;
111115
this.searchAttributes = o.searchAttributes;
112116
this.contextPropagators = o.contextPropagators;
@@ -194,6 +198,11 @@ public Builder setCronSchedule(String cronSchedule) {
194198
return this;
195199
}
196200

201+
public Builder setCronOverlapPolicy(int cronOverlapPolicy) {
202+
this.cronOverlapPolicy = cronOverlapPolicy;
203+
return this;
204+
}
205+
197206
/**
198207
* Specifies additional non-indexed information in result of list workflow. The type of value
199208
* can be any object that are serializable by {@link com.uber.cadence.converter.DataConverter}
@@ -235,7 +244,8 @@ public WorkflowOptions build() {
235244
memo,
236245
searchAttributes,
237246
contextPropagators,
238-
delayStart);
247+
delayStart,
248+
cronOverlapPolicy);
239249
}
240250

241251
/**
@@ -290,7 +300,8 @@ public WorkflowOptions validateBuildWithDefaults() {
290300
memo,
291301
searchAttributes,
292302
contextPropagators,
293-
delayStart);
303+
delayStart,
304+
cronOverlapPolicy);
294305
}
295306
}
296307

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

309320
private String cronSchedule;
310321

322+
private int cronOverlapPolicy;
323+
311324
private Map<String, Object> memo;
312325

313326
private Map<String, Object> searchAttributes;
@@ -327,7 +340,8 @@ private WorkflowOptions(
327340
Map<String, Object> memo,
328341
Map<String, Object> searchAttributes,
329342
List<ContextPropagator> contextPropagators,
330-
Duration delayStart) {
343+
Duration delayStart,
344+
int cronOverlapPolicy) {
331345
this.workflowId = workflowId;
332346
this.workflowIdReusePolicy = workflowIdReusePolicy;
333347
this.executionStartToCloseTimeout = executionStartToCloseTimeout;
@@ -339,6 +353,7 @@ private WorkflowOptions(
339353
this.searchAttributes = searchAttributes;
340354
this.contextPropagators = contextPropagators;
341355
this.delayStart = delayStart;
356+
this.cronOverlapPolicy = cronOverlapPolicy;
342357
}
343358

344359
public String getWorkflowId() {
@@ -369,6 +384,10 @@ public String getCronSchedule() {
369384
return cronSchedule;
370385
}
371386

387+
public int getCronOverlapPolicy() {
388+
return cronOverlapPolicy;
389+
}
390+
372391
public Map<String, Object> getMemo() {
373392
return memo;
374393
}
@@ -397,6 +416,7 @@ public boolean equals(Object o) {
397416
&& Objects.equals(taskList, that.taskList)
398417
&& Objects.equals(retryOptions, that.retryOptions)
399418
&& Objects.equals(cronSchedule, that.cronSchedule)
419+
&& cronOverlapPolicy == that.cronOverlapPolicy
400420
&& Objects.equals(memo, that.memo)
401421
&& Objects.equals(searchAttributes, that.searchAttributes)
402422
&& Objects.equals(contextPropagators, that.contextPropagators)
@@ -413,6 +433,7 @@ public int hashCode() {
413433
taskList,
414434
retryOptions,
415435
cronSchedule,
436+
cronOverlapPolicy,
416437
memo,
417438
searchAttributes,
418439
contextPropagators,
@@ -439,6 +460,8 @@ public String toString() {
439460
+ ", cronSchedule='"
440461
+ cronSchedule
441462
+ '\''
463+
+ ", cronOverlapPolicy="
464+
+ cronOverlapPolicy
442465
+ ", memo='"
443466
+ memo
444467
+ '\''

src/main/java/com/uber/cadence/internal/common/StartWorkflowExecutionParameters.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public final class StartWorkflowExecutionParameters {
5656

5757
private Duration delayStart;
5858

59+
private int cronOverlapPolicy;
60+
5961
/**
6062
* Returns the value of the WorkflowId property for this object.
6163
*
@@ -317,6 +319,14 @@ public Duration getDelayStart() {
317319
return delayStart;
318320
}
319321

322+
public int getCronOverlapPolicy() {
323+
return cronOverlapPolicy;
324+
}
325+
326+
public void setCronOverlapPolicy(int cronOverlapPolicy) {
327+
this.cronOverlapPolicy = cronOverlapPolicy;
328+
}
329+
320330
public StartWorkflowExecutionParameters withRetryParameters(RetryParameters retryParameters) {
321331
this.retryParameters = retryParameters;
322332
return this;
@@ -352,6 +362,7 @@ public static StartWorkflowExecutionParameters fromWorkflowOptions(WorkflowOptio
352362
if (options.getCronSchedule() != null) {
353363
parameters.setCronSchedule(options.getCronSchedule());
354364
}
365+
parameters.setCronOverlapPolicy(options.getCronOverlapPolicy());
355366
return parameters;
356367
}
357368

@@ -386,6 +397,8 @@ public String toString() {
386397
+ ", cronSchedule='"
387398
+ cronSchedule
388399
+ '\''
400+
+ ", cronOverlapPolicy="
401+
+ cronOverlapPolicy
389402
+ ", memo='"
390403
+ memo
391404
+ '\''
@@ -413,6 +426,7 @@ public boolean equals(Object o) {
413426
&& workflowIdReusePolicy == that.workflowIdReusePolicy
414427
&& Objects.equals(retryParameters, that.retryParameters)
415428
&& Objects.equals(cronSchedule, that.cronSchedule)
429+
&& cronOverlapPolicy == that.cronOverlapPolicy
416430
&& Objects.equals(memo, that.memo)
417431
&& Objects.equals(searchAttributes, that.searchAttributes)
418432
&& Objects.equals(context, that.context)
@@ -431,6 +445,7 @@ public int hashCode() {
431445
workflowIdReusePolicy,
432446
retryParameters,
433447
cronSchedule,
448+
cronOverlapPolicy,
434449
memo,
435450
searchAttributes,
436451
context,
@@ -452,6 +467,7 @@ public StartWorkflowExecutionParameters copy() {
452467
result.setRetryParameters(retryParameters.copy());
453468
}
454469
result.setCronSchedule(cronSchedule);
470+
result.setCronOverlapPolicy(cronOverlapPolicy);
455471
result.setMemo(memo);
456472
result.setSearchAttributes(searchAttributes);
457473
result.setContext(context);

src/main/java/com/uber/cadence/internal/compatibility/proto/DecisionMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ static Decision decision(com.uber.cadence.Decision d) {
194194
if (attr.getCronSchedule() != null) {
195195
builder.setCronSchedule(attr.getCronSchedule());
196196
}
197+
// cronOverlapPolicy not mapped in proto path yet
197198
decision.setContinueAsNewWorkflowExecutionDecisionAttributes(builder);
198199
}
199200
break;
@@ -226,6 +227,7 @@ static Decision decision(com.uber.cadence.Decision d) {
226227
if (attr.getCronSchedule() != null) {
227228
builder.setCronSchedule(attr.getCronSchedule());
228229
}
230+
// cronOverlapPolicy not mapped in proto path yet
229231
decision.setStartChildWorkflowExecutionDecisionAttributes(builder);
230232
}
231233
break;

src/main/java/com/uber/cadence/internal/compatibility/proto/RequestMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ public static StartWorkflowExecutionRequest startWorkflowExecutionRequest(
545545
if (t.getCronSchedule() != null) {
546546
request.setCronSchedule(t.getCronSchedule());
547547
}
548+
// cronOverlapPolicy not mapped in proto path yet
548549
if (t.getIdentity() != null) {
549550
request.setIdentity(t.getIdentity());
550551
}

src/main/java/com/uber/cadence/internal/external/GenericWorkflowClientExternalImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ private StartWorkflowExecutionRequest getStartRequest(
275275
if (!Strings.isNullOrEmpty(startParameters.getCronSchedule())) {
276276
request.setCronSchedule(startParameters.getCronSchedule());
277277
}
278+
// cronOverlapPolicy not supported in thrift request yet
278279
request.setMemo(toMemoThrift(startParameters.getMemo()));
279280
request.setSearchAttributes(toSearchAttributesThrift(startParameters.getSearchAttributes()));
280281
request.setHeader(toHeaderThrift(startParameters.getContext()));
@@ -504,6 +505,7 @@ private SignalWithStartWorkflowExecutionRequest createSignalWithStartRequest(
504505
if (!Strings.isNullOrEmpty(startParameters.getCronSchedule())) {
505506
request.setCronSchedule(startParameters.getCronSchedule());
506507
}
508+
// cronOverlapPolicy not supported in thrift request yet
507509
if (startParameters.getDelayStart() != null) {
508510
request.setDelayStartSeconds((int) startParameters.getDelayStart().getSeconds());
509511
}

src/main/java/com/uber/cadence/internal/replay/StartChildWorkflowExecutionParameters.java

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public static final class Builder {
5151

5252
private String cronSchedule;
5353

54+
private int cronOverlapPolicy;
55+
5456
private Map<String, Object> memo;
5557

5658
private Map<String, Object> searchAttributes;
@@ -115,6 +117,11 @@ public Builder setCronSchedule(String cronSchedule) {
115117
return this;
116118
}
117119

120+
public Builder setCronOverlapPolicy(int cronOverlapPolicy) {
121+
this.cronOverlapPolicy = cronOverlapPolicy;
122+
return this;
123+
}
124+
118125
public Builder setMemo(Map<String, Object> memo) {
119126
this.memo = memo;
120127
return this;
@@ -148,6 +155,7 @@ public StartChildWorkflowExecutionParameters build() {
148155
workflowIdReusePolicy,
149156
retryParameters,
150157
cronSchedule,
158+
cronOverlapPolicy,
151159
memo,
152160
searchAttributes,
153161
context,
@@ -177,6 +185,8 @@ public StartChildWorkflowExecutionParameters build() {
177185

178186
private final String cronSchedule;
179187

188+
private final int cronOverlapPolicy;
189+
180190
private Map<String, Object> memo;
181191

182192
private Map<String, Object> searchAttributes;
@@ -197,6 +207,7 @@ private StartChildWorkflowExecutionParameters(
197207
WorkflowIdReusePolicy workflowIdReusePolicy,
198208
RetryParameters retryParameters,
199209
String cronSchedule,
210+
int cronOverlapPolicy,
200211
Map<String, Object> memo,
201212
Map<String, Object> searchAttributes,
202213
Map<String, byte[]> context,
@@ -212,6 +223,7 @@ private StartChildWorkflowExecutionParameters(
212223
this.workflowIdReusePolicy = workflowIdReusePolicy;
213224
this.retryParameters = retryParameters;
214225
this.cronSchedule = cronSchedule;
226+
this.cronOverlapPolicy = cronOverlapPolicy;
215227
this.memo = memo;
216228
this.searchAttributes = searchAttributes;
217229
this.context = context;
@@ -262,6 +274,10 @@ public String getCronSchedule() {
262274
return cronSchedule;
263275
}
264276

277+
public int getCronOverlapPolicy() {
278+
return cronOverlapPolicy;
279+
}
280+
265281
public Map<String, Object> getMemo() {
266282
return memo;
267283
}
@@ -278,6 +294,28 @@ public ParentClosePolicy getParentClosePolicy() {
278294
return parentClosePolicy;
279295
}
280296

297+
public StartChildWorkflowExecutionParameters copy() {
298+
StartChildWorkflowExecutionParameters result =
299+
new StartChildWorkflowExecutionParameters(
300+
domain,
301+
input,
302+
control,
303+
executionStartToCloseTimeoutSeconds,
304+
taskList,
305+
taskStartToCloseTimeoutSeconds,
306+
workflowId,
307+
workflowType,
308+
workflowIdReusePolicy,
309+
retryParameters,
310+
cronSchedule,
311+
cronOverlapPolicy,
312+
memo,
313+
searchAttributes,
314+
context,
315+
parentClosePolicy);
316+
return result;
317+
}
318+
281319
@Override
282320
public boolean equals(Object o) {
283321
if (this == o) return true;
@@ -286,18 +324,19 @@ public boolean equals(Object o) {
286324
return executionStartToCloseTimeoutSeconds == that.executionStartToCloseTimeoutSeconds
287325
&& taskStartToCloseTimeoutSeconds == that.taskStartToCloseTimeoutSeconds
288326
&& Objects.equals(domain, that.domain)
289-
&& Objects.equals(control, that.control)
290327
&& Arrays.equals(input, that.input)
328+
&& Objects.equals(control, that.control)
291329
&& Objects.equals(taskList, that.taskList)
292330
&& Objects.equals(workflowId, that.workflowId)
293331
&& Objects.equals(workflowType, that.workflowType)
294332
&& workflowIdReusePolicy == that.workflowIdReusePolicy
295333
&& Objects.equals(retryParameters, that.retryParameters)
296334
&& Objects.equals(cronSchedule, that.cronSchedule)
335+
&& cronOverlapPolicy == that.cronOverlapPolicy
297336
&& Objects.equals(memo, that.memo)
298337
&& Objects.equals(searchAttributes, that.searchAttributes)
299338
&& Objects.equals(context, that.context)
300-
&& Objects.equals(parentClosePolicy, that.parentClosePolicy);
339+
&& parentClosePolicy == that.parentClosePolicy;
301340
}
302341

303342
@Override
@@ -314,6 +353,7 @@ public int hashCode() {
314353
workflowIdReusePolicy,
315354
retryParameters,
316355
cronSchedule,
356+
cronOverlapPolicy,
317357
memo,
318358
searchAttributes,
319359
context,
@@ -349,13 +389,16 @@ public String toString() {
349389
+ workflowIdReusePolicy
350390
+ ", retryParameters="
351391
+ retryParameters
352-
+ ", cronSchedule="
392+
+ ", cronSchedule='"
353393
+ cronSchedule
394+
+ '\''
395+
+ ", cronOverlapPolicy="
396+
+ cronOverlapPolicy
354397
+ ", memo="
355398
+ memo
356399
+ ", searchAttributes="
357400
+ searchAttributes
358-
+ ", context='"
401+
+ ", context="
359402
+ context
360403
+ ", parentClosePolicy="
361404
+ parentClosePolicy

src/main/java/com/uber/cadence/internal/sync/SyncDecisionContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ private Promise<byte[]> executeChildWorkflowOnce(
460460
.setWorkflowIdReusePolicy(options.getWorkflowIdReusePolicy())
461461
.setRetryParameters(retryParameters)
462462
.setCronSchedule(options.getCronSchedule())
463+
.setCronOverlapPolicy(options.getCronOverlapPolicy())
463464
.setMemo(options.getMemo())
464465
.setSearchAttributes(options.getSearchAttributes())
465466
.setContext(extractContextsAndConvertToBytes(propagators))

0 commit comments

Comments
 (0)