• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TApplicationException类的典型用法和代码示例

java 11次浏览

本文整理汇总了Java中org.apache.thrift.TApplicationException的典型用法代码示例。如果您正苦于以下问题:Java TApplicationException类的具体用法?Java TApplicationException怎么用?Java TApplicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TApplicationException类属于org.apache.thrift包,在下文中一共展示了TApplicationException类的36个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invoke

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

	Object thriftProxy = ThriftUtil.buildClient(getServiceInterface(), protocolFactory.getProtocol(getTransport()));

	ClassLoader originalClassLoader = overrideThreadContextClassLoader();
	try {
		return methodInvocation.getMethod().invoke(thriftProxy, methodInvocation.getArguments());
	} catch (InvocationTargetException e) {
		Throwable targetEx = e.getTargetException();
		if (targetEx instanceof InvocationTargetException) {
			targetEx = ((InvocationTargetException) targetEx).getTargetException();
		}
		if (targetEx instanceof TApplicationException && ((TApplicationException) targetEx).getType() == TApplicationException.MISSING_RESULT) {
			return null;
		} else {
			throw targetEx;
		}
	} catch (Throwable ex) {
		throw new RemoteProxyFailureException("Failed to invoke Thrift proxy for remote service [" + getServiceUrl() + "]", ex);
	} finally {
		resetThreadContextClassLoader(originalClassLoader);
	}
}
 

开发者ID:funtl,
项目名称:framework,
代码行数:25,
代码来源:ThriftClientInterceptor.java

示例2: process

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
@Override
public boolean process(TProtocol in, TProtocol out) throws TException {
	TMessage msg = in.readMessageBegin();
	Controller<?, ?> fn = (Controller<?, ?>) this.beanFactory
			.getBean(msg.name);
	if (fn == null) {
		if (LOGGER.isWarnEnabled()) {
			LOGGER.warn("Invalid request: failed to find interface="
					+ msg.name + ", from: " + getInetAddress(in));
		}

		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;
	}
	process(msg.seqid, msg.name, in, out, fn);
	return true;
}
 

开发者ID:jigsaw-projects,
项目名称:jigsaw-payment,
代码行数:27,
代码来源:TProtobufProcessor.java

示例3: process

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
@Override
public final boolean process(final TProtocol in, final TProtocol out)
    throws TException {
  final TMessage msg = in.readMessageBegin();
  final ProcessFunction<LocatorServiceImpl, ?> fn = this.fnMap
      .get(msg.name);
  if (fn != null) {
    fn.process(msg.seqid, in, out, this.inst);
    // terminate connection on receiving closeConnection
    // direct class comparison should be the fastest way
    return fn.getClass() != LocatorService.Processor.closeConnection.class;
  }
  else {
    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;
  }
}
 

开发者ID:gemxd,
项目名称:gemfirexd-oss,
代码行数:27,
代码来源:LocatorServiceImpl.java

示例4: read

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
/**
 * 读取操作
 */
@Override
public void read(TProtocol iprot) throws TException {
	if (!"org.apache.thrift.scheme.StandardScheme".equals(iprot.getScheme().getName()))
		throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
	TField schemeField;
	iprot.readStructBegin();
	while (Boolean.TRUE) {
		schemeField = iprot.readFieldBegin();
		if (schemeField.type == TType.STOP)
			break;
		if (schemeField.type == TType.STRING)
			str = iprot.readString();
		else
			throw new TApplicationException("field type must be 'String' !");
		iprot.readFieldEnd();
	}
	iprot.readStructEnd();
}
 

开发者ID:venwyhk,
项目名称:ikasoa,
代码行数:22,
代码来源:AbstractThriftBase.java

示例5: handleTApplicationException

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
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);
    }
}
 

开发者ID:twitter,
项目名称:distributedlog,
代码行数:19,
代码来源:DistributedLogClientImpl.java

示例6: releaseResource

点赞 3

import org.apache.thrift.TApplicationException; //导入依赖的package包/类
@Override
public void releaseResource(String handle, List<Integer> idList)
  throws TException, InvalidSessionHandle, SafeModeException {
  checkSafeMode("releaseResource");
  try {
    LOG.info("Release " + idList.size() + " resources from session: " +
             handle);
    sessionManager.heartbeat(handle);
    Collection<ResourceGrant> canceledGrants =
      sessionManager.releaseResource(handle, idList);

    if (canceledGrants == null) {
      // LOG.info("No canceled grants for session " + handle);
      return;
    }

    for (ResourceGrant grant: canceledGrants) {
      nodeManager.cancelGrant(grant.nodeName, handle, grant.id);
      metrics.releaseResource(grant.type);
    }

    scheduler.notifyScheduler();
  } catch (RuntimeException e) {
    throw new TApplicationException(e.getMessage());
  }
}
 

开发者ID:rhli,
项目名称:hadoop-EAR,
代码行数:27,
代码来源:ClusterManager.java

示例7: createTranslator

点赞 3


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)