Package org.apache.thrift

Examples of org.apache.thrift.TApplicationException


    private void waitForResponse(TProtocol in, int sequenceId)
            throws TException
    {
        TMessage message = in.readMessageBegin();
        if (message.type == EXCEPTION) {
            TApplicationException exception = TApplicationException.read(in);
            in.readMessageEnd();
            throw exception;
        }
        if (message.type != REPLY) {
            throw new TApplicationException(INVALID_MESSAGE_TYPE,
                                            "Received invalid message type " + message.type + " from server");
        }
        if (!message.name.equals(this.name)) {
            throw new TApplicationException(WRONG_METHOD_NAME,
                                            "Wrong method name in reply: expected " + this.name + " but received " + message.name);
        }
        if (message.seqid != sequenceId) {
            throw new TApplicationException(BAD_SEQUENCE_ID, name + " failed: out of sequence response");
        }
    }
View Full Code Here


        try {
            // lookup method
            ThriftMethodProcessor method = methods.get(methodName);
            if (method == null) {
                TProtocolUtil.skip(in, TType.STRUCT);
                throw new TApplicationException(UNKNOWN_METHOD, "Invalid method name: '" + methodName + "'");
            }

            switch (message.type) {
                case TMessageType.CALL:
                case TMessageType.ONEWAY:
                    // Ideally we'd check the message type here to make the presence/absence of
                    // the "oneway" keyword annotating the method matches the message type.
                    // Unfortunately most clients send both one-way and two-way messages as CALL
                    // message type instead of using ONEWAY message type, and servers ignore the
                    // difference.
                    break;

                default:
                    throw new TApplicationException(INVALID_MESSAGE_TYPE,
                                                    "Received invalid message type " + message.type + " from client");
            }

            // invoke method
            String qualifiedMethodName = method.getQualifiedName();
View Full Code Here

            ThriftMethodHandler methodHandler = methods.get(method);

            try {
                if (methodHandler == null) {
                    throw new TApplicationException(UNKNOWN_METHOD, "Unknown method : '" + method + "'");
                }
                ClientContextChain context = new ClientContextChain(eventHandlers, methodHandler.getQualifiedName());
                try {
                    return methodHandler.invoke(channel,
                                                inputTransport,
View Full Code Here

            try {
                Thread.sleep(100);
                logEntries.addAll(messages);
            }
            catch (InterruptedException e) {
                throw new TApplicationException(TApplicationException.UNKNOWN);
            }
            return com.facebook.swift.service.scribe.ResultCode.OK;
        }
View Full Code Here

                                          exceptionCodec.getCodec(),
                                          t);
                            contextChain.postWriteException(t);
                        } else {
                            // unexpected exception
                            TApplicationException applicationException =
                                    new TApplicationException(INTERNAL_ERROR,
                                                              "Internal error processing " + method.getName());
                            applicationException.initCause(t);
                            LOG.error("Internal error processing {}", method.getName(), t);

                            // Application exceptions are sent to client, and the connection can be reused
                            out.writeMessageBegin(new TMessage(name, TMessageType.EXCEPTION, sequenceId));
                            applicationException.write(out);
                            out.writeMessageEnd();
                            out.getTransport().flush();

                            contextChain.postWriteException(applicationException);
                        }
View Full Code Here

        }
        catch (TProtocolException e) {
            // TProtocolException is the only recoverable exception
            // Other exceptions may have left the input stream in corrupted state so we must
            // tear down the socket.
            throw new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
        }
    }
View Full Code Here

            // TODO: check for non-null return from a void function?
            return null;
        }

        if (results == null) {
            throw new TApplicationException(TApplicationException.MISSING_RESULT, name + " failed: unknown result");
        }
        return results;
    }
View Full Code Here

    private void waitForResponse(TProtocol in, int sequenceId)
            throws TException
    {
        TMessage message = in.readMessageBegin();
        if (message.type == EXCEPTION) {
            TApplicationException exception = TApplicationException.read(in);
            in.readMessageEnd();
            throw exception;
        }
        if (message.type != REPLY) {
            throw new TApplicationException(INVALID_MESSAGE_TYPE,
                                            "Received invalid message type " + message.type + " from server");
        }
        if (!message.name.equals(this.name)) {
            throw new TApplicationException(WRONG_METHOD_NAME,
                                            "Wrong method name in reply: expected " + this.name + " but received " + message.name);
        }
        if (message.seqid != sequenceId) {
            throw new TApplicationException(BAD_SEQUENCE_ID, name + " failed: out of sequence response");
        }
    }
View Full Code Here

            // lookup method
            ThriftMethodProcessor method = methods.get(methodName);
            if (method == null) {
                TProtocolUtil.skip(in, TType.STRUCT);
                throw new TApplicationException(UNKNOWN_METHOD, "Invalid method name: '" + methodName + "'");
            }

            switch (message.type) {
                case TMessageType.CALL:
                case TMessageType.ONEWAY:
                    // Ideally we'd check the message type here to make the presence/absence of
                    // the "oneway" keyword annotating the method matches the message type.
                    // Unfortunately most clients send both one-way and two-way messages as CALL
                    // message type instead of using ONEWAY message type, and servers ignore the
                    // difference.
                    break;

                default:
                    throw new TApplicationException(INVALID_MESSAGE_TYPE,
                                                    "Received invalid message type " + message.type + " from client");
            }

            // invoke method
            final ContextChain context = new ContextChain(eventHandlers, method.getQualifiedName(), requestContext);
View Full Code Here

            try {
                processRequest(ctx, message, messageTransport, inProtocol, outProtocol);
            }
            catch (RejectedExecutionException ex) {
                TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR,
                        "Server overloaded");
                sendTApplicationException(x, ctx, message, messageTransport, inProtocol, outProtocol);
            }
        }
        else {
View Full Code Here

TOP

Related Classes of org.apache.thrift.TApplicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.