Exemple #1
0
def get_worker(port):
    ip = utils.IPGetter.get_ip_address()
    master_info = NodeInfo(name="master",
                           ip=conf.MASTER_IP,
                           port=conf.MASTER_PORT,
                           status=NodeStatus.working)
    node_info = NodeInfo(name="worker",
                         ip=ip,
                         port=port,
                         status=NodeStatus.idle)

    if common.doesServiceExist(node_info.ip, node_info.port):
        logging.warning("%s:%s already been used! change another port" %
                        (node_info.ip, node_info.port))
        exit(1)

    worker_node = WorkerNode(master_info, node_info)
    logging.info("%s startup" % worker_node.get_node_info())

    return worker_node
 def heartbeat(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.heartbeat(nodeInfo)
 def task_complete(self, worker, taskResult):
     nodeInfo = NodeInfo.from_dict(worker)
     result = TaskResult.from_dict(taskResult)
     return self.master.task_complete(nodeInfo, result)
 def logout_worker(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.remove_worker(nodeInfo)
 def register_worker(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.register_worker(nodeInfo)
Exemple #6
0
 def heartbeat(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.heartbeat(nodeInfo)
Exemple #7
0
 def task_complete(self, worker, taskResult):
     nodeInfo = NodeInfo.from_dict(worker)
     result = TaskResult.from_dict(taskResult)
     return self.master.task_complete(nodeInfo, result)
Exemple #8
0
 def logout_worker(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.remove_worker(nodeInfo)
Exemple #9
0
 def register_worker(self, worker):
     nodeInfo = NodeInfo.from_dict(worker)
     return self.master.register_worker(nodeInfo)