Java Code Examples for com.alibaba.dubbo.rpc.RpcException#TIMEOUT_EXCEPTION

The following examples show how to use com.alibaba.dubbo.rpc.RpcException#TIMEOUT_EXCEPTION . 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: JsonRpcProtocol.java    From dubbo-rpc-jsonrpc with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null) {
        Class<?> cls = e.getClass();
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 2
Source File: RmiProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null && e.getCause() != null) {
        Class<?> cls = e.getCause().getClass();
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 3
Source File: HttpProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null) {
        Class<?> cls = e.getClass();
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 4
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null && e.getCause() != null) {
        Class<?> cls = e.getCause().getClass();
        // 是根据测试Case发现的问题,对RpcException.setCode进行设置
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 5
Source File: JsonRpcProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null) {
        Class<?> cls = e.getClass();
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 6
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null && e.getCause() != null) {
        Class<?> cls = e.getCause().getClass();
        // 是根据测试Case发现的问题,对RpcException.setCode进行设置
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 7
Source File: HttpProtocol.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null) {
        Class<?> cls = e.getClass();
        // 是根据测试Case发现的问题,对RpcException.setCode进行设置
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 8
Source File: DubboParser.java    From brave with Apache License 2.0 6 votes vote down vote up
/**
 * This library is no-longer being released, so it should not have any maintenance on error codes.
 * The error codes here were defined in 2012.
 */
@Nullable static String errorCode(Throwable error) {
  if (error instanceof RpcException) {
    int code = ((RpcException) error).getCode();
    switch (code) {
      case RpcException.UNKNOWN_EXCEPTION:
        return "UNKNOWN_EXCEPTION";
      case RpcException.NETWORK_EXCEPTION:
        return "NETWORK_EXCEPTION";
      case RpcException.TIMEOUT_EXCEPTION:
        return "TIMEOUT_EXCEPTION";
      case RpcException.BIZ_EXCEPTION:
        return "BIZ_EXCEPTION";
      case RpcException.FORBIDDEN_EXCEPTION:
        return "FORBIDDEN_EXCEPTION";
      case RpcException.SERIALIZATION_EXCEPTION:
        return "SERIALIZATION_EXCEPTION";
      default:
        return String.valueOf(code);
    }
  }
  return null;
}
 
Example 9
Source File: HttpProtocol.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof RemoteAccessException) {
        e = e.getCause();
    }
    if (e != null) {
        Class<?> cls = e.getClass();
        // 是根据测试Case发现的问题,对RpcException.setCode进行设置
        if (SocketTimeoutException.class.equals(cls)) {
            return RpcException.TIMEOUT_EXCEPTION;
        } else if (IOException.class.isAssignableFrom(cls)) {
            return RpcException.NETWORK_EXCEPTION;
        } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
            return RpcException.SERIALIZATION_EXCEPTION;
        }
    }
    return super.getErrorCode(e);
}
 
Example 10
Source File: ErrorCodeUtils.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static int getErrorCode(Throwable e, Class<?> cls) {
    // 是根据测试Case发现的问题,对RpcException.setCode进行设置
    if (SocketTimeoutException.class.equals(cls)) {
        return RpcException.TIMEOUT_EXCEPTION;
    } else if (IOException.class.isAssignableFrom(cls)) {
        return RpcException.NETWORK_EXCEPTION;
    } else if (ClassNotFoundException.class.isAssignableFrom(cls)) {
        return RpcException.SERIALIZATION_EXCEPTION;
    }
    return 0;
}
 
Example 11
Source File: FailoverClusterInvokerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
   * 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模拟invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
Example 12
Source File: WebServiceProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected int getErrorCode(Throwable e) {
	if (e instanceof Fault) {
        e = e.getCause();
    }
    if (e instanceof SocketTimeoutException) {
        return RpcException.TIMEOUT_EXCEPTION;
    } else if (e instanceof IOException) {
        return RpcException.NETWORK_EXCEPTION;
    }
    return super.getErrorCode(e);
}
 
Example 13
Source File: FailoverClusterInvokerTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
/**
   * 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模拟invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
Example 14
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof HessianConnectionException) {
        if (e.getCause() != null) {
            Class<?> cls = e.getCause().getClass();
            if (SocketTimeoutException.class.equals(cls)) {
                return RpcException.TIMEOUT_EXCEPTION;
            }
        }
        return RpcException.NETWORK_EXCEPTION;
    } else if (e instanceof HessianMethodSerializationException) {
        return RpcException.SERIALIZATION_EXCEPTION;
    }
    return super.getErrorCode(e);
}
 
Example 15
Source File: HessianProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof HessianConnectionException) {
        if (e.getCause() != null) {
            Class<?> cls = e.getCause().getClass();
            if (SocketTimeoutException.class.equals(cls)) {
                return RpcException.TIMEOUT_EXCEPTION;
            }
        }
        return RpcException.NETWORK_EXCEPTION;
    } else if (e instanceof HessianMethodSerializationException) {
        return RpcException.SERIALIZATION_EXCEPTION;
    }
    return super.getErrorCode(e);
}
 
Example 16
Source File: FailoverClusterInvokerTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
   * 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模拟invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
Example 17
Source File: WebServiceProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected int getErrorCode(Throwable e) {
	if (e instanceof Fault) {
        e = e.getCause();
    }
    if (e instanceof SocketTimeoutException) {
        return RpcException.TIMEOUT_EXCEPTION;
    } else if (e instanceof IOException) {
        return RpcException.NETWORK_EXCEPTION;
    }
    return super.getErrorCode(e);
}
 
Example 18
Source File: HessianProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected int getErrorCode(Throwable e) {
    if (e instanceof HessianConnectionException) {
        if (e.getCause() != null) {
            Class<?> cls = e.getCause().getClass();
            if (SocketTimeoutException.class.equals(cls)) {
                return RpcException.TIMEOUT_EXCEPTION;
            }
        }
        return RpcException.NETWORK_EXCEPTION;
    } else if (e instanceof HessianMethodSerializationException) {
        return RpcException.SERIALIZATION_EXCEPTION;
    }
    return super.getErrorCode(e);
}
 
Example 19
Source File: FailoverClusterInvokerTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
   * 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模拟invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
Example 20
Source File: WebServiceProtocol.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
protected int getErrorCode(Throwable e) {
    if (e instanceof Fault) {
        e = e.getCause();
    }
    if (e instanceof SocketTimeoutException) {
        return RpcException.TIMEOUT_EXCEPTION;
    } else if (e instanceof IOException) {
        return RpcException.NETWORK_EXCEPTION;
    }
    return super.getErrorCode(e);
}