Skip to content

Commit 8693c37

Browse files
authored
Remove unused code from cadence.internal package (#921)
1 parent 6d3f55f commit 8693c37

10 files changed

+0
-341
lines changed

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

Lines changed: 0 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,17 @@
2929
import com.uber.cadence.ActivityType;
3030
import com.uber.cadence.Decision;
3131
import com.uber.cadence.DecisionType;
32-
import com.uber.cadence.DescribeWorkflowExecutionRequest;
33-
import com.uber.cadence.DescribeWorkflowExecutionResponse;
3432
import com.uber.cadence.EntityNotExistsError;
3533
import com.uber.cadence.EventType;
3634
import com.uber.cadence.GetWorkflowExecutionHistoryRequest;
3735
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;
3836
import com.uber.cadence.History;
3937
import com.uber.cadence.HistoryEvent;
4038
import com.uber.cadence.HistoryEventFilterType;
41-
import com.uber.cadence.StartWorkflowExecutionRequest;
4239
import com.uber.cadence.TaskList;
4340
import com.uber.cadence.WorkflowExecution;
4441
import com.uber.cadence.WorkflowExecutionCloseStatus;
45-
import com.uber.cadence.WorkflowExecutionContinuedAsNewEventAttributes;
4642
import com.uber.cadence.WorkflowExecutionFailedEventAttributes;
47-
import com.uber.cadence.WorkflowExecutionInfo;
4843
import com.uber.cadence.WorkflowExecutionTerminatedEventAttributes;
4944
import com.uber.cadence.WorkflowExecutionTimedOutEventAttributes;
5045
import com.uber.cadence.WorkflowType;
@@ -389,42 +384,6 @@ public static boolean isWorkflowExecutionCompleteDecision(Decision decision) {
389384
|| decision.getDecisionType() == DecisionType.ContinueAsNewWorkflowExecution));
390385
}
391386

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-
428387
public static String getId(HistoryEvent historyEvent) {
429388
String id = null;
430389
if (historyEvent != null) {
@@ -436,67 +395,6 @@ public static String getId(HistoryEvent historyEvent) {
436395
return id;
437396
}
438397

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-
500398
public static WorkflowExecutionCloseStatus getCloseStatus(HistoryEvent event) {
501399
switch (event.getEventType()) {
502400
case WorkflowExecutionCanceled:
@@ -516,88 +414,6 @@ public static WorkflowExecutionCloseStatus getCloseStatus(HistoryEvent event) {
516414
}
517415
}
518416

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-
601417
public static GetWorkflowExecutionHistoryResponse getHistoryPage(
602418
byte[] nextPageToken,
603419
IWorkflowService service,
@@ -621,26 +437,6 @@ public static GetWorkflowExecutionHistoryResponse getHistoryPage(
621437
return history;
622438
}
623439

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-
644440
public static Iterator<HistoryEvent> getHistory(
645441
IWorkflowService service, String domain, WorkflowExecution workflowExecution) {
646442
return new Iterator<HistoryEvent>() {
@@ -1012,38 +808,6 @@ public static boolean isDecisionEvent(HistoryEvent event) {
1012808
return result;
1013809
}
1014810

1015-
public static EventType getEventTypeForDecision(DecisionType decisionType) {
1016-
switch (decisionType) {
1017-
case ScheduleActivityTask:
1018-
return EventType.ActivityTaskScheduled;
1019-
case RequestCancelActivityTask:
1020-
return EventType.ActivityTaskCancelRequested;
1021-
case StartTimer:
1022-
return EventType.TimerStarted;
1023-
case CompleteWorkflowExecution:
1024-
return EventType.WorkflowExecutionCompleted;
1025-
case FailWorkflowExecution:
1026-
return EventType.WorkflowExecutionFailed;
1027-
case CancelTimer:
1028-
return EventType.TimerCanceled;
1029-
case CancelWorkflowExecution:
1030-
return EventType.WorkflowExecutionCanceled;
1031-
case RequestCancelExternalWorkflowExecution:
1032-
return EventType.ExternalWorkflowExecutionCancelRequested;
1033-
case RecordMarker:
1034-
return EventType.MarkerRecorded;
1035-
case ContinueAsNewWorkflowExecution:
1036-
return EventType.WorkflowExecutionContinuedAsNew;
1037-
case StartChildWorkflowExecution:
1038-
return EventType.StartChildWorkflowExecutionInitiated;
1039-
case SignalExternalWorkflowExecution:
1040-
return EventType.SignalExternalWorkflowExecutionInitiated;
1041-
case UpsertWorkflowSearchAttributes:
1042-
return EventType.UpsertWorkflowSearchAttributes;
1043-
}
1044-
throw new IllegalArgumentException("Unknown decisionType");
1045-
}
1046-
1047811
public static WorkflowExecutionHistory readHistoryFromResource(String resourceFileName)
1048812
throws IOException {
1049813
ClassLoader classLoader = WorkflowExecutionUtils.class.getClassLoader();

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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.uber.cadence.internal.sync;
1919

2020
import com.uber.cadence.PollForDecisionTaskResponse;
21-
import com.uber.cadence.WorkflowExecution;
2221
import com.uber.cadence.common.WorkflowExecutionHistory;
2322
import com.uber.cadence.converter.DataConverter;
2423
import com.uber.cadence.internal.common.InternalUtils;
@@ -224,18 +223,6 @@ public boolean isSuspended() {
224223
return workflowWorker.isSuspended() && laWorker.isSuspended() && ldaWorker.isSuspended();
225224
}
226225

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-
239226
public <R> R queryWorkflowExecution(
240227
WorkflowExecutionHistory history,
241228
String queryType,

0 commit comments

Comments
 (0)