def frameworkMessage(self, driver, message): #logger("Ignoring framework message: %s" % message) logger.info("Message received: %s" % message) message_type = messages.message_type(message) # finish if message_type == messages.SMT_TERMINATEEXECUTOR: logger.info("Termination signal received...") self.shutdown(driver) # run comp task if message_type == messages.SMT_RUNTASK: # here should be Task instance task = messages.message_body(message) logger.info("run task id: %s, runtime: %s" % (task['id'], task['runtime'])) self.rlock.acquire() if self.runnig_task is not None: # TODO: make a special message to refuse to run logger.error("Alarm! Node is not empty") raise Exception("Node is not empty") self.runnig_task = tasks.ComputationalTask(task) ## spawn compute-intesive task self.runnig_task.run() self.rlock.release() # simulating of node fail if message_type == messages.SMT_POISONPILL: logger.info("Poison pill has been received") self.abruptShutdown(driver) pass
def frameworkMessage(self, driver, executorId, slaveId, message): logger.info("Message: " + str(slaveId) + " " + str(executorId) + " " + str(message)) self.rlock.acquire() if executorId.value not in self.active_resources: logger.info("Exceutor %s hasn't been recognized as registered. Dropping message. Possibly that executor was deleted" % (executorId.value)) return if self.active_resources[executorId.value].state == ResourceInfo.DEAD: logger.info("Executor %s marked as a dead. Dropping message" % (executorId.value)) return message_type = messages.message_type(message) if message_type == messages.EMT_READYTOWORK: # confirm resource as active self.active_resources[executorId.value].change_state(ResourceInfo.FREE) if message_type == messages.EMT_TASKFINISHED: # id # real_start_time # real_end_time rinfo = self.active_resources[executorId.value] body = messages.message_body(message) finished_task_id = body['id'] real_start_time = body['real_start_time'] real_end_time = body['real_end_time'] # self.current_schedule.change_state_byId(finished_task_id, ScheduleItem.FINISHED) node, item = self.current_schedule.place_non_failed(finished_task_id) logger.info("Item state: %s" % item.state) item.real_start_time = real_start_time item.real_end_time = real_end_time item.state = ScheduleItem.FINISHED rinfo.change_state(ResourceInfo.FREE) logger.info("TaskFinished: %s" % self.current_schedule) self.run_next_tasks(driver) # tasks = self.workflow.ready_to_run_tasks(self.finished_tasks, self.running_tasks) # self.running_tasks.remove(finished_task_id) # if len(tasks) > 0: # task = tasks[0] # rinfo.askExecutor_RunTask(driver, task) # self.running_tasks.add(task.id) self.rlock.release()