Ejemplo n.º 1
0
    def launchTask(self, driver, task):
        """
        Logic to launch TaskChunks by running through sub-tasks one at a time.
        """
        if task.task_id in self.pendingTaskChunks:
            self.pendingTaskChunks.setActive(task.task_id)

        if chunk_utils.isTaskChunk(task):
            self.pendingTaskChunks.addTask(task)
            taskChunkId = task.task_id
            if not self.pendingTaskChunks.isActive(taskChunkId):
                update = mesos_pb2.TaskStatus()
                update.task_id.value = taskChunkId.value
                update.state = mesos_pb2.TASK_RUNNING
                driver.sendStatusUpdate(update)

            self.runNextSubTask(driver, taskChunkId)
        else:
            chunk_utils.ExecutorWrapper.launchTask(self, driver, task)
Ejemplo n.º 2
0
    def killTask(self, driver, taskId):
        """
        Kills task specified using taskId.
        taskId can refer to task or TaskChunks.
        """
        if taskId in self.pendingTaskChunks:
            origTaskId = taskId
            task = self.pendingTaskChunks[taskId]
            while chunk_utils.isTaskChunk(task):
                for subTask in chunk_utils.subTaskIterator(task):
                    if self.pendingTaskChunks.isActive(subTask.task_id):
                        taskId = subTask.task_id
                        task = self.pendingTaskChunks[taskId]
                        break
            update = mesos_pb2.TaskStatus()
            update.task_id.value = origTaskId.value
            update.state = mesos_pb2.TASK_KILLED
            driver.sendStatusUpdate(update)

        chunk_utils.ExecutorWrapper.killTask(self, driver, taskId)