@@ -70,15 +70,13 @@ private class ContextImplTask implements TaskOrchestrationContext {
70
70
private String instanceId ;
71
71
private Instant currentInstant ;
72
72
private boolean isComplete ;
73
- private boolean isSuspended ;
74
73
private boolean isReplaying = true ;
75
74
76
75
// LinkedHashMap to maintain insertion order when returning the list of pending actions
77
76
private final LinkedHashMap <Integer , OrchestratorAction > pendingActions = new LinkedHashMap <>();
78
77
private final HashMap <Integer , TaskRecord <?>> openTasks = new HashMap <>();
79
78
private final LinkedHashMap <String , Queue <TaskRecord <?>>> outstandingEvents = new LinkedHashMap <>();
80
79
private final LinkedList <HistoryEvent > unprocessedEvents = new LinkedList <>();
81
- private final Queue <HistoryEvent > eventsWhileSuspended = new ArrayDeque <>();
82
80
private final DataConverter dataConverter = TaskOrchestrationExecutor .this .dataConverter ;
83
81
private final Duration maximumTimerInterval = TaskOrchestrationExecutor .this .maximumTimerInterval ;
84
82
private final Logger logger = TaskOrchestrationExecutor .this .logger ;
@@ -87,6 +85,7 @@ private class ContextImplTask implements TaskOrchestrationContext {
87
85
private boolean continuedAsNew ;
88
86
private Object continuedAsNewInput ;
89
87
private boolean preserveUnprocessedEvents ;
88
+
90
89
private Object customStatus ;
91
90
92
91
public ContextImplTask (List <HistoryEvent > pastEvents , List <HistoryEvent > newEvents ) {
@@ -530,23 +529,6 @@ private void handleEventRaised(HistoryEvent e) {
530
529
task .complete (result );
531
530
}
532
531
533
- private void handleEventWhileSuspended (HistoryEvent historyEvent ){
534
- if (historyEvent .getEventTypeCase () != HistoryEvent .EventTypeCase .EXECUTIONSUSPENDED ) {
535
- eventsWhileSuspended .offer (historyEvent );
536
- }
537
- }
538
-
539
- private void handleExecutionSuspended (HistoryEvent historyEvent ) {
540
- this .isSuspended = true ;
541
- }
542
-
543
- private void handleExecutionResumed (HistoryEvent historyEvent ) {
544
- this .isSuspended = false ;
545
- while (!eventsWhileSuspended .isEmpty ()) {
546
- this .processEvent (eventsWhileSuspended .poll ());
547
- }
548
- }
549
-
550
532
public Task <Void > createTimer (Duration duration ) {
551
533
Helpers .throwIfOrchestratorComplete (this .isComplete );
552
534
Helpers .throwIfArgumentNull (duration , "duration" );
@@ -762,86 +744,75 @@ private boolean processNextEvent() {
762
744
}
763
745
764
746
private void processEvent (HistoryEvent e ) {
765
- boolean overrideSuspension = e .getEventTypeCase () == HistoryEvent .EventTypeCase .EXECUTIONRESUMED || e .getEventTypeCase () == HistoryEvent .EventTypeCase .EXECUTIONTERMINATED ;
766
- if (this .isSuspended && !overrideSuspension ) {
767
- this .handleEventWhileSuspended (e );
768
- } else {
769
- switch (e .getEventTypeCase ()) {
770
- case ORCHESTRATORSTARTED :
771
- Instant instant = DataConverter .getInstantFromTimestamp (e .getTimestamp ());
772
- this .setCurrentInstant (instant );
773
- break ;
774
- case ORCHESTRATORCOMPLETED :
775
- // No action
776
- break ;
777
- case EXECUTIONSTARTED :
778
- ExecutionStartedEvent startedEvent = e .getExecutionStarted ();
779
- String name = startedEvent .getName ();
780
- this .setName (name );
781
- String instanceId = startedEvent .getOrchestrationInstance ().getInstanceId ();
782
- this .setInstanceId (instanceId );
783
- String input = startedEvent .getInput ().getValue ();
784
- this .setInput (input );
785
- TaskOrchestrationFactory factory = TaskOrchestrationExecutor .this .orchestrationFactories .get (name );
786
- if (factory == null ) {
787
- // Try getting the default orchestrator
788
- factory = TaskOrchestrationExecutor .this .orchestrationFactories .get ("*" );
789
- }
790
- // TODO: Throw if the factory is null (orchestration by that name doesn't exist)
791
- TaskOrchestration orchestrator = factory .create ();
792
- orchestrator .run (this );
793
- break ;
747
+ switch (e .getEventTypeCase ()) {
748
+ case ORCHESTRATORSTARTED :
749
+ Instant instant = DataConverter .getInstantFromTimestamp (e .getTimestamp ());
750
+ this .setCurrentInstant (instant );
751
+ break ;
752
+ case ORCHESTRATORCOMPLETED :
753
+ // No action
754
+ break ;
755
+ case EXECUTIONSTARTED :
756
+ ExecutionStartedEvent startedEvent = e .getExecutionStarted ();
757
+ String name = startedEvent .getName ();
758
+ this .setName (name );
759
+ String instanceId = startedEvent .getOrchestrationInstance ().getInstanceId ();
760
+ this .setInstanceId (instanceId );
761
+ String input = startedEvent .getInput ().getValue ();
762
+ this .setInput (input );
763
+ TaskOrchestrationFactory factory = TaskOrchestrationExecutor .this .orchestrationFactories .get (name );
764
+ if (factory == null ) {
765
+ // Try getting the default orchestrator
766
+ factory = TaskOrchestrationExecutor .this .orchestrationFactories .get ("*" );
767
+ }
768
+ // TODO: Throw if the factory is null (orchestration by that name doesn't exist)
769
+ TaskOrchestration orchestrator = factory .create ();
770
+ orchestrator .run (this );
771
+ break ;
794
772
// case EXECUTIONCOMPLETED:
795
773
// break;
796
774
// case EXECUTIONFAILED:
797
775
// break;
798
- case EXECUTIONTERMINATED :
799
- this .handleExecutionTerminated (e );
800
- break ;
801
- case TASKSCHEDULED :
802
- this .handleTaskScheduled (e );
803
- break ;
804
- case TASKCOMPLETED :
805
- this .handleTaskCompleted (e );
806
- break ;
807
- case TASKFAILED :
808
- this .handleTaskFailed (e );
809
- break ;
810
- case TIMERCREATED :
811
- this .handleTimerCreated (e );
812
- break ;
813
- case TIMERFIRED :
814
- this .handleTimerFired (e );
815
- break ;
816
- case SUBORCHESTRATIONINSTANCECREATED :
817
- this .handleSubOrchestrationCreated (e );
818
- break ;
819
- case SUBORCHESTRATIONINSTANCECOMPLETED :
820
- this .handleSubOrchestrationCompleted (e );
821
- break ;
822
- case SUBORCHESTRATIONINSTANCEFAILED :
823
- this .handleSubOrchestrationFailed (e );
824
- break ;
776
+ case EXECUTIONTERMINATED :
777
+ this .handleExecutionTerminated (e );
778
+ break ;
779
+ case TASKSCHEDULED :
780
+ this .handleTaskScheduled (e );
781
+ break ;
782
+ case TASKCOMPLETED :
783
+ this .handleTaskCompleted (e );
784
+ break ;
785
+ case TASKFAILED :
786
+ this .handleTaskFailed (e );
787
+ break ;
788
+ case TIMERCREATED :
789
+ this .handleTimerCreated (e );
790
+ break ;
791
+ case TIMERFIRED :
792
+ this .handleTimerFired (e );
793
+ break ;
794
+ case SUBORCHESTRATIONINSTANCECREATED :
795
+ this .handleSubOrchestrationCreated (e );
796
+ break ;
797
+ case SUBORCHESTRATIONINSTANCECOMPLETED :
798
+ this .handleSubOrchestrationCompleted (e );
799
+ break ;
800
+ case SUBORCHESTRATIONINSTANCEFAILED :
801
+ this .handleSubOrchestrationFailed (e );
802
+ break ;
825
803
// case EVENTSENT:
826
804
// break;
827
- case EVENTRAISED :
828
- this .handleEventRaised (e );
829
- break ;
805
+ case EVENTRAISED :
806
+ this .handleEventRaised (e );
807
+ break ;
830
808
// case GENERICEVENT:
831
809
// break;
832
810
// case HISTORYSTATE:
833
811
// break;
834
812
// case EVENTTYPE_NOT_SET:
835
813
// break;
836
- case EXECUTIONSUSPENDED :
837
- this .handleExecutionSuspended (e );
838
- break ;
839
- case EXECUTIONRESUMED :
840
- this .handleExecutionResumed (e );
841
- break ;
842
- default :
843
- throw new IllegalStateException ("Don't know how to handle history type " + e .getEventTypeCase ());
844
- }
814
+ default :
815
+ throw new IllegalStateException ("Don't know how to handle history type " + e .getEventTypeCase ());
845
816
}
846
817
}
847
818
0 commit comments