Ejemplo n.º 1
0
  /**
   * 实际解析协议模板
   *
   * @param protocol
   * @param template
   * @return
   */
  @SuppressWarnings("unchecked")
  public <T extends GeneratedMessage> T parseProtocol(HawkProtocol protocol, T template) {
    if (protocol != null && template != null) {
      try {
        T pbProtocol = template;
        Parser<T> parser = (Parser<T>) parsers.get(template.getClass().getName());
        if (parser == null) {
          parser = (Parser<T>) template.getClass().getField("PARSER").get(template);
          parsers.put(template.getClass().getName(), parser);
        }

        if (protocol.getSize() > 0) {
          pbProtocol =
              parser.parseFrom(protocol.getOctets().getBuffer().array(), 0, protocol.getSize());
        }

        logProtocolBuilder(protocol, pbProtocol);
        return pbProtocol;
      } catch (Exception e) {
        HawkException.catchException(e);
        // 抛出运行时异常
        throw new RuntimeException("protocol parse exception: " + protocol.getType());
      }
    }
    return null;
  }
Ejemplo n.º 2
0
 public static <T> T get(ByteBuf pBody, Parser<T> parser) throws RpcException {
   try {
     ByteBufInputStream is = new ByteBufInputStream(pBody);
     return parser.parseFrom(is);
   } catch (InvalidProtocolBufferException e) {
     throw new RpcException(
         String.format(
             "Failure while decoding message with parser of type. %s",
             parser.getClass().getCanonicalName()),
         e);
   }
 }
Ejemplo n.º 3
0
 public static com.hailiang.study.codec.demo01.protobuf.SubscribeRespProto.SubscribeResp
     parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
   return PARSER.parseFrom(input, extensionRegistry);
 }
Ejemplo n.º 4
0
 public static com.hailiang.study.codec.demo01.protobuf.SubscribeRespProto.SubscribeResp
     parseFrom(
         com.google.protobuf.ByteString data,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
 }
Ejemplo n.º 5
0
 @Override
 protected T doNext() {
   try {
     return parser.parseDelimitedFrom(fileInputStream);
   } catch (InvalidProtocolBufferException e) {
     Throwables.propagate(e);
     // actually never reached
     return null;
   }
 }
Ejemplo n.º 6
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();
        }
      }
    }
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   com.chaoslabgames.packet.UpdateMoverEventPkg parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage = (com.chaoslabgames.packet.UpdateMoverEventPkg) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 8
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   com.cloudata.blockstore.IscsiProto.LogEntry parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage = (com.cloudata.blockstore.IscsiProto.LogEntry) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 9
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   com.github.jsdossier.proto.JsTypeRenderSpec parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage = (com.github.jsdossier.proto.JsTypeRenderSpec) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 10
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   messages.ScriptedProvider parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage = (messages.ScriptedProvider) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   akka.persistence.kafka.journal.EventFormats.EventFormat parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (akka.persistence.kafka.journal.EventFormats.EventFormat) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   com.google.genomics.v1.ImportReadGroupSetsRequest parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (com.google.genomics.v1.ImportReadGroupSetsRequest) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 13
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   cn.klzhong.samples.proto.hello.Hello.HelloResponse parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (cn.klzhong.samples.proto.hello.Hello.HelloResponse) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 14
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta) e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 15
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts)
             e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 16
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   org.apache.hadoop.hbase.protobuf.generated.TracingProtos.RPCTInfo parsedMessage = null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (org.apache.hadoop.hbase.protobuf.generated.TracingProtos.RPCTInfo)
             e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 17
0
 public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   com.hailiang.study.codec.demo01.protobuf.SubscribeRespProto.SubscribeResp parsedMessage =
       null;
   try {
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
   } catch (com.google.protobuf.InvalidProtocolBufferException e) {
     parsedMessage =
         (com.hailiang.study.codec.demo01.protobuf.SubscribeRespProto.SubscribeResp)
             e.getUnfinishedMessage();
     throw e;
   } finally {
     if (parsedMessage != null) {
       mergeFrom(parsedMessage);
     }
   }
   return this;
 }
Ejemplo n.º 18
0
 public static org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts parseFrom(
     com.google.protobuf.ByteString data)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
 }
Ejemplo n.º 19
0
 public static org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta parseFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   return PARSER.parseFrom(input, extensionRegistry);
 }
Ejemplo n.º 20
0
 public static org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta parseDelimitedFrom(
     java.io.InputStream input) throws java.io.IOException {
   return PARSER.parseDelimitedFrom(input);
 }
Ejemplo n.º 21
0
 public static org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta parseFrom(
     byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
 }
Ejemplo n.º 22
0
 public static org.simplefs.fs.meta.serial.proto.FileMetaProtos.FileMeta parseFrom(
     com.google.protobuf.ByteString data)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
 }
Ejemplo n.º 23
0
 public static com.cloudata.blockstore.IscsiProto.LogEntry parseFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   return PARSER.parseFrom(input, extensionRegistry);
 }
Ejemplo n.º 24
0
 public static com.cloudata.blockstore.IscsiProto.LogEntry parseDelimitedFrom(
     java.io.InputStream input) throws java.io.IOException {
   return PARSER.parseDelimitedFrom(input);
 }
Ejemplo n.º 25
0
 public static com.cloudata.blockstore.IscsiProto.LogEntry parseFrom(
     byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
 }
Ejemplo n.º 26
0
 public static com.cloudata.blockstore.IscsiProto.LogEntry parseFrom(
     com.google.protobuf.ByteString data)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data);
 }
Ejemplo n.º 27
0
 public static org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts parseFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   return PARSER.parseFrom(input, extensionRegistry);
 }
Ejemplo n.º 28
0
 public static org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts
     parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
   return PARSER.parseDelimitedFrom(input);
 }
Ejemplo n.º 29
0
 public static org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts parseFrom(
     byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws com.google.protobuf.InvalidProtocolBufferException {
   return PARSER.parseFrom(data, extensionRegistry);
 }
Ejemplo n.º 30
0
 public static messages.ScriptedProvider parseFrom(
     com.google.protobuf.CodedInputStream input,
     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     throws java.io.IOException {
   return PARSER.parseFrom(input, extensionRegistry);
 }