Java Code Examples for com.alibaba.dubbo.rpc.RpcException#isBiz()
The following examples show how to use
com.alibaba.dubbo.rpc.RpcException#isBiz() .
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: MockClusterInvoker.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public Result invoke(Invocation invocation) throws RpcException { Result result = null; // mock 属性值,是否开启了mock String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")) { //no mock 没有mock直接执行业务方法=》com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke // 这里的invoker就是从远程refer的服务proxy result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); } catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.warn("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 2
Source File: MockClusterInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public Result invoke(Invocation invocation) throws RpcException { Result result = null; String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")){ //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); }catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.info("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 3
Source File: MockClusterInvoker.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public Result invoke(Invocation invocation) throws RpcException { Result result = null; String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")){ //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); }catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.info("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 4
Source File: MockClusterInvoker.java From dubbo3 with Apache License 2.0 | 5 votes |
public Result invoke(Invocation invocation) throws RpcException { Result result = null; String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")){ //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); }catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.info("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 5
Source File: MockClusterInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public Result invoke(Invocation invocation) throws RpcException { Result result = null; String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")){ //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); }catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.info("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 6
Source File: MockClusterInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public Result invoke(Invocation invocation) throws RpcException { Result result = null; String value = directory.getUrl().getMethodParameter(invocation.getMethodName(), Constants.MOCK_KEY, Boolean.FALSE.toString()).trim(); if (value.length() == 0 || value.equalsIgnoreCase("false")){ //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith("force")) { if (logger.isWarnEnabled()) { logger.info("force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + directory.getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); } else { //fail-mock try { result = this.invoker.invoke(invocation); }catch (RpcException e) { if (e.isBiz()) { throw e; } else { if (logger.isWarnEnabled()) { logger.info("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); } result = doMockInvoke(invocation, e); } } } return result; }
Example 7
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 4 votes |
/** * rpc client handler * @param invoker * @param invocation * @return */ private Result doServerFilter(Invoker<?> invoker, Invocation invocation) { if (dubboProviderSofaTracer == null) { this.dubboProviderSofaTracer = DubboProviderSofaTracer .getDubboProviderSofaTracerSingleton(); } SofaTracerSpan sofaTracerSpan = serverReceived(invocation); appendRpcServerSpanTags(invoker, sofaTracerSpan); Result result; Throwable exception = null; try { result = invoker.invoke(invocation); if (result == null) { return null; } else { appendElapsedTimeTags(invocation, sofaTracerSpan, result, false); } if (result.hasException()) { exception = result.getException(); } return result; } catch (RpcException e) { exception = e; throw e; } catch (Throwable t) { exception = t; throw new RpcException(t); } finally { String resultCode = SofaTracerConstant.RESULT_CODE_SUCCESS; if (exception != null) { if (exception instanceof RpcException) { sofaTracerSpan.setTag(Tags.ERROR.getKey(), exception.getMessage()); RpcException rpcException = (RpcException) exception; if (rpcException.isBiz()) { resultCode = String.valueOf(rpcException.getCode()); } } else { resultCode = SofaTracerConstant.RESULT_CODE_ERROR; } } dubboProviderSofaTracer.serverSend(resultCode); } }