def init(): if EggRoll.init_flag: return config = file_utils.load_json_conf('arch/conf/mock_roll.json') egg_ids = config.get('eggs') for egg_id in egg_ids: target = config.get('storage').get(egg_id) channel = grpc.insecure_channel( target, options=[('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1)]) EggRoll.egg_list.append(kv_pb2_grpc.KVServiceStub(channel)) procs = config.get('procs').get(egg_id) for proc in procs: _channel = grpc.insecure_channel( proc, options=[('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1)]) _stub = processor_pb2_grpc.ProcessServiceStub(_channel) proc_info = (_channel, _stub) i = len(EggRoll.proc_list) EggRoll.proc_egg_map[i] = int(egg_id) - 1 EggRoll.proc_list.append(proc_info) EggRoll.init_flag = True
def __init__(self, job_id, host, port): if _EggRoll.instance is not None: raise EnvironmentError("eggroll should be initialized only once") self.channel = grpc.insecure_channel(target="{}:{}".format(host, port), options=[('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1)]) self.job_id = job_id self.kv_stub = kv_pb2_grpc.KVServiceStub(self.channel) self.proc_stub = processor_pb2_grpc.ProcessServiceStub(self.channel) _EggRoll.instance = self
def __init__(self, job_id, host, port, eggroll_context): if _EggRoll.instance is not None: raise EnvironmentError("eggroll should be initialized only once") self.channel = grpc.insecure_channel( target="{}:{}".format(host, port), options=[('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1)]) self.job_id = job_id self.kv_stub = kv_pb2_grpc.KVServiceStub(self.channel) self.proc_stub = processor_pb2_grpc.ProcessServiceStub(self.channel) self.eggroll_context = eggroll_context _EggRoll.instance = self # todo: move to eggrollContext try: self.host_name = socket.gethostname() self.host_ip = socket.gethostbyname(self.host_name) except socket.gaierror as e: self.host_name = 'unknown' self.host_ip = 'unknown'