Esempio n. 1
0
 def get_decisions_after_workflow_start(self):
     logger.debug('DecisionBuilder.get_decisions_after_workflow_start()')
     decisions = []
     tasks = self.execution_graph.get_first_tasks()
     for t in tasks:
         decision = self.get_decision_schedule_activity(t)
         decisions.append(decision)
     return decisions
Esempio n. 2
0
 def get_decisions_after_workflow_start(self):
     logger.debug('DecisionBuilder.get_decisions_after_workflow_start()')
     decisions = []
     task_ids = self.execution_graph.get_nodes_zero_in_degree()
     for task_id in task_ids:
         task = self.tasks_by_id[task_id]
         decision = self.get_decision_schedule_activity(task=task)
         decisions.append(decision)
     return decisions
Esempio n. 3
0
 def get_decisions_after_workflow_start(self):
     logger.debug('DecisionBuilder.get_decisions_after_workflow_start()')
     decisions = []
     task_ids = self.execution_graph.get_nodes_zero_in_degree()
     for task_id in task_ids:
         task = self.tasks_by_id[task_id]
         decision = self.get_decision_schedule_activity(task=task)
         decisions.append(decision)
     return decisions
Esempio n. 4
0
 def get_decisions_after_workflow_start(self):
     decisions = []
     tasks = self.execution_graph.get_first_tasks()
     for t in tasks:
         if isinstance(t, floto.specs.ActivityTask):
             input_ = self.get_input_activity_task_after_workflow_start(t)
             decision = self.get_decision_schedule_activity_task(activity_task=t, input=input_)
         else:
             decision = self.get_decision_start_timer(t)
         decisions.append(decision)
     return decisions
Esempio n. 5
0
    def get_decisions_after_activity_completion(self, events):
        """Return the decisions based on the completed activities since the last decision task.
        Parameters
        ----------
        events: list
            List of ActivityTaskCompleted or TimerFired events
        """
        task_ids = [self.history.get_id_task_event(e) for e in events]
        tasks = self.get_tasks_to_be_scheduled(task_ids)

        decisions = []
        for t in tasks:
            decisions.append(self.get_decision_task(t))
        return decisions
Esempio n. 6
0
    def get_decisions_after_activity_completion(self, events):
        """Return the decisions based on the completed activities since the last decision task.
        Parameters
        ----------
        events: list
            List of ActivityTaskCompleted or TimerFired events
        """
        logger.debug(
            'DecisionBuilder.get_decisions_after_activity_completion...')

        task_ids = [self.history.get_id_task_event(e) for e in events]
        tasks = self.get_tasks_to_be_scheduled(task_ids)

        decisions = []
        for t in tasks:
            decisions.append(self.get_decision_schedule_activity(task=t))
        return decisions
Esempio n. 7
0
    def get_decisions_faulty_tasks(self, task_events):
        """Analyze the faulty tasks and their retry strategies. If a task is to be resubmitted,
        add a decision to the output.

        Parameters
        ----------
        task_events: list
            List of ActivityTask Failed/TimedOut events

        Returns
        -------
        list
            List of ScheduleActivityTask decision if the tasks are being resubmitted. 
            If not, a TerminateWorkflow decision is returned and the self.terminate_workflow flag
            is set.
        """
        decisions = []
        for e in task_events:
            if self.is_terminate_workflow():
                break
            id_ = self.history.get_id_task_event(e)
            t = self.tasks_by_id[id_]
            if t.retry_strategy:
                failures = self.history.get_number_activity_failures(t)
                if t.retry_strategy.is_task_resubmitted(failures):
                    decision = self.get_decision_schedule_activity(task=t)
                    decisions.append(decision)
                else:
                    reason = 'task_retry_limit_reached'
                    details = self.decision_input.get_details_failed_tasks(
                        task_events)
                    decisions = self.get_decisions_after_failed_workflow_execution(
                        reason=reason, details=details)
            else:
                reason = 'task_failed'
                details = self.decision_input.get_details_failed_tasks(
                    task_events)
                decisions = self.get_decisions_after_failed_workflow_execution(
                    reason=reason, details=details)
        return decisions
Esempio n. 8
0
    def get_decisions_faulty_tasks(self, task_events):
        """Analyze the faulty tasks and their retry strategies. If a task is to be resubmitted,
        add a decision to the output

        Parameters
        ----------
        task_events: list
            List of ActivityTask Failed/TimedOut events

        Returns
        -------
        list
            List of ScheduleActivityTask decision if the tasks are being resubmitted. 
            If not, a TerminateWorkflow decision is returned and the self.terminate_worklfow flag
            is set.
        """
        decisions = []
        for e in task_events:
            if self.is_terminate_workflow():
                break
            activity_id = self.history.get_id_activity_task_event(e)
            t = self.execution_graph.tasks_by_id[activity_id]
            if t.retry_strategy:
                failures = self.history.get_number_activity_task_failures(activity_id)
                if t.retry_strategy.is_task_resubmitted(failures):
                    scheduled_event = self.history.get_event_task_scheduled(activity_id)
                    attributes = scheduled_event['activityTaskScheduledEventAttributes']
                    input = json.loads(attributes['input']) if 'input' in attributes else None
                    decision = self.get_decision_schedule_activity_task(t, input)
                    decisions.append(decision)
                else:
                    reason = 'task_retry_limit_reached'
                    details = self.get_details_failed_tasks(task_events)
                    decisions = self.get_decisions_after_failed_workflow_execution(reason, details)
            else:
                reason = 'task_failed'
                details = self.get_details_failed_tasks(task_events)
                decisions = self.get_decisions_after_failed_workflow_execution(reason, details)
        return decisions
Esempio n. 9
0
    def get_decisions_faulty_tasks(self, task_events):
        """Analyze the faulty tasks and their retry strategies. If a task is to be resubmitted,
        add a decision to the output.

        Parameters
        ----------
        task_events: list
            List of ActivityTask Failed/TimedOut events

        Returns
        -------
        list
            List of ScheduleActivityTask decision if the tasks are being resubmitted. 
            If not, a TerminateWorkflow decision is returned and the self.terminate_workflow flag
            is set.
        """
        decisions = []
        for e in task_events:
            if self.is_terminate_workflow():
                break
            id_ = self.history.get_id_task_event(e)
            t = self.tasks_by_id[id_]
            if t.retry_strategy:
                failures = self.history.get_number_activity_failures(t)
                if t.retry_strategy.is_task_resubmitted(failures):
                    decision = self.get_decision_schedule_activity(task=t)
                    decisions.append(decision)
                else:
                    reason = 'task_retry_limit_reached'
                    details = self.decision_input.get_details_failed_tasks(task_events)
                    decisions = self.get_decisions_after_failed_workflow_execution(reason=reason, 
                            details=details)
            else:
                reason = 'task_failed'
                details = self.decision_input.get_details_failed_tasks(task_events)
                decisions = self.get_decisions_after_failed_workflow_execution(reason=reason, 
                        details=details)
        return decisions