Exemplo n.º 1
0
def JSONDecoderTaskTree(dct):
    if dct.has_key("tid"):
        task = EngineDB.Task()
        task.tid = dct.get("tid")
        task.id = dct.get("id")
        task.title = dct.get("title")
        task.service = dct.get("service")
        task.minslots = dct.get("atleast", 1)
        task.maxslots = dct.get("atmost", 1)
        task.serialsubtasks = True if dct.get("serialsubtasks",
                                              False) == 1 else False
        task.ptids = [0]
        if dct.has_key("ants"):
            task.__dict__["instanceTids"] = dct.get("ants")
        task.cids = dct.get("cids", [])
        return task
    elif dct.has_key("data") and dct.has_key("children") \
             and dct["data"] != OUTER_TASK_TREE_SENTINAL:
        # this puts the subtasks as a member of a task object (which is dct["data"])
        dct["data"].children = dct["children"]
        return dct["data"]
    elif dct.has_key("data") and dct["data"] == OUTER_TASK_TREE_SENTINAL:
        # this ensures the top-level JSON wrapper just returns a list of tasks
        return dct["children"]
    else:
        raise FileSystemDBError, "invalid task tree"
Exemplo n.º 2
0
 def newTask (self, jid, tid, sst):
     task = EngineDB.Task()
     task.jid = jid
     task.tid = tid
     task.state = EngineDB.STATE_BLOCKED
     task.cids = []
     task.serialsubtasks = True if sst else False  # sst may be numeric
     task.statetime = self.spooltime
     setattr(task, "kids", []) # for construction use, not recorded to db
     setattr(task, "idx", 0) # for construction use, not recorded to db
     if tid > 0:
         # tid 0 is special and "reserved" for the job itself
         # commands attached to the job object are placed into
         # the db with their tid=0, but the task itself is not.
         task.idx = len(self.allTasks)
         self.allTasks.append( task )
     return task
Exemplo n.º 3
0
            raise FileSystemDBError(msg)
        f.close()
        # traverse task tree and express tasks as updates
        taskStack = taskTree
        while taskStack:
            task = taskStack.pop()
            task.jid = self.job.jid
            self.tasks.append(task)
            if hasattr(task, "children"):
                taskStack.extend(task.children)
                # put parent tid in all children
                for child in task.children:
                    child.ptids = [task.tid]

        # create a task with tid 0 for containing job-level commands
        zeroTask = EngineDB.Task()
        zeroTask.jid = self.job.jid
        zeroTask.tid = 0
        zeroTask.title = "LAST"
        # NOTE: we're not yet maintaining the zero task's list of children
        zeroTask.children = []
        self.tasks.append(zeroTask)

        # populate task LUT
        for task in self.tasks:
            self.taskByTid[task.tid] = task

        # extend the ptids list for tasks that are referred to by other tasks as instances
        for task in self.tasks:
            for tid in task.__dict__.get("instanceTids", []):
                childTask = self.taskByTid.get(tid)