Java Code Examples for org.apache.thrift.TApplicationException#getType()

The following examples show how to use org.apache.thrift.TApplicationException#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistributedLogClientImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
void handleTApplicationException(Throwable cause,
                                 Optional<StreamOp> op,
                                 SocketAddress addr,
                                 ProxyClient sc) {
    TApplicationException ex = (TApplicationException) cause;
    if (ex.getType() == TApplicationException.UNKNOWN_METHOD) {
        // if we encountered unknown method exception on thrift server, it means this proxy
        // has problem. we should remove it from routing service, clean up ownerships
        routingService.removeHost(addr, cause);
        onServerLeft(addr, sc);
        if (op.isPresent()) {
            ownershipCache.removeOwnerFromStream(op.get().stream, addr, cause.getMessage());
            doSend(op.get(), addr);
        }
    } else {
        handleException(cause, op, addr);
    }
}
 
Example 2
Source File: DistributedLogClientImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
void handleTApplicationException(Throwable cause,
                                 Optional<StreamOp> op,
                                 SocketAddress addr,
                                 ProxyClient sc) {
    TApplicationException ex = (TApplicationException) cause;
    if (ex.getType() == TApplicationException.UNKNOWN_METHOD) {
        // if we encountered unknown method exception on thrift server, it means this proxy
        // has problem. we should remove it from routing service, clean up ownerships
        routingService.removeHost(addr, cause);
        onServerLeft(addr, sc);
        if (op.isPresent()) {
            ownershipCache.removeOwnerFromStream(op.get().stream, addr, cause.getMessage());
            doSend(op.get(), addr);
        }
    } else {
        handleException(cause, op, addr);
    }
}
 
Example 3
Source File: ThriftHiveMetastore.java    From presto with Apache License 2.0 5 votes vote down vote up
private static boolean isUnknownMethodExceptionalResponse(Exception exception)
{
    if (!(exception instanceof TApplicationException)) {
        return false;
    }

    TApplicationException applicationException = (TApplicationException) exception;
    return applicationException.getType() == UNKNOWN_METHOD;
}
 
Example 4
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getExceptionString(Throwable t) {
  String typeMessage = null;
  if (t instanceof TTransportException) {
    TTransportException tte = (TTransportException)t;
    switch (tte.getType()) {
      case TTransportException.ALREADY_OPEN:
        typeMessage = "SOCKET ALREADY OPEN";
        break;
      case TTransportException.END_OF_FILE:
        typeMessage = "SOCKET END OF TRANSMISSION";
        break;
      case TTransportException.NOT_OPEN:
        typeMessage = "SOCKET NOT OPEN";
        break;
      case TTransportException.TIMED_OUT:
        typeMessage = "SOCKET TIMED OUT";
        break;
      default:
        typeMessage = "UNKNOWN SOCKET ERROR";
        break;
    }
  }
  else if (t instanceof TProtocolException) {
    TProtocolException tpe = (TProtocolException)t;
    switch (tpe.getType()) {
      case TProtocolException.BAD_VERSION:
        typeMessage = "BAD PROTOCOL VERSION";
        break;
      case TProtocolException.INVALID_DATA:
        typeMessage = "INVALID DATA IN PROTOCOL";
        break;
      case TProtocolException.NEGATIVE_SIZE:
        typeMessage = "NEGATIVE SIZE IN PROTOCOL";
        break;
      case TProtocolException.NOT_IMPLEMENTED:
        typeMessage = "NOT IMPLEMENTED";
        break;
      case TProtocolException.SIZE_LIMIT:
        typeMessage = "PROTOCOL SIZE LIMIT HIT";
        break;
      default:
        typeMessage = "UNKNOWN PROTOCOL ERROR";
        break;
    }
  }
  else if (t instanceof TApplicationException) {
    TApplicationException tae = (TApplicationException)t;
    switch (tae.getType()) {
      case TApplicationException.BAD_SEQUENCE_ID:
        typeMessage = "BAD SEQUENCE ID";
        break;
      case TApplicationException.INTERNAL_ERROR:
        typeMessage = "INTERNAL ERROR";
        break;
      case TApplicationException.INVALID_MESSAGE_TYPE:
        typeMessage = "INVALID MESSAGE TYPE";
        break;
      case TApplicationException.MISSING_RESULT:
        typeMessage = "MISSING RESULT";
        break;
      case TApplicationException.PROTOCOL_ERROR:
        typeMessage = "PROTOCOL ERROR";
        break;
      case TApplicationException.UNKNOWN_METHOD:
        typeMessage = "UNKNOWN METHOD";
        break;
      case TApplicationException.WRONG_METHOD_NAME:
        typeMessage = "WRONG METHOD NAME";
        break;
      default:
        typeMessage = "UNKNOWN APPLICATION ERROR";
        break;
    }
  }
  String message = t.getLocalizedMessage();
  if (message == null || message.length() == 0) {
    message = t.getClass().getName();
  }
  if (typeMessage != null) {
    return message + " [" + typeMessage + ']';
  }
  else {
    return message;
  }
}
 
Example 5
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getExceptionString(Throwable t) {
  String typeMessage = null;
  if (t instanceof TTransportException) {
    TTransportException tte = (TTransportException)t;
    switch (tte.getType()) {
      case TTransportException.ALREADY_OPEN:
        typeMessage = "SOCKET ALREADY OPEN";
        break;
      case TTransportException.END_OF_FILE:
        typeMessage = "SOCKET END OF TRANSMISSION";
        break;
      case TTransportException.NOT_OPEN:
        typeMessage = "SOCKET NOT OPEN";
        break;
      case TTransportException.TIMED_OUT:
        typeMessage = "SOCKET TIMED OUT";
        break;
      default:
        typeMessage = "UNKNOWN SOCKET ERROR";
        break;
    }
  }
  else if (t instanceof TProtocolException) {
    TProtocolException tpe = (TProtocolException)t;
    switch (tpe.getType()) {
      case TProtocolException.BAD_VERSION:
        typeMessage = "BAD PROTOCOL VERSION";
        break;
      case TProtocolException.INVALID_DATA:
        typeMessage = "INVALID DATA IN PROTOCOL";
        break;
      case TProtocolException.NEGATIVE_SIZE:
        typeMessage = "NEGATIVE SIZE IN PROTOCOL";
        break;
      case TProtocolException.NOT_IMPLEMENTED:
        typeMessage = "NOT IMPLEMENTED";
        break;
      case TProtocolException.SIZE_LIMIT:
        typeMessage = "PROTOCOL SIZE LIMIT HIT";
        break;
      default:
        typeMessage = "UNKNOWN PROTOCOL ERROR";
        break;
    }
  }
  else if (t instanceof TApplicationException) {
    TApplicationException tae = (TApplicationException)t;
    switch (tae.getType()) {
      case TApplicationException.BAD_SEQUENCE_ID:
        typeMessage = "BAD SEQUENCE ID";
        break;
      case TApplicationException.INTERNAL_ERROR:
        typeMessage = "INTERNAL ERROR";
        break;
      case TApplicationException.INVALID_MESSAGE_TYPE:
        typeMessage = "INVALID MESSAGE TYPE";
        break;
      case TApplicationException.MISSING_RESULT:
        typeMessage = "MISSING RESULT";
        break;
      case TApplicationException.PROTOCOL_ERROR:
        typeMessage = "PROTOCOL ERROR";
        break;
      case TApplicationException.UNKNOWN_METHOD:
        typeMessage = "UNKNOWN METHOD";
        break;
      case TApplicationException.WRONG_METHOD_NAME:
        typeMessage = "WRONG METHOD NAME";
        break;
      default:
        typeMessage = "UNKNOWN APPLICATION ERROR";
        break;
    }
  }
  String message = t.getLocalizedMessage();
  if (message == null || message.length() == 0) {
    message = t.getClass().getName();
  }
  if (typeMessage != null) {
    return message + " [" + typeMessage + ']';
  }
  else {
    return message;
  }
}