@@ -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 >() {
0 commit comments