Skip to content

Commit 13d4daf

Browse files
committed
Remove unused code from cadence.internal package
1 parent c6891e2 commit 13d4daf

10 files changed

+0
-303
lines changed

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

Lines changed: 0 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -389,42 +389,6 @@ public static boolean isWorkflowExecutionCompleteDecision(Decision decision) {
389389
|| decision.getDecisionType() == DecisionType.ContinueAsNewWorkflowExecution));
390390
}
391391

392-
public static boolean isActivityTaskClosedEvent(HistoryEvent event) {
393-
return ((event != null)
394-
&& (event.getEventType() == EventType.ActivityTaskCompleted
395-
|| event.getEventType() == EventType.ActivityTaskCanceled
396-
|| event.getEventType() == EventType.ActivityTaskFailed
397-
|| event.getEventType() == EventType.ActivityTaskTimedOut));
398-
}
399-
400-
public static boolean isExternalWorkflowClosedEvent(HistoryEvent event) {
401-
return ((event != null)
402-
&& (event.getEventType() == EventType.ChildWorkflowExecutionCompleted
403-
|| event.getEventType() == EventType.ChildWorkflowExecutionCanceled
404-
|| event.getEventType() == EventType.ChildWorkflowExecutionFailed
405-
|| event.getEventType() == EventType.ChildWorkflowExecutionTerminated
406-
|| event.getEventType() == EventType.ChildWorkflowExecutionTimedOut));
407-
}
408-
409-
public static WorkflowExecution getWorkflowIdFromExternalWorkflowCompletedEvent(
410-
HistoryEvent event) {
411-
if (event != null) {
412-
if (event.getEventType() == EventType.ChildWorkflowExecutionCompleted) {
413-
return event.getChildWorkflowExecutionCompletedEventAttributes().getWorkflowExecution();
414-
} else if (event.getEventType() == EventType.ChildWorkflowExecutionCanceled) {
415-
return event.getChildWorkflowExecutionCanceledEventAttributes().getWorkflowExecution();
416-
} else if (event.getEventType() == EventType.ChildWorkflowExecutionFailed) {
417-
return event.getChildWorkflowExecutionFailedEventAttributes().getWorkflowExecution();
418-
} else if (event.getEventType() == EventType.ChildWorkflowExecutionTerminated) {
419-
return event.getChildWorkflowExecutionTerminatedEventAttributes().getWorkflowExecution();
420-
} else if (event.getEventType() == EventType.ChildWorkflowExecutionTimedOut) {
421-
return event.getChildWorkflowExecutionTimedOutEventAttributes().getWorkflowExecution();
422-
}
423-
}
424-
425-
return null;
426-
}
427-
428392
public static String getId(HistoryEvent historyEvent) {
429393
String id = null;
430394
if (historyEvent != null) {
@@ -436,67 +400,6 @@ public static String getId(HistoryEvent historyEvent) {
436400
return id;
437401
}
438402

439-
public static String getFailureCause(HistoryEvent historyEvent) {
440-
String failureCause = null;
441-
if (historyEvent != null) {
442-
if (historyEvent.getEventType() == EventType.StartChildWorkflowExecutionFailed) {
443-
failureCause =
444-
historyEvent
445-
.getStartChildWorkflowExecutionFailedEventAttributes()
446-
.getCause()
447-
.toString();
448-
// } else if (historyEvent.getEventType() ==
449-
// EventType.SignalExternalWorkflowExecutionFailed) {
450-
// failureCause =
451-
// historyEvent.getSignalExternalWorkflowExecutionFailedEventAttributes().getCause();
452-
} else {
453-
failureCause = "Cannot extract failure cause from " + historyEvent.getEventType();
454-
}
455-
}
456-
457-
return failureCause;
458-
}
459-
460-
/**
461-
* Blocks until workflow instance completes. <strong>Never</strong> use in production setting as
462-
* polling for worklow instance status is an expensive operation.
463-
*
464-
* @param workflowExecution result of {@link
465-
* IWorkflowService#StartWorkflowExecution(StartWorkflowExecutionRequest)}
466-
* @return instance close status
467-
*/
468-
public static WorkflowExecutionCloseStatus waitForWorkflowInstanceCompletion(
469-
IWorkflowService service, String domain, WorkflowExecution workflowExecution)
470-
throws EntityNotExistsError {
471-
try {
472-
return waitForWorkflowInstanceCompletion(
473-
service, domain, workflowExecution, 0, TimeUnit.MILLISECONDS);
474-
} catch (TimeoutException e) {
475-
throw new Error("should never happen", e);
476-
}
477-
}
478-
479-
/**
480-
* Waits up to specified timeout for workflow instance completion. <strong>Never</strong> use in
481-
* production setting as polling for worklow instance status is an expensive operation.
482-
*
483-
* @param workflowExecution result of {@link
484-
* IWorkflowService#StartWorkflowExecution(StartWorkflowExecutionRequest)}
485-
* @param timeout maximum time to wait for completion. 0 means wait forever.
486-
* @return instance close status
487-
*/
488-
public static WorkflowExecutionCloseStatus waitForWorkflowInstanceCompletion(
489-
IWorkflowService service,
490-
String domain,
491-
WorkflowExecution workflowExecution,
492-
long timeout,
493-
TimeUnit unit)
494-
throws TimeoutException, EntityNotExistsError {
495-
HistoryEvent closeEvent =
496-
getInstanceCloseEvent(service, domain, workflowExecution, timeout, unit);
497-
return getCloseStatus(closeEvent);
498-
}
499-
500403
public static WorkflowExecutionCloseStatus getCloseStatus(HistoryEvent event) {
501404
switch (event.getEventType()) {
502405
case WorkflowExecutionCanceled:
@@ -516,88 +419,6 @@ public static WorkflowExecutionCloseStatus getCloseStatus(HistoryEvent event) {
516419
}
517420
}
518421

519-
/**
520-
* Like {@link #waitForWorkflowInstanceCompletion(IWorkflowService, String, WorkflowExecution,
521-
* long, TimeUnit)} , except will wait for continued generations of the original workflow
522-
* execution too.
523-
*
524-
* @see #waitForWorkflowInstanceCompletion(IWorkflowService, String, WorkflowExecution, long,
525-
* TimeUnit)
526-
*/
527-
public static WorkflowExecutionCloseStatus waitForWorkflowInstanceCompletionAcrossGenerations(
528-
IWorkflowService service,
529-
String domain,
530-
WorkflowExecution workflowExecution,
531-
long timeout,
532-
TimeUnit unit)
533-
throws TimeoutException, EntityNotExistsError {
534-
535-
WorkflowExecution lastExecutionToRun = workflowExecution;
536-
long millisecondsAtFirstWait = System.currentTimeMillis();
537-
WorkflowExecutionCloseStatus lastExecutionToRunCloseStatus =
538-
waitForWorkflowInstanceCompletion(service, domain, lastExecutionToRun, timeout, unit);
539-
540-
// keep waiting if the instance continued as new
541-
while (lastExecutionToRunCloseStatus == WorkflowExecutionCloseStatus.CONTINUED_AS_NEW) {
542-
// get the new execution's information
543-
HistoryEvent closeEvent =
544-
getInstanceCloseEvent(service, domain, lastExecutionToRun, timeout, unit);
545-
WorkflowExecutionContinuedAsNewEventAttributes continuedAsNewAttributes =
546-
closeEvent.getWorkflowExecutionContinuedAsNewEventAttributes();
547-
548-
WorkflowExecution newGenerationExecution = new WorkflowExecution();
549-
newGenerationExecution.setRunId(continuedAsNewAttributes.getNewExecutionRunId());
550-
newGenerationExecution.setWorkflowId(lastExecutionToRun.getWorkflowId());
551-
552-
// and wait for it
553-
long currentTime = System.currentTimeMillis();
554-
long millisecondsSinceFirstWait = currentTime - millisecondsAtFirstWait;
555-
long timeoutInSecondsForNextWait =
556-
unit.toMillis(timeout) - (millisecondsSinceFirstWait / 1000L);
557-
558-
lastExecutionToRunCloseStatus =
559-
waitForWorkflowInstanceCompletion(
560-
service,
561-
domain,
562-
newGenerationExecution,
563-
timeoutInSecondsForNextWait,
564-
TimeUnit.MILLISECONDS);
565-
lastExecutionToRun = newGenerationExecution;
566-
}
567-
568-
return lastExecutionToRunCloseStatus;
569-
}
570-
571-
/**
572-
* Like {@link #waitForWorkflowInstanceCompletion(IWorkflowService, String, WorkflowExecution,
573-
* long, TimeUnit)} , but with no timeout.*
574-
*/
575-
public static WorkflowExecutionCloseStatus waitForWorkflowInstanceCompletionAcrossGenerations(
576-
IWorkflowService service, String domain, WorkflowExecution workflowExecution)
577-
throws InterruptedException, EntityNotExistsError {
578-
try {
579-
return waitForWorkflowInstanceCompletionAcrossGenerations(
580-
service, domain, workflowExecution, 0L, TimeUnit.MILLISECONDS);
581-
} catch (TimeoutException e) {
582-
throw new Error("should never happen", e);
583-
}
584-
}
585-
586-
public static WorkflowExecutionInfo describeWorkflowInstance(
587-
IWorkflowService service, String domain, WorkflowExecution workflowExecution) {
588-
DescribeWorkflowExecutionRequest describeRequest = new DescribeWorkflowExecutionRequest();
589-
describeRequest.setDomain(domain);
590-
describeRequest.setExecution(workflowExecution);
591-
DescribeWorkflowExecutionResponse executionDetail = null;
592-
try {
593-
executionDetail = service.DescribeWorkflowExecution(describeRequest);
594-
} catch (TException e) {
595-
throw new RuntimeException(e);
596-
}
597-
WorkflowExecutionInfo instanceMetadata = executionDetail.getWorkflowExecutionInfo();
598-
return instanceMetadata;
599-
}
600-
601422
public static GetWorkflowExecutionHistoryResponse getHistoryPage(
602423
byte[] nextPageToken,
603424
IWorkflowService service,
@@ -621,26 +442,6 @@ public static GetWorkflowExecutionHistoryResponse getHistoryPage(
621442
return history;
622443
}
623444

624-
/** Returns workflow instance history in a human readable format. */
625-
public static String prettyPrintHistory(
626-
IWorkflowService service, String domain, WorkflowExecution workflowExecution) {
627-
return prettyPrintHistory(service, domain, workflowExecution, true);
628-
}
629-
/**
630-
* Returns workflow instance history in a human readable format.
631-
*
632-
* @param showWorkflowTasks when set to false workflow task events (decider events) are not
633-
* included
634-
*/
635-
public static String prettyPrintHistory(
636-
IWorkflowService service,
637-
String domain,
638-
WorkflowExecution workflowExecution,
639-
boolean showWorkflowTasks) {
640-
Iterator<HistoryEvent> events = getHistory(service, domain, workflowExecution);
641-
return prettyPrintHistory(events, showWorkflowTasks);
642-
}
643-
644445
public static Iterator<HistoryEvent> getHistory(
645446
IWorkflowService service, String domain, WorkflowExecution workflowExecution) {
646447
return new Iterator<HistoryEvent>() {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ public ActivityDecisionStateMachine(
3333
this.scheduleAttributes = scheduleAttributes;
3434
}
3535

36-
/** Used for unit testing */
37-
ActivityDecisionStateMachine(
38-
DecisionId id,
39-
ScheduleActivityTaskDecisionAttributes scheduleAttributes,
40-
DecisionState state) {
41-
super(id, state);
42-
this.scheduleAttributes = scheduleAttributes;
43-
}
44-
4536
@Override
4637
public Decision getDecision() {
4738
switch (state) {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ public ChildWorkflowDecisionStateMachine(
3333
this.startAttributes = startAttributes;
3434
}
3535

36-
/** Used for unit testing */
37-
ChildWorkflowDecisionStateMachine(
38-
DecisionId id,
39-
StartChildWorkflowExecutionDecisionAttributes startAttributes,
40-
DecisionState state) {
41-
super(id, state);
42-
this.startAttributes = startAttributes;
43-
}
44-
4536
@Override
4637
public Decision getDecision() {
4738
switch (state) {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ public SignalDecisionStateMachine(
3434
this.attributes = attributes;
3535
}
3636

37-
/** Used for unit testing */
38-
SignalDecisionStateMachine(
39-
DecisionId id,
40-
SignalExternalWorkflowExecutionDecisionAttributes attributes,
41-
DecisionState state) {
42-
super(id, state);
43-
this.attributes = attributes;
44-
}
45-
4637
@Override
4738
public Decision getDecision() {
4839
switch (state) {

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ public TimerDecisionStateMachine(DecisionId id, StartTimerDecisionAttributes att
4141
this.attributes = attributes;
4242
}
4343

44-
/** Used for unit testing */
45-
TimerDecisionStateMachine(
46-
DecisionId id, StartTimerDecisionAttributes attributes, DecisionState state) {
47-
super(id, state);
48-
this.attributes = attributes;
49-
}
50-
5144
@Override
5245
public Decision getDecision() {
5346
switch (state) {

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ final class SimulatedTimeoutExceptionInternal extends RuntimeException {
3434
this.details = details;
3535
}
3636

37-
SimulatedTimeoutExceptionInternal(TimeoutType timeoutType) {
38-
this.timeoutType = timeoutType;
39-
this.details = null;
40-
}
41-
4237
TimeoutType getTimeoutType() {
4338
return timeoutType;
4439
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,6 @@ public boolean isSuspended() {
224224
return workflowWorker.isSuspended() && laWorker.isSuspended() && ldaWorker.isSuspended();
225225
}
226226

227-
public <R> R queryWorkflowExecution(
228-
WorkflowExecution execution,
229-
String queryType,
230-
Class<R> resultClass,
231-
Type resultType,
232-
Object[] args)
233-
throws Exception {
234-
byte[] serializedArgs = dataConverter.toData(args);
235-
byte[] result = workflowWorker.queryWorkflowExecution(execution, queryType, serializedArgs);
236-
return dataConverter.fromData(result, resultClass, resultType);
237-
}
238-
239227
public <R> R queryWorkflowExecution(
240228
WorkflowExecutionHistory history,
241229
String queryType,

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public static WorkflowThread newThread(boolean ignoreParentCancellation, Runnabl
7070
return WorkflowThread.newThread(runnable, ignoreParentCancellation);
7171
}
7272

73-
public static WorkflowThread newThread(
74-
boolean ignoreParentCancellation, String name, Runnable runnable) {
75-
if (name == null) {
76-
throw new NullPointerException("name cannot be null");
77-
}
78-
return WorkflowThread.newThread(runnable, ignoreParentCancellation, name);
79-
}
80-
8173
public static Promise<Void> newTimer(Duration duration) {
8274
return getWorkflowInterceptor().newTimer(duration);
8375
}
@@ -228,26 +220,6 @@ public static <T> T newContinueAsNewStub(
228220
new ContinueAsNewWorkflowInvocationHandler(options, getWorkflowInterceptor()));
229221
}
230222

231-
/**
232-
* Execute activity by name.
233-
*
234-
* @param name name of the activity
235-
* @param resultClass activity return type
236-
* @param args list of activity arguments
237-
* @param <R> activity return type
238-
* @return activity result
239-
*/
240-
public static <R> R executeActivity(
241-
String name, ActivityOptions options, Class<R> resultClass, Type resultType, Object... args) {
242-
Promise<R> result =
243-
getWorkflowInterceptor().executeActivity(name, resultClass, resultType, args, options);
244-
if (AsyncInternal.isAsync()) {
245-
AsyncInternal.setAsyncResult(result);
246-
return null; // ignored
247-
}
248-
return result.get();
249-
}
250-
251223
private static WorkflowInterceptor getWorkflowInterceptor() {
252224
return DeterministicRunnerImpl.currentThreadInternal()
253225
.getDecisionContext()
@@ -347,10 +319,6 @@ public static void continueAsNew(
347319
decisionContext.continueAsNew(workflowType, options, args);
348320
}
349321

350-
public static Promise<Void> cancelWorkflow(WorkflowExecution execution) {
351-
return getWorkflowInterceptor().cancelWorkflow(execution);
352-
}
353-
354322
public static void sleep(Duration duration) {
355323
getWorkflowInterceptor().sleep(duration);
356324
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@
3232
*/
3333
final class WorkflowRetryerInternal {
3434

35-
/**
36-
* Retry procedure synchronously.
37-
*
38-
* @param options retry options.
39-
* @param proc procedure to retry.
40-
*/
41-
public static void retry(RetryOptions options, Functions.Proc proc) {
42-
retry(
43-
options,
44-
() -> {
45-
proc.apply();
46-
return null;
47-
});
48-
}
49-
5035
public static <R> R validateOptionsAndRetry(RetryOptions options, Functions.Func<R> func) {
5136
return retry(RetryOptions.merge(null, options), func);
5237
}

0 commit comments

Comments
 (0)