Example usage for org.apache.thrift.protocol TProtocolException TProtocolException

List of usage examples for org.apache.thrift.protocol TProtocolException TProtocolException

Introduction

In this page you can find the example usage for org.apache.thrift.protocol TProtocolException TProtocolException.

Prototype

public TProtocolException(Throwable cause) 

Source Link

Usage

From source file:backtype.storm.generated.HBMessageData.java

License:Apache License

@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 PATH:
            String path;//from  w w w  . j a  va  2 s.com
            path = iprot.readString();
            return path;
        case PULSE:
            HBPulse pulse;
            pulse = new HBPulse();
            pulse.read(iprot);
            return pulse;
        case BOOLVAL:
            Boolean boolval;
            boolval = iprot.readBool();
            return boolval;
        case RECORDS:
            HBRecords records;
            records = new HBRecords();
            records.read(iprot);
            return records;
        case NODES:
            HBNodes nodes;
            nodes = new HBNodes();
            nodes.read(iprot);
            return nodes;
        case MESSAGE_BLOB:
            ByteBuffer message_blob;
            message_blob = iprot.readBinary();
            return message_blob;
        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);
    }
}

From source file:backtype.storm.generated.SpecificAggregateStats.java

License:Apache License

@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 BOLT:
            BoltAggregateStats bolt;/*from  w  ww  . j a  v a 2s.c  o  m*/
            bolt = new BoltAggregateStats();
            bolt.read(iprot);
            return bolt;
        case SPOUT:
            SpoutAggregateStats spout;
            spout = new SpoutAggregateStats();
            spout.read(iprot);
            return spout;
        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);
    }
}

From source file:backtype.storm.generated.TopologyActionOptions.java

License:Apache License

@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 KILL_OPTIONS:
            KillOptions kill_options;//  w ww.ja v  a  2  s  . com
            kill_options = new KillOptions();
            kill_options.read(iprot);
            return kill_options;
        case REBALANCE_OPTIONS:
            RebalanceOptions rebalance_options;
            rebalance_options = new RebalanceOptions();
            rebalance_options.read(iprot);
            return rebalance_options;
        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);
    }
}

From source file:com.baidu.oped.apm.plugin.thrift.ThriftRequestProperty.java

License:Apache License

public void setTraceHeader(ThriftHeader headerKey, Object value) throws TException {
    byte headerType = headerKey.getType();
    if (headerType == TType.STRING) {
        // skipped Strings are read as byte buffer.
        // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
        this.thriftHeaders.put(headerKey, byteBufferToString((ByteBuffer) value));
    } else if (headerType == TType.I64) {
        this.thriftHeaders.put(headerKey, (Long) value);
    } else if (headerType == TType.I16) {
        this.thriftHeaders.put(headerKey, (Short) value);
    } else if (headerType == TType.BOOL) {
        this.thriftHeaders.put(headerKey, (Boolean) value);
    } else {//  ww  w  .jav  a2 s . c o m
        throw new TProtocolException("Invalid apm header type - " + headerType);
    }
}

From source file:com.baidu.oped.apm.plugin.thrift.ThriftRequestProperty.java

License:Apache License

public void writeTraceHeader(ThriftHeader headerKey, TProtocol oprot) throws TException {
    Object headerValue = this.thriftHeaders.get(headerKey);
    if (headerValue == null) {
        return;/*from   w  w w  .  j  a v a2 s  . c  o m*/
    }
    byte headerType = headerKey.getType();
    TField traceField = new TField(headerKey.name(), headerKey.getType(), headerKey.getId());
    oprot.writeFieldBegin(traceField);
    try {
        if (headerType == TType.STRING) {
            // these will be read as byte buffer although it's probably safe to just use writeString here.
            // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
            oprot.writeBinary(stringToByteBuffer((String) headerValue));
        } else if (headerType == TType.I64) {
            oprot.writeI64((Long) headerValue);
        } else if (headerType == TType.I16) {
            oprot.writeI16((Short) headerValue);
        } else if (headerType == TType.BOOL) {
            oprot.writeBool((Boolean) headerValue);
        } else {
            throw new TProtocolException("Invalid apm header type - " + headerType);
        }
    } finally {
        oprot.writeFieldEnd();
    }
}

From source file:com.bigdata.dastor.thrift.AuthenticationException.java

License:Apache License

public void validate() throws TException {
    // check for required fields
    if (why == null) {
        throw new TProtocolException("Required field 'why' was not present! Struct: " + toString());
    }/*from  w ww  . jav a  2 s .c  o m*/
}

From source file:com.bigdata.dastor.thrift.AuthenticationRequest.java

License:Apache License

public void validate() throws TException {
    // check for required fields
    if (credentials == null) {
        throw new TProtocolException("Required field 'credentials' was not present! Struct: " + toString());
    }//from   w  ww  .ja  va 2  s . c  o  m
}

From source file:com.bigdata.dastor.thrift.Column.java

License:Apache License

public void read(TProtocol iprot) throws TException {
    TField field;/* w w  w .ja va2  s . c  o m*/
    iprot.readStructBegin();
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // NAME
            if (field.type == TType.STRING) {
                this.name = iprot.readBinary();
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // VALUE
            if (field.type == TType.STRING) {
                this.value = iprot.readBinary();
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // TIMESTAMP
            if (field.type == TType.I64) {
                this.timestamp = iprot.readI64();
                setTimestampIsSet(true);
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    if (!isSetTimestamp()) {
        throw new TProtocolException(
                "Required field 'timestamp' was not found in serialized data! Struct: " + toString());
    }
    validate();
}

From source file:com.bigdata.dastor.thrift.Column.java

License:Apache License

public void validate() throws TException {
    // check for required fields
    if (name == null) {
        throw new TProtocolException("Required field 'name' was not present! Struct: " + toString());
    }//from  ww w .ja  v a 2s.c  om
    if (value == null) {
        throw new TProtocolException("Required field 'value' was not present! Struct: " + toString());
    }
    // alas, we cannot check 'timestamp' because it's a primitive and you chose the non-beans generator.
}

From source file:com.bigdata.dastor.thrift.ColumnParent.java

License:Apache License

public void validate() throws TException {
    // check for required fields
    if (column_family == null) {
        throw new TProtocolException("Required field 'column_family' was not present! Struct: " + toString());
    }/*  w  w w .  ja va  2s .c  o m*/
}