예제 #1
0
 def from_proto(pb_message):
     return ErTask(id=pb_message.id,
                   name=pb_message.name,
                   inputs=_map_and_listify(ErPartition.from_proto,
                                           pb_message.inputs),
                   outputs=_map_and_listify(ErPartition.from_proto,
                                            pb_message.outputs),
                   job=ErJob.from_proto(pb_message.job))
예제 #2
0
 def from_proto(pb_message):
     return ErJob(id=pb_message.id,
                  name=pb_message.name,
                  inputs=_map_and_listify(ErStore.from_proto,
                                          pb_message.inputs),
                  outputs=_map_and_listify(ErStore.from_proto,
                                           pb_message.outputs),
                  functors=_map_and_listify(ErFunctor.from_proto,
                                            pb_message.functors),
                  options=dict(pb_message.options))
예제 #3
0
 def from_proto(pb_message):
     return ErProcessorBatch(id=pb_message.id,
                             name=pb_message.name,
                             processors=_map_and_listify(
                                 ErProcessor.from_proto,
                                 pb_message.processors),
                             tag=pb_message.tag)
예제 #4
0
 def from_proto(pb_message):
     return ErServerCluster(id=pb_message.id,
                            name=pb_message.name,
                            server_nodes=_map_and_listify(
                                ErServerNode.from_proto,
                                pb_message.serverNodes),
                            tag=pb_message.tag)
예제 #5
0
    def sync_send(self,
                  inputs: list,
                  output_types: list,
                  endpoint: ErEndpoint,
                  command_uri: CommandURI,
                  serdes_type=SerdesTypes.PROTOBUF):
        request = None
        try:
            request = ErCommandRequest(id=time_now(),
                                       uri=command_uri._uri,
                                       args=_map_and_listify(
                                           _to_proto_string, inputs))
            L.debug(f"calling:{endpoint} {command_uri} {request}")
            _channel = self._channel_factory.create_channel(endpoint)
            _command_stub = command_pb2_grpc.CommandServiceStub(_channel)
            response = _command_stub.call(request.to_proto())
            er_response = ErCommandResponse.from_proto(response)
            L.debug(f"called:{endpoint} {command_uri} {request} {er_response}")
            byte_results = er_response._results

            if len(byte_results):
                zipped = zip(output_types, byte_results)
                return list(
                    map(
                        lambda t: t[0].from_proto_string(t[1])
                        if t[1] is not None else None, zipped))
            else:
                return []
        except Exception as e:
            L.error(
                f'Error calling to {endpoint}, command_uri: {command_uri}, req:{request}'
            )
            raise CommandCallError(command_uri, endpoint, e)
예제 #6
0
 def from_proto(pb_message):
     return ErSessionMeta(id=pb_message.id,
                          name=pb_message.name,
                          status=pb_message.status,
                          tag=pb_message.tag,
                          processors=_map_and_listify(
                              ErProcessor.from_proto,
                              pb_message.processors),
                          options=dict(pb_message.options))
예제 #7
0
 def from_proto(pb_message):
     return ErStoreList(
         _map_and_listify(ErStore.from_proto, pb_message.stores))
예제 #8
0
 def from_proto(pb_message):
     return ErStore(store_locator=ErStoreLocator.from_proto(
         pb_message.storeLocator),
                    partitions=_map_and_listify(ErPartition.from_proto,
                                                pb_message.partitions),
                    options=dict(pb_message.options))
예제 #9
0
 def from_proto(pb_message):
     return ErPairBatch(
         _map_and_listify(ErPair.from_proto, pb_message.pairs))