Example usage for org.apache.thrift TApplicationException readFrom

List of usage examples for org.apache.thrift TApplicationException readFrom

Introduction

In this page you can find the example usage for org.apache.thrift TApplicationException readFrom.

Prototype

public static TApplicationException readFrom(TProtocol iprot) throws TException 

Source Link

Document

Convenience factory method for constructing a TApplicationException given a TProtocol input

Usage

From source file:io.airlift.drift.transport.netty.server.TestDriftNettyServerTransport.java

License:Apache License

private static ResultCode readLogResponse(int expectedSequenceId, TProtocol protocol) throws TException {
    TMessage message = protocol.readMessageBegin();
    if (message.type == TMessageType.EXCEPTION) {
        throw TApplicationException.readFrom(protocol);
    }//  ww w. j ava 2s .c  o m
    if (message.type != TMessageType.REPLY) {
        throw new TApplicationException(MISSING_RESULT, "request failed");
    }
    if (message.seqid != expectedSequenceId) {
        throw new TApplicationException(BAD_SEQUENCE_ID,
                format("expected sequenceId %s, but received %s", expectedSequenceId, message.seqid));
    }

    Log_result result = new Log_result();
    result.read(protocol);
    protocol.readMessageEnd();
    return result.success;
}

From source file:zipkin2.reporter.libthrift.InternalScribeCodec.java

License:Apache License

/** Returns false if the scribe response was try later. */
public static boolean readLogResponse(int seqid, TBinaryProtocol iprot) throws TException {
    TMessage msg = iprot.readMessageBegin();
    if (msg.type == TMessageType.EXCEPTION) {
        throw TApplicationException.readFrom(iprot);
    } else if (msg.seqid != seqid) {
        throw new TApplicationException(BAD_SEQUENCE_ID, "Log failed: out of sequence response");
    }//from w  ww  . j  a  va  2  s. co  m
    return parseResponse(iprot);
}