Codota Logo
RpcException
Code IndexAdd Codota to your IDE (free)

How to use
RpcException
in
com.alibaba.dubbo.rpc

Best Java code snippets using com.alibaba.dubbo.rpc.RpcException (Showing top 20 results out of 315)

  • Common ways to obtain RpcException
private void myMethod () {
RpcException r =
  • Codota IconString str;new RpcException(str)
  • Codota IconString str;Throwable cause;new RpcException(str, cause)
  • Codota IconThrowable cause;new RpcException(cause)
  • Smart code suggestions by Codota
}
origin: liuyangming/ByteTCC

public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
  if (invokers == null || invokers.isEmpty()) {
    throw new RpcException("No invoker is found!");
  }
  int lengthOfInvokerList = invokers == null ? 0 : invokers.size();
  return invokers.get(random.nextInt(lengthOfInvokerList));
}
origin: openzipkin/brave

static void onError(Throwable error, Span span) {
 span.error(error);
 if (error instanceof RpcException) {
  span.tag("dubbo.error_code", Integer.toString(((RpcException) error).getCode()));
 }
}
origin: com.alibaba/dubbo

@SuppressWarnings({"unchecked", "rawtypes"})
private Result doMockInvoke(Invocation invocation, RpcException e) {
  Result result = null;
  Invoker<T> minvoker;
  List<Invoker<T>> mockInvokers = selectMockInvoker(invocation);
  if (mockInvokers == null || mockInvokers.isEmpty()) {
    minvoker = (Invoker<T>) new MockInvoker(directory.getUrl());
  } else {
    minvoker = mockInvokers.get(0);
  }
  try {
    result = minvoker.invoke(invocation);
  } catch (RpcException me) {
    if (me.isBiz()) {
      result = new RpcResult(me.getCause());
    } else {
      throw new RpcException(me.getCode(), getMockExceptionMessage(e, me), me.getCause());
    }
  } catch (Throwable me) {
    throw new RpcException(getMockExceptionMessage(e, me), me.getCause());
  }
  return result;
}
origin: com.alibaba/dubbo

  exception = new RpcException("Failed to register service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
  logger.warn(exception.getMessage(), exception);
} else {
  throw exception;
origin: com.alibaba/dubbo

protected RpcException getRpcException(Class<?> type, URL url, Invocation invocation, Throwable e) {
  RpcException re = new RpcException("Failed to invoke remote service: " + type + ", method: "
      + invocation.getMethodName() + ", cause: " + e.getMessage(), e);
  re.setCode(getErrorCode(e));
  return re;
}
origin: linux-china/dubbo3

  public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
    checkInvokers(invokers, invocation);
    Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
    try {
      return invoker.invoke(invocation);
    } catch (Throwable e) {
      if (e instanceof RpcException && ((RpcException)e).isBiz()) { // biz exception.
        throw (RpcException) e;
      }
      throw new RpcException(e instanceof RpcException ? ((RpcException)e).getCode() : 0, "Failfast invoke providers " + invoker.getUrl() + " " + loadbalance.getClass().getSimpleName() + " select from all providers " + invokers + " for service " + getInterface().getName() + " method " + invocation.getMethodName() + " on consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
    }
  }
}
origin: linux-china/dubbo3

if (ret instanceof Throwable) {
  Throwable e = (Throwable) ret;
  throw new RpcException(e instanceof RpcException ? ((RpcException)e).getCode() : 0, "Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
throw new RpcException("Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e);
origin: remoting/dubbox

public Result invoke(Invocation inv) throws RpcException {
  if(destroyed) {
    throw new RpcException("Rpc invoker for service " + this + " on consumer " + NetUtils.getLocalHost() 
                    + " use dubbo version " + Version.getVersion()
                    + " is DESTROYED, can not be invoked any more!");
    } else {
      if (te instanceof RpcException) {
        ((RpcException) te).setCode(RpcException.BIZ_EXCEPTION);
    if (e.isBiz()) {
      return new RpcResult(e);
    } else {
origin: com.alibaba/dubbo

  @Override
  protected Result doInvoke(Invocation invocation) throws Throwable {
    try {
      Result result = target.invoke(invocation);
      Throwable e = result.getException();
      if (e != null) {
        for (Class<?> rpcException : rpcExceptions) {
          if (rpcException.isAssignableFrom(e.getClass())) {
            throw getRpcException(type, url, invocation, e);
          }
        }
      }
      return result;
    } catch (RpcException e) {
      if (e.getCode() == RpcException.UNKNOWN_EXCEPTION) {
        e.setCode(getErrorCode(e.getCause()));
      }
      throw e;
    } catch (Throwable e) {
      throw getRpcException(type, url, invocation, e);
    }
  }
};
origin: com.alibaba/dubbo

@Override
public Response toResponse(RpcException e) {
  // TODO do more sophisticated exception handling and output
  if (e.getCause() instanceof ConstraintViolationException) {
    return handleConstraintViolationException((ConstraintViolationException) e.getCause());
  }
  // we may want to avoid exposing the dubbo exception details to certain clients
  // TODO for now just do plain text output
  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Internal server error: " + e.getMessage()).type(ContentType.TEXT_PLAIN_UTF_8).build();
}
origin: com.alibaba/dubbo

} else {
  if (te instanceof RpcException) {
    ((RpcException) te).setCode(RpcException.BIZ_EXCEPTION);
if (e.isBiz()) {
  return new RpcResult(e);
} else {
origin: dubboclub/dubbo-plus

private Result wrapBreakerInvoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  //首先检查是否需要进入服务降级流程
  if(checkNeedCircuitBreak(invoker, invocation)){
    logger.info("[{}] activate the circuit break for url [{}],invoke method [{}]",localHost,invoker.getUrl(),invocation.getMethodName());
    //进入服务降级
    return doCircuitBreak(invoker, invocation);
  }
  try{
    Result result = invoker.invoke(invocation);
    //将该服务从服务降级中恢复出来
    toBeNormal(invoker, invocation);
    return result;
  }catch (RpcException e){
    //如果是请求超时或者网络异常,进行异常统计
    if(!e.isBiz()){
      caughtException(invoker,invocation,e);
    }
    throw e;
  }
}
origin: com.alibaba/dubbo-rpc-api

@Override
public T get() throws InterruptedException, ExecutionException {
  throw new ExecutionException(e.getCause());
}
origin: wu191287278/spring-boot-starter-dubbo

public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  URL url = invoker.getUrl();
  String spanName = url.getServiceInterface() + "." + invocation.getMethodName();
  Span newSpan = tracer.createSpan(spanName);
  try {
    dubboSpanInjector.inject(newSpan, RpcContext.getContext());
    newSpan.logEvent(Span.CLIENT_SEND);
    return invoker.invoke(invocation);
  } catch (RpcException e) {
    newSpan.tag("error", e.getMessage());
    throw e;
  } finally {
    if (tracer.isTracing()) {
      tracer.getCurrentSpan().logEvent(Span.CLIENT_RECV);
      tracer.close(tracer.getCurrentSpan());
    }
  }
}
origin: linux-china/dubbo3

  @SuppressWarnings({ "unchecked", "rawtypes" })
  private Result doMockInvoke(Invocation invocation,RpcException e){
    Result result = null;
    Invoker<T> minvoker ;
    
    List<Invoker<T>> mockInvokers = selectMockInvoker(invocation);
    if (mockInvokers == null || mockInvokers.size() == 0){
      minvoker = (Invoker<T>) new MockInvoker(directory.getUrl());
    } else {
      minvoker = mockInvokers.get(0);
    }
    try {
      result = minvoker.invoke(invocation);
    } catch (RpcException me) {
      if (me.isBiz()) {
        result = new RpcResult(me.getCause());
      } else {
        throw new RpcException(me.getCode(), getMockExceptionMessage(e, me), me.getCause());
      }
//            
    } catch (Throwable me) {
      throw new RpcException(getMockExceptionMessage(e, me), me.getCause());
    }
    return result;
  }
   
origin: com.alibaba/dubbo-registry-redis

  exception = new RpcException("Failed to register service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
  logger.warn(exception.getMessage(), exception);
} else {
  throw exception;
origin: remoting/dubbox

protected RpcException getRpcException(Class<?> type, URL url, Invocation invocation, Throwable e) {
  RpcException re = new RpcException("Failed to invoke remote service: " + type + ", method: "
      + invocation.getMethodName() + ", cause: " + e.getMessage(), e);
  re.setCode(getErrorCode(e));
  return re;
}
origin: linux-china/dubbo3

  public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
    checkInvokers(invokers, invocation);
    Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
    try {
      return invoker.invoke(invocation);
    } catch (Throwable e) {
      if (e instanceof RpcException && ((RpcException)e).isBiz()) { // biz exception.
        throw (RpcException) e;
      }
      throw new RpcException(e instanceof RpcException ? ((RpcException)e).getCode() : 0, "Failfast invoke providers " + invoker.getUrl() + " " + loadbalance.getClass().getSimpleName() + " select from all providers " + invokers + " for service " + getInterface().getName() + " method " + invocation.getMethodName() + " on consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
    }
  }
}
origin: linux-china/dubbo3

if (ret instanceof Throwable) {
  Throwable e = (Throwable) ret;
  throw new RpcException(e instanceof RpcException ? ((RpcException)e).getCode() : 0, "Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
throw new RpcException("Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e);
origin: remoting/dubbox

public Result invoke(Invocation inv) throws RpcException {
  if(destroyed) {
    throw new RpcException("Rpc invoker for service " + this + " on consumer " + NetUtils.getLocalHost() 
                    + " use dubbo version " + Version.getVersion()
                    + " is DESTROYED, can not be invoked any more!");
    } else {
      if (te instanceof RpcException) {
        ((RpcException) te).setCode(RpcException.BIZ_EXCEPTION);
    if (e.isBiz()) {
      return new RpcResult(e);
    } else {
com.alibaba.dubbo.rpcRpcException

Javadoc

RPC Exception. (API, Prototype, ThreadSafe)

Most used methods

  • <init>
  • getCause
  • getCode
  • getMessage
  • isBiz
  • setCode
  • printStackTrace

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JComboBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now