void send(int code, MessageLite req) throws IOException {
   int len = req.getSerializedSize();
   dout.writeInt(len + 1);
   dout.write(code);
   req.writeTo(dout);
   dout.flush();
 }
  public boolean tryWrite(MessageLite message) {
    try {
      codedOutput.writeRawLittleEndian32(message.getSerializedSize());
      message.writeTo(codedOutput);
      // writes to the underlying output stream
      codedOutput.flush();

      return connection.tryFlush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Esempio n. 3
0
    public void run() {
      try {
        MessageLite m = getResponseDefaultInstance(rpcType);
        assert rpcConfig.checkReceive(rpcType, m.getClass());
        RpcOutcome<?> rpcFuture = queue.getFuture(rpcType, coordinationId, m.getClass());
        Parser<?> parser = m.getParserForType();
        Object value = parser.parseFrom(new ByteBufInputStream(pBody, pBody.readableBytes()));
        rpcFuture.set(value, dBody);
        if (RpcConstants.EXTRA_DEBUGGING) {
          logger.debug("Updated rpc future {} with value {}", rpcFuture, value);
        }
      } catch (Exception ex) {
        logger.error("Failure while handling response.", ex);
      } finally {
        if (pBody != null) {
          pBody.release();
        }

        if (dBody != null) {
          dBody.release();
        }
      }
    }
 private static FileWriteAction makeProtoTextWriteAction(
     ActionOwner actionOwner, final MessageLite message, Artifact artifact) {
   return new FileWriteAction(
       actionOwner, artifact, message.toString(), /*makeExecutable =*/ false);
 }