本文整理汇总了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();
}
示例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));
}
示例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();
}
示例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();
}
示例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());
}