示例#1
0
    def schedule(self):
        """
         create inter-priority
        """
        def byPriority(wf):
            return 0 if wf.priority is None else wf.priority

        ##simple inter priority sorting
        sorted_wfs = sorted(self.workflows, key=byPriority)
        wf_jobs = {wf: [] for wf in sorted_wfs}
        resources = self.resource_manager.get_resources()
        ##print("common nodes count:" + str(len(toNodes(resources))))
        nodes = PeftHelper.to_nodes(resources)

        wf_jobs = {wf: self.make_ranking(wf, nodes) for wf in sorted_wfs}

        ##new_schedule = self.get_unchanged_schedule(self.old_schedule, time)
        new_schedule = Schedule({node: [] for node in nodes})
        new_plan = new_schedule.mapping

        for (wf, jobs) in wf_jobs.items():

            new_schedule = self.mapping([(wf, jobs)], new_plan, nodes,
                                        self.commcost, self.compcost)
            new_plan = new_schedule.mapping

        return new_schedule
示例#2
0
 def make_ranking(self, wf, nodes):
     ##resources = self.resource_manager.get_resources()
     ##print("common nodes count:" + str(len(toNodes(resources))))
     ##nodes = PeftHelper.to_nodes(resources)
     ranking_func = PeftHelper.build_ranking_func(nodes, self.compcost,
                                                  self.commcost, self.oct)
     wf_jobs = ranking_func(wf)
     return wf_jobs
 def checkDown(self, node_name, is_down):
     nodes = PeftHelper.to_nodes(self.public_resources)
     for nd in nodes:
         if nd.name == node_name:
             if is_down:
                 nd.state = Node.Down
             else:
                 nd.state = Node.Unknown
     pass
示例#4
0
    def mapping(self, sorted_jobs, existing_plan, nodes, commcost, compcost):
        """def allocate(job, orders, jobson, prec, compcost, commcost):"""
        """ Allocate job to the machine with earliest finish time

        Operates in place
        """

        ## TODO: add finished tasks
        jobson = dict()
        for (node, items) in existing_plan.items():
            for item in items:
                if item.state == ScheduleItem.FINISHED or item.state == ScheduleItem.EXECUTING:
                    jobson[item.job] = node

        new_plan = existing_plan

        def ft(machine):
            #cost = st(machine)
            runtime = compcost(task, machine)
            cost = st(machine, runtime) + runtime + self.oct[(task, machine)]
            ##print("machine: %s job:%s cost: %s" % (machine.name, task.id, cost))
            ##print("machine: " + str(machine.name) + " cost: " + str(cost))

            return cost

        def ft_run(machine):
            runtime = compcost(task, machine)
            cost = st(machine, runtime) + runtime
            return cost

        for wf, tasks in sorted_jobs:
            ##wf_dag = self.convert_to_parent_children_map(wf)
            wf_dag = PeftHelper.convert_to_parent_children_map(wf)
            prec = reverse_dict(wf_dag)
            for task in tasks:
                st = partial(self.start_time, wf, task, new_plan, jobson, prec,
                             commcost)

                # ress = [(key, ft(key)) for key in new_plan.keys()]
                # agent_pair = min(ress, key=lambda x: x[1][0])
                # agent = agent_pair[0]
                # start = agent_pair[1][0]
                # end = agent_pair[1][1]

                agent = min(new_plan.keys(), key=ft)
                runtime = compcost(task, agent)
                start = st(agent, runtime)
                end = ft_run(agent)

                # new_plan[agent].append(ScheduleItem(task, start, end))
                Schedule.insert_item(new_plan, agent,
                                     ScheduleItem(task, start, end))

                jobson[task] = agent
        new_sched = Schedule(new_plan)
        return new_sched
示例#5
0
def run_peft(workflow, resource_manager, estimator):
    """
    It simply runs peft with empty initial schedule
    and returns complete schedule
    """
    oct = PeftHelper.get_OCT(workflow, resource_manager, estimator)
    peft = DynamicPeft(workflow, resource_manager, estimator, oct)
    nodes = resource_manager.get_nodes()
    init_schedule = Schedule({node: [] for node in nodes})
    return peft.run(init_schedule)
    def get_by_softreq(self, soft_reqs):
        nodes = PeftHelper.to_nodes(self.public_resources)

        def check_reqs(node):
            return (soft_reqs in node.soft) or (SoftItem.ANY_SOFT in node.soft)

        gotcha = [
            node for node in nodes
            if node.state != Node.Down and check_reqs(node)
        ]
        return gotcha
示例#7
0
    def run(self, current_cleaned_schedule):
        ## current_cleaned_schedule - this schedule contains only
        ## finished and executed tasks, all unfinished and failed have been removed already
        ## current_cleaned_schedule also have down nodes and new added
        ## ALGORITHM DOESN'T CHECK ADDING OF NEW NODES BY ITSELF
        ## nodes contain only available now

        ## 1. get all unscheduled tasks
        ## 2. sort them by rank
        ## 3. map on the existed nodes according to current_cleaned_schedule

        nodes = self.get_nodes()

        for_planning = PeftHelper.get_tasks_for_planning(self.workflow, current_cleaned_schedule)
        ## TODO: check if it sorted properly
        for_planning = set([task.id for task in for_planning])

        sorted_tasks = [task for task in self.wf_jobs if task.id in for_planning]

        # print("P: " + str(sorted_tasks))

        new_sched = self.mapping([(self.workflow, sorted_tasks)], current_cleaned_schedule.mapping, nodes, self.commcost, self.compcost)
        return new_sched
示例#8
0
 def get_nodes(self):
     resources = self.resource_manager.get_resources()
     nodes = PeftHelper.to_nodes(resources)
     return nodes
 def isCloudNode(self, node):
     result = node.name in [
         nd.name for nd in PeftHelper.to_nodes(self.public_resources)
     ]
     return result