コード例 #1
0
ファイル: bataar.py プロジェクト: oar-team/oar3
    def scheduleJobs(self):
        print("Sheduling Round")
        real_time = time.time()
        if self.platform_model == "simu":
            schedule_cycle(self.platform, self.env.now, "default")

            # retrieve jobs to launch
            jids_to_launch = []
            for jid, job in iteritems(self.platform.assigned_jobs):
                print("job.start_time %s" % job.start_time)
                if (job.start_time == self.env.now) and (job.state == "Waiting"):
                    self.waiting_jids.remove(jid)
                    jids_to_launch.append(jid)
                    job.state = "Running"
                    print("tolaunch: %s" % jid)
                    self.platform.running_jids.append(jid)

        else:
            print("call meta_schedule('internal')")
            meta_schedule("internal", plt)

            result = db.query(Job).filter(Job.state == "toLaunch").order_by(Job.id).all()

            for job_db in result:
                set_job_state(job_db.id, "Running")
                jid = self.db_jid2s_jid[job_db.id]
                self.waiting_jids.remove(jid)
                jids_to_launch.append(jid)
                self.jobs[jid].state = "Running"
                print("_tolaunch: %s" % jid)
                self.platform.running_jids.append(jid)

        print("Ids of jobs to launch: ", *jids_to_launch)
        print("Time befort scheduling round: ", self.bs._current_time, self.sched_delay)
        # update time
        real_sched_time = time.time() - real_time
        if self.sched_delay == -1:
            self.bs.consume_time(real_sched_time)  # TODO
        else:
            self.bs.consume_time(self.sched_delay)

        self.env.now = self.bs._current_time

        print("Time after scheduling round: ", self.bs._current_time)
        # send to uds
        if len(jids_to_launch) > 0:
            scheduled_jobs = []
            jobs_res = {}
            for jid in jids_to_launch:
                ds_job = self.jobs[jid].ds_job
                res = itvs2batsim_str0(self.jobs[jid].res_set)
                scheduled_jobs.append(ds_job)
                jobs_res[ds_job.id] = res

            self.bs.start_jobs(scheduled_jobs, jobs_res)
コード例 #2
0
ファイル: bataar.py プロジェクト: fr0uty/oartm
def send_bat_msg(connection, now, jids_to_launch, jobs):
    msg = "0:" + str(now) + "|"
    if jids_to_launch:
        msg += str(now) + ":J:"
        for jid in jids_to_launch:
            msg += str(jid) + "=" + itvs2batsim_str0(jobs[jid].res_set) + ";"
        msg = msg[:-1]  # remove last semicolon

    else:  # Do nothing
        msg += str(now) + ":N"

    print(msg)
    lg = struct.pack("i", int(len(msg)))
    connection.sendall(lg)
    connection.sendall(msg.encode("utf-8"))
コード例 #3
0
ファイル: test_interval.py プロジェクト: fr0uty/oartm
def test_itvs2batsim_str0():
    itvs = [(1, 1), (4, 5), (7, 7), (8, 10)]
    bat_str = '0,3-4,6,7-9'
    assert itvs2batsim_str0(itvs) == bat_str