org.apache.thrift.protocol.TProtocolException类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.6k)|赞(0)|评价(0)|浏览(483)

本文整理了Java中org.apache.thrift.protocol.TProtocolException类的一些代码示例,展示了TProtocolException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TProtocolException类的具体详情如下:
包路径:org.apache.thrift.protocol.TProtocolException
类名称:TProtocolException

TProtocolException介绍

[英]Protocol exceptions.
[中]协议例外。

代码示例

代码示例来源:origin: apache/hbase

public void read(org.apache.thrift.protocol.TProtocol iprot, TTimeRange struct) throws org.apache.thrift.TException {
 org.apache.thrift.protocol.TField schemeField;
 iprot.readStructBegin();
 while (true)
  schemeField = iprot.readFieldBegin();
  if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
   break;
   case 1: // MIN_STAMP
    if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
     struct.minStamp = iprot.readI64();
     struct.setMinStampIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
     struct.setMaxStampIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  iprot.readFieldEnd();
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'minStamp' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'maxStamp' was not found in serialized data! Struct: " + toString());

代码示例来源:origin: twitter/distributedlog

public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
 {
  write_args args = new write_args();
  try {
   args.read(iprot);
  } catch (TProtocolException e) {
   iprot.readMessageEnd();
   TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
   oprot.writeMessageBegin(new TMessage("write", TMessageType.EXCEPTION, seqid));
   x.write(oprot);
   oprot.writeMessageEnd();
   oprot.getTransport().flush();
   return;
  }
  iprot.readMessageEnd();
  write_result result = new write_result();
  result.success = iface_.write(args.stream, args.data);
  
  oprot.writeMessageBegin(new TMessage("write", TMessageType.REPLY, seqid));
  result.write(oprot);
  oprot.writeMessageEnd();
  oprot.getTransport().flush();
 }
}

代码示例来源:origin: line/armeria

public void read(org.apache.thrift.protocol.TProtocol iprot, TTextProtocolTestMsg struct) throws org.apache.thrift.TException {
 org.apache.thrift.protocol.TField schemeField;
 iprot.readStructBegin();
 while (true)
  schemeField = iprot.readFieldBegin();
  if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
   break;
     struct.setBIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
     struct.setNIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'a' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'b' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'n' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'f' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'g' was not found in serialized data! Struct: " + toString());

代码示例来源:origin: alibaba/jstorm

case INT_ARG:
  Integer int_arg;
  int_arg = iprot.readI32();
  return int_arg;
 case LONG_ARG:
  Long long_arg;
  long_arg = iprot.readI64();
  return long_arg;
 case STRING_ARG:
  String string_arg;
  string_arg = iprot.readString();
  return string_arg;
 case BOOL_ARG:
throw new TProtocolException("Couldn't find a field with field id " + fieldID);

代码示例来源:origin: apache/hive

@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case I32_VALUE:
    Integer i32Value;
    i32Value = iprot.readI32();
    return i32Value;
   case STRING_VALUE:
    String stringValue;
    stringValue = iprot.readString();
    return stringValue;
   default:
    throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: apache/hbase

public void validate() throws org.apache.thrift.TException {
 // check for required fields
 if (family == null) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
 }
 if (qualifier == null) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
 }
 // check for sub-struct validity
}

代码示例来源:origin: line/armeria

@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case F1:
    ByteBuffer f1;
    f1 = iprot.readBinary();
    return f1;
   case F2:
    Integer f2;
    f2 = iprot.readI32();
    return f2;
   default:
    throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: alibaba/jstorm

@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case SERIALIZED_JAVA:
    ByteBuffer serialized_java;
    serialized_java = iprot.readBinary();
    return serialized_java;
   case SHELL:
    ShellComponent shell;
    shell = new ShellComponent();
    shell.read(iprot);
    return shell;
   case JAVA_OBJECT:
    JavaObject java_object;
    java_object = new JavaObject();
    java_object.read(iprot);
    return java_object;
   default:
    throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: line/armeria

public void read(org.apache.thrift.protocol.TProtocol iprot, TTextProtocolTestMsg struct) throws org.apache.thrift.TException {
 org.apache.thrift.protocol.TField schemeField;
 iprot.readStructBegin();
 while (true)
  schemeField = iprot.readFieldBegin();
  if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
   break;
     struct.setBIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
     struct.setNIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'a' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'b' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'n' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'f' was not found in serialized data! Struct: " + toString());
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'g' was not found in serialized data! Struct: " + toString());

代码示例来源:origin: line/armeria

@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case STRING_VAL:
    String stringVal;
    stringVal = iprot.readString();
    return stringVal;
   case ENUM_VAL:
    FooEnum enumVal;
    enumVal = com.linecorp.armeria.service.test.thrift.main.FooEnum.findByValue(iprot.readI32());
    return enumVal;
   default:
    throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: apache/hbase

public void validate() throws org.apache.thrift.TException {
 // check for required fields
 if (name == null) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' was not present! Struct: " + toString());
 }
 // check for sub-struct validity
}

代码示例来源:origin: line/armeria

@Override
protected java.lang.Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case F1:
    java.nio.ByteBuffer f1;
    f1 = iprot.readBinary();
    return f1;
   case F2:
    java.lang.Integer f2;
    f2 = iprot.readI32();
    return f2;
   default:
    throw new java.lang.IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new org.apache.thrift.protocol.TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: pinterest/secor

public void read(TProtocol iprot) throws TException {
 TField field;
 iprot.readStructBegin();
 while (true)
  field = iprot.readFieldBegin();
  if (field.type == TType.STOP) { 
   break;
   case 1: // TIMESTAMP
    if (field.type == TType.I64) {
     this.timestamp = iprot.readI64();
     setTimestampIsSet(true);
    } else { 
     TProtocolUtil.skip(iprot, field.type);
     this.requiredField = iprot.readString();
    } else { 
     TProtocolUtil.skip(iprot, field.type);
     this.optionalField = iprot.readString();
    } else { 
     TProtocolUtil.skip(iprot, field.type);
  throw new TProtocolException("Required field 'timestamp' was not found in serialized data! Struct: " + toString());

代码示例来源:origin: twitter/distributedlog

public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
 {
  truncate_args args = new truncate_args();
  try {
   args.read(iprot);
  } catch (TProtocolException e) {
   iprot.readMessageEnd();
   TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
   oprot.writeMessageBegin(new TMessage("truncate", TMessageType.EXCEPTION, seqid));
   x.write(oprot);
   oprot.writeMessageEnd();
   oprot.getTransport().flush();
   return;
  }
  iprot.readMessageEnd();
  truncate_result result = new truncate_result();
  result.success = iface_.truncate(args.stream, args.dlsn, args.ctx);
  
  oprot.writeMessageBegin(new TMessage("truncate", TMessageType.REPLY, seqid));
  result.write(oprot);
  oprot.writeMessageEnd();
  oprot.getTransport().flush();
 }
}

代码示例来源:origin: org.apache.thrift/libthrift

prot.readBool();
break;
prot.readByte();
break;
prot.readI16();
break;
  break;
 skip(prot, field.type, maxDepth - 1);
 prot.readFieldEnd();
TMap map = prot.readMapBegin();
for (int i = 0; i < map.size; i++) {
 skip(prot, map.keyType, maxDepth - 1);
 skip(prot, map.valueType, maxDepth - 1);
prot.readMapEnd();
throw new TProtocolException(TProtocolException.INVALID_DATA,
              "Unrecognized type " + type);

代码示例来源:origin: line/armeria

@Override
protected java.lang.Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
 _Fields setField = _Fields.findByThriftId(fieldID);
 if (setField != null) {
  switch (setField) {
   case STRING_VAL:
    java.lang.String stringVal;
    stringVal = iprot.readString();
    return stringVal;
   case ENUM_VAL:
    FooEnum enumVal;
    enumVal = com.linecorp.armeria.service.test.thrift.main.FooEnum.findByValue(iprot.readI32());
    return enumVal;
   default:
    throw new java.lang.IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
  }
 } else {
  throw new org.apache.thrift.protocol.TProtocolException("Couldn't find a field with field id " + fieldID);
 }
}

代码示例来源:origin: alibaba/jstorm

public void validate() throws org.apache.thrift.TException {
 // check for required fields
 if (!is_set_inputs()) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'inputs' is unset! Struct:" + toString());
 }
 if (!is_set_streams()) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'streams' is unset! Struct:" + toString());
 }
 // check for sub-struct validity
}

代码示例来源:origin: apache/hbase

public void read(org.apache.thrift.protocol.TProtocol iprot, THRegionInfo struct) throws org.apache.thrift.TException {
 org.apache.thrift.protocol.TField schemeField;
 iprot.readStructBegin();
 while (true)
  schemeField = iprot.readFieldBegin();
  if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
   break;
   case 1: // REGION_ID
    if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
     struct.regionId = iprot.readI64();
     struct.setRegionIdIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
     struct.setTableNameIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
     struct.setStartKeyIsSet(true);
    } else { 
     org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'regionId' was not found in serialized data! Struct: " + toString());

代码示例来源:origin: twitter/distributedlog

public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
 {
  handshakeWithClientInfo_args args = new handshakeWithClientInfo_args();
  try {
   args.read(iprot);
  } catch (TProtocolException e) {
   iprot.readMessageEnd();
   TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
   oprot.writeMessageBegin(new TMessage("handshakeWithClientInfo", TMessageType.EXCEPTION, seqid));
   x.write(oprot);
   oprot.writeMessageEnd();
   oprot.getTransport().flush();
   return;
  }
  iprot.readMessageEnd();
  handshakeWithClientInfo_result result = new handshakeWithClientInfo_result();
  result.success = iface_.handshakeWithClientInfo(args.clientInfo);
  
  oprot.writeMessageBegin(new TMessage("handshakeWithClientInfo", TMessageType.REPLY, seqid));
  result.write(oprot);
  oprot.writeMessageEnd();
  oprot.getTransport().flush();
 }
}

代码示例来源:origin: alibaba/jstorm

public void validate() throws org.apache.thrift.TException {
 // check for required fields
 if (!is_set_name()) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString());
 }
 if (!is_set_bits()) {
  throw new org.apache.thrift.protocol.TProtocolException("Required field 'bits' is unset! Struct:" + toString());
 }
 // check for sub-struct validity
}

相关文章

微信公众号

最新文章

更多