def run_task(): """ Run a Apache Mesos Task. """ # start openlava services tmp = json.loads(task.data) master_hostname = tmp['master_hostname'] master_ip = tmp['master_ip'] agent_hostname = tmp['agent_hostname'] agent_ip = tmp['agent_ip'] # configure the master. util.add_to_hosts(master_hostname, master_ip) util.add_to_cluster_conf(master_hostname) # tell master we are ready to fire up. update = mesos_pb2.TaskStatus() update.task_id.value = task.task_id.value update.state = mesos_pb2.TASK_RUNNING update.data = str(agent_hostname) + ':' + str(agent_ip) driver.sendStatusUpdate(update) util.start_lava() # in case I'm idle for a while done. busy = True count = 0 while busy: time.sleep(10) try: if util.njobs_per_host(agent_hostname.strip()) == 0: count += 1 except: # lim not ready... pass if count >= 12: busy = False # tell master we are done here. update = mesos_pb2.TaskStatus() update.task_id.value = task.task_id.value update.state = mesos_pb2.TASK_FINISHED update.data = str(agent_hostname) + ':' + str(agent_ip) driver.sendStatusUpdate(update) util.stop_lava()
def run_task(): """ Run a Apache Mesos Task. """ # start openlava services tmp = json.loads(task.data) host = tmp['master_host'] ip_addr = tmp['master_ip'] util.add_to_hosts(host, ip_addr) util.add_to_cluster_conf(host) slave_host, slave_ip = util.get_ip() update = mesos_pb2.TaskStatus() update.task_id.value = task.task_id.value update.state = mesos_pb2.TASK_RUNNING update.data = slave_host + ':' + slave_ip driver.sendStatusUpdate(update) util.start_lava() # in case I'm idle for a while done. busy = True count = 0 while busy: time.sleep(10) try: if util.njobs_per_host(slave_host.strip()) == 0: count += 1 except: # lim not ready... pass if count >= 12: busy = False update = mesos_pb2.TaskStatus() update.task_id.value = task.task_id.value update.state = mesos_pb2.TASK_FINISHED update.data = slave_host + ':' + slave_ip driver.sendStatusUpdate(update) util.stop_lava()