Exemple #1
0
 def process_job_gather(self, ifn):
     """Process a job config file, allocate the tasks."""
     print "proccess job", ifn
     VRNUM = 80
     jobid = random.randint(0,65535)
     config = ConfigReader(ifn)
     l = self.get_idle_nodes()
     m = 0
     # Liang: allocation strategy is here, needs improvement
     for vrid, vrd in config.vrdetail.items():
         m += 1
         n = min(int(m/VRNUM), len(l)-1)
         # Inform a node to intialize a job
         if (m-1) % VRNUM == 0:
             msg = "jobc%i|%s" % (jobid, config.vrset2msg(config.vrouters))
             self.reliable_send(msg, (l[n][1], BPORT))
         msg = "ctvr%i|%s" % (jobid, config.vrd2msg(vrd))
         self.reliable_send(msg, (l[n][1], BPORT))
         if config.has_upperapp(vrid):
             msg = "ctap%i|%s" % (jobid, config.apd2msg(config.appdetail[vrid]))
             self.reliable_send(msg, (l[n][1], BPORT))
     pass