Package org.apache.thrift

Examples of org.apache.thrift.TApplicationException


            // 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


    {
        long start = nanoTime();

        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");
        }

        stats.addInvokeTime(nanosSince(start));
    }
View Full Code Here

            ThriftMethodHandler methodHandler = methods.get(method);

            try {
                if (methodHandler == null) {
                    throw new TApplicationException(UNKNOWN_METHOD, "Unknown method : '" + method + "'");
                }
                return methodHandler.invoke(protocolFactory, channel, sequenceId.getAndIncrement(), args);
            }
            catch (TException e) {
                Class<? extends TException> thrownType = e.getClass();
View Full Code Here

      scheduler.notifyScheduler();
      sessionNotifier.deleteSession(handle);

    } catch (RuntimeException e) {
      LOG.error("Error in sessionEnd of " + handle, e);
      throw new TApplicationException(e.getMessage());
    }
  }
View Full Code Here

      LOG.info("sessionUpdateInfo called for session: " + handle +
               " with info: " + info);
      sessionManager.heartbeat(handle);
      sessionManager.updateInfo(handle, info);
    } catch (RuntimeException e) {
      throw new TApplicationException(e.getMessage());
    }
  }
View Full Code Here

      InvalidSessionHandle, SafeModeException {
    checkSafeMode("sessionHeartbeat");
    try {
      sessionManager.heartbeat(handle);
    } catch (RuntimeException e) {
      throw new TApplicationException(e.getMessage());
    }
  }
View Full Code Here

    try {
      LOG.info ("Request " + requestList.size() +
          " resources from session: " + handle);
      if (!checkResourceRequestType(requestList)) {
        LOG.error ("Bad resource type from session: " + handle);
        throw new TApplicationException("Bad resource type");
      }
      if (!checkResourceRequestExcluded(requestList)) {
        LOG.error("Bad excluded hosts from session: " + handle);
        throw new TApplicationException("Requesting excluded hosts");
      }
      sessionManager.heartbeat(handle);
      List<ResourceRequestInfo> reqInfoList =
          new ArrayList<ResourceRequestInfo>(requestList.size());
      for (ResourceRequest request : requestList) {
        List<String> hosts = request.getHosts();
        List<RequestedNode> requestedNodes = null;
        if (hosts != null && hosts.size() > 0) {
          requestedNodes = new ArrayList<RequestedNode>(hosts.size());
          for (String host : hosts) {
            requestedNodes.add(nodeManager.resolve(host, request.type));
          }
        }
        ResourceRequestInfo info =
          new ResourceRequestInfo(request, requestedNodes);
        reqInfoList.add(info);
      }
      sessionManager.requestResource(handle, reqInfoList);
      for (ResourceRequest req : requestList) {
        metrics.requestResource(req.type);
      }
      scheduler.notifyScheduler();
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw new TApplicationException(e.getMessage());
    }
  }
View Full Code Here

        metrics.releaseResource(grant.type);
      }

      scheduler.notifyScheduler();
    } catch (RuntimeException e) {
      throw new TApplicationException(e.getMessage());
    }
  }
View Full Code Here

    final TMessage msg = in.readMessageBegin();
    final ProcessFunction<I, ? extends  TBase<?,?>> fn = functions.get(msg.name);
    if (fn == null) {
      TProtocolUtil.skip(in, TType.STRUCT);
      in.readMessageEnd();
      TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD,
          "Invalid method name: '"+msg.name+"'");
      out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
      x.write(out);
      out.writeMessageEnd();
      out.getTransport().flush();
      return true;
    }
    TUGIContainingTransport ugiTrans = (TUGIContainingTransport)in.getTransport();
View Full Code Here

    set_ugi_args args = (set_ugi_args)method.invoke(fn, new Object[0]);
    try {
      args.read(iprot);
    } catch (TProtocolException e) {
      iprot.readMessageEnd();
      TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR,
          e.getMessage());
      oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
      x.write(oprot);
      oprot.writeMessageEnd();
      oprot.getTransport().flush();
      return;
    }
    iprot.readMessageEnd();
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.