예제 #1
0
 def execute_action(self, action, priority):
     """Schedule action to SWF as activity task and wait. If action is not
     completed, raise TaskWait.
     """
     if self.handler.is_waiting():
         raise TaskWait
     elif self.handler.is_scheduled():
         return
     else:
         handler = InputHandler(self.handler.protocol)
         action_name = self.handler.get_next_activity_name()
         ActivityTask.schedule(
             self.decisions,
             name=action_name,
             input_data={
                 'protocol':
                 self.handler.protocol,
                 'body':
                 handler.save(data=action,
                              genealogy=self.handler.tag_list +
                              ['Action%s' % action_name])
             },
             task_list=action['Action'].get('_role',
                                            config.ACTIVITY_TASK_LIST),
             priority=priority)
예제 #2
0
파일: utils.py 프로젝트: drakeguan/mass
def submit(job, protocol=None, priority=1):
    """Submit mass job to SWF with specific priority.
    """
    client = boto3.client('swf', region_name=config.REGION)
    handler = InputHandler(protocol)

    res = client.start_workflow_execution(
        domain=config.DOMAIN,
        workflowId=job.title,
        workflowType=config.WORKFLOW_TYPE_FOR_JOB,
        taskList={'name': config.DECISION_TASK_LIST},
        taskPriority=str(priority),
        input=json.dumps({
            'protocol': protocol,
            'body': handler.save(
                data=job,
                job_title=job.title,
                task_title=job.title
            )
        }),
        executionStartToCloseTimeout=str(config.WORKFLOW_EXECUTION_START_TO_CLOSE_TIMEOUT),
        tagList=[job.title],
        taskStartToCloseTimeout=str(config.DECISION_TASK_START_TO_CLOSE_TIMEOUT),
        childPolicy=config.WORKFLOW_CHILD_POLICY)
    return job.title, res['runId']
예제 #3
0
파일: utils.py 프로젝트: davidecarson/mass
def submit(job, protocol=None, priority=1, scheduler='swf', domain=None, region=None):
    """Submit mass job to SWF with specific priority.
    """
    if scheduler != 'swf':
        raise UnsupportedScheduler(scheduler)
    from mass.scheduler.swf import config
    import boto3
    client = boto3.client(
        'swf',
        region_name=region or config.REGION,
        config=Config(connect_timeout=config.CONNECT_TIMEOUT,
                      read_timeout=config.READ_TIMEOUT))
    handler = InputHandler(protocol)

    job_title = job['Job']['title']
    res = client.start_workflow_execution(
        domain=domain or config.DOMAIN,
        workflowId=job_title,
        workflowType=config.WORKFLOW_TYPE_FOR_JOB,
        taskList={'name': config.DECISION_TASK_LIST},
        taskPriority=str(priority),
        input=json.dumps({
            'protocol': protocol,
            'body': handler.save(
                data=job,
                genealogy=[job_title]
            )
        }),
        executionStartToCloseTimeout=str(config.WORKFLOW_EXECUTION_START_TO_CLOSE_TIMEOUT),
        tagList=[job_title],
        taskStartToCloseTimeout=str(config.DECISION_TASK_START_TO_CLOSE_TIMEOUT),
        childPolicy=config.WORKFLOW_CHILD_POLICY)
    return job_title, res['runId']
예제 #4
0
파일: __init__.py 프로젝트: badboy99tw/mass
 def execute_task(self, task, priority):
     """Schedule task to SWF as child workflow and wait. If the task is not
     completed, raise TaskWait.
     """
     if self.handler.is_waiting():
         raise TaskWait
     elif self.handler.is_scheduled():
         return
     else:
         handler = InputHandler(self.handler.protocol)
         ChildWorkflowExecution.start(
             decisions=self.decisions,
             name=self.handler.get_next_workflow_name(task['Task']['title']),
             input_data={
                 'protocol': self.handler.protocol,
                 'body': handler.save(
                     data=task,
                     genealogy=self.handler.tag_list + [task['Task']['title']])
             },
             tag_list=self.handler.tag_list + [task['Task']['title']],
             priority=priority)
예제 #5
0
파일: __init__.py 프로젝트: badboy99tw/mass
 def execute_action(self, action, priority):
     """Schedule action to SWF as activity task and wait. If action is not
     completed, raise TaskWait.
     """
     if self.handler.is_waiting():
         raise TaskWait
     elif self.handler.is_scheduled():
         return
     else:
         handler = InputHandler(self.handler.protocol)
         action_name = self.handler.get_next_activity_name()
         ActivityTask.schedule(
             self.decisions,
             name=action_name,
             input_data={
                 'protocol': self.handler.protocol,
                 'body': handler.save(
                     data=action,
                     genealogy=self.handler.tag_list + ['Action%s' % action_name])
             },
             task_list=action['Action'].get('_role', config.ACTIVITY_TASK_LIST),
             priority=priority
         )
예제 #6
0
 def execute_task(self, task, priority):
     """Schedule task to SWF as child workflow and wait. If the task is not
     completed, raise TaskWait.
     """
     if self.handler.is_waiting():
         raise TaskWait
     elif self.handler.is_scheduled():
         return
     else:
         handler = InputHandler(self.handler.protocol)
         ChildWorkflowExecution.start(
             decisions=self.decisions,
             name=self.handler.get_next_workflow_name(
                 task['Task']['title']),
             input_data={
                 'protocol':
                 self.handler.protocol,
                 'body':
                 handler.save(data=task,
                              genealogy=self.handler.tag_list +
                              [task['Task']['title']])
             },
             tag_list=self.handler.tag_list + [task['Task']['title']],
             priority=priority)