当前位置: 首页>>代码示例>>Java>>正文


Java TimeoutException类代码示例

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


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

示例1: get

import com.alibaba.dubbo.remoting.TimeoutException; //导入依赖的package包/类
public Object get(int timeout) throws RemotingException {
    if (timeout <= 0) {
        timeout = Constants.DEFAULT_TIMEOUT;
    }
    if (! isDone()) {
        long start = System.currentTimeMillis();
        lock.lock();
        try {
            while (! isDone()) {
                done.await(timeout, TimeUnit.MILLISECONDS);
                if (isDone() || System.currentTimeMillis() - start > timeout) {
                    break;
                }
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            lock.unlock();
        }
        if (! isDone()) {
            throw new TimeoutException(sent > 0, channel, getTimeoutMessage(false));
        }
    }
    return returnFromResponse();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:26,代码来源:DefaultFuture.java

示例2: main

import com.alibaba.dubbo.remoting.TimeoutException; //导入依赖的package包/类
public static void main(final String... args) {
  final ExecutionException ee = new ExecutionException(null, null, "hee");

  System.err.println("ee:" + JSON.toJSONString(ee));
  System.err.println("em:" + ee.getMessage());
  System.err.println("em-1:" + JSON.toJSONString(ee.getClass()));
  System.err.println("em-2:" + ee.getClass().getCanonicalName());

  final RpcException re = new RpcException("sx");
  System.err.println("re:" + JSON.toJSONString(re));
  System.err.println("rem:" + re.getMessage());

  final TimeoutException te = new TimeoutException(true, null, "sss");
  System.err.println("te:" + JSON.toJSONString(te));

  @SuppressWarnings("PMD.AvoidThrowingNullPointerException")
  final Throwable tb = new NullPointerException("null");
  System.err.println("tb:" + JSON.toJSONString(tb));
}
 
开发者ID:Yirendai,项目名称:cicada,代码行数:20,代码来源:ExceptionTest.java

示例3: get

import com.alibaba.dubbo.remoting.TimeoutException; //导入依赖的package包/类
public Object get(int timeout) throws RemotingException {
    if (timeout <= 0) {
        timeout = Constants.DEFAULT_TIMEOUT;
    }
    if (! isDone()) {
        long start = System.currentTimeMillis();
        lock.lock();
        try {
            while (! isDone()) {//如果没有Response到来的话(也就说明请求没有结束)
                done.await(timeout, TimeUnit.MILLISECONDS);
                //如果已经做完或者请求超时的话就直接break
                if (isDone() || System.currentTimeMillis() - start > timeout) {
                    break;
                }
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            lock.unlock();
        }
        if (! isDone()) {
            throw new TimeoutException(sent > 0, channel, getTimeoutMessage(false));
        }
    }
    return returnFromResponse();
}
 
开发者ID:DoubleSmile,项目名称:dubbo-learning,代码行数:27,代码来源:DefaultFuture.java

示例4: get

import com.alibaba.dubbo.remoting.TimeoutException; //导入依赖的package包/类
public Object get(int timeout) throws RemotingException {
    if (timeout <= 0) {
        timeout = Constants.DEFAULT_TIMEOUT;
    }
    if (!isDone()) {
        long start = System.currentTimeMillis();
        lock.lock();
        try {
            while (!isDone()) {
                done.await(timeout, TimeUnit.MILLISECONDS);
                if (isDone() || System.currentTimeMillis() - start > timeout) {
                    break;
                }
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            lock.unlock();
        }
        if (!isDone()) {
            throw new TimeoutException(sent > 0, channel, getTimeoutMessage(false));
        }
    }
    return returnFromResponse();
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:26,代码来源:DefaultFuture.java

示例5: returnFromResponse

import com.alibaba.dubbo.remoting.TimeoutException; //导入依赖的package包/类
private Object returnFromResponse() throws RemotingException {
    Response res = response;
    if (res == null) {
        throw new IllegalStateException("response cannot be null");
    }
    if (res.getStatus() == Response.OK) {
        return res.getResult();
    }
    if (res.getStatus() == Response.CLIENT_TIMEOUT || res.getStatus() == Response.SERVER_TIMEOUT) {
        throw new TimeoutException(res.getStatus() == Response.SERVER_TIMEOUT, channel, res.getErrorMessage());
    }
    throw new RemotingException(channel, res.getErrorMessage());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:14,代码来源:DefaultFuture.java


注:本文中的com.alibaba.dubbo.remoting.TimeoutException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。