本文整理了Java中java.util.concurrent.TimeoutException.getMessage()
方法的一些代码示例,展示了TimeoutException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeoutException.getMessage()
方法的具体详情如下:
包路径:java.util.concurrent.TimeoutException
类名称:TimeoutException
方法名:getMessage
暂无
代码示例来源:origin: hs-web/hsweb-framework
@ExceptionHandler(TimeoutException.class)
@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT)
ResponseMessage handleException(TimeoutException exception) {
String msg = Optional.ofNullable(exception.getMessage())
.orElse("访问服务超时");
logger.warn(exception.getMessage(), exception);
return ResponseMessage.error(504, msg);
}
代码示例来源:origin: apache/hbase
@Override
public V get() throws InterruptedException, ExecutionException {
// TODO: should we ever spin forever?
// fix HBASE-21715. TODO: If the function call get() without timeout limit is not allowed,
// is it possible to compose instead of inheriting from the class Future for this class?
try {
return get(admin.getProcedureTimeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOG.warn("Failed to get the procedure with procId=" + procId + " throws exception " + e
.getMessage(), e);
return null;
}
}
代码示例来源:origin: apache/zeppelin
public void shutdown() {
if (!zconf.isClusterMode()) {
return;
}
running.set(false);
try {
if (null != raftSessionClient) {
raftSessionClient.close().get(3, TimeUnit.SECONDS);
}
if (null != raftClient) {
raftClient.close().get(3, TimeUnit.SECONDS);
}
} catch (InterruptedException e) {
LOGGER.error(e.getMessage());
} catch (ExecutionException e) {
LOGGER.error(e.getMessage());
} catch (TimeoutException e) {
LOGGER.error(e.getMessage());
}
}
代码示例来源:origin: google/guava
/**
* Retrieves the result of a {@code Future} known to be done but uses the {@code get(long,
* TimeUnit)} overload in order to test that method.
*/
static <V> V getDoneFromTimeoutOverload(Future<V> future) throws ExecutionException {
checkState(future.isDone(), "Future was expected to be done: %s", future);
try {
return getUninterruptibly(future, 0, SECONDS);
} catch (TimeoutException e) {
AssertionFailedError error = new AssertionFailedError(e.getMessage());
error.initCause(e);
throw error;
}
}
代码示例来源:origin: apache/zeppelin
public HashMap<String, HashMap<String, Object>> getClusterMeta(
ClusterMetaType metaType, String metaKey) {
HashMap<String, HashMap<String, Object>> clusterMeta = new HashMap<>();
if (!raftInitialized()) {
LOGGER.error("Raft incomplete initialization!");
return clusterMeta;
}
ClusterMetaEntity entity = new ClusterMetaEntity(GET_OPERATION, metaType, metaKey, null);
byte[] mateData = null;
try {
mateData = raftSessionClient.execute(operation(ClusterStateMachine.GET,
clientSerializer.encode(entity))).get(3, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage());
} catch (ExecutionException e) {
LOGGER.error(e.getMessage());
} catch (TimeoutException e) {
LOGGER.error(e.getMessage());
}
if (null != mateData) {
clusterMeta = clientSerializer.decode(mateData);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("getClusterMeta >>> {}", clusterMeta.toString());
}
return clusterMeta;
}
代码示例来源:origin: alibaba/nacos
.getMessage());
代码示例来源:origin: alibaba/fescar
private void sendRegisterMessage(String serverAddress, Channel channel, String dbKey) {
RegisterRMRequest message = new RegisterRMRequest(applicationId,
transactionServiceGroup);
message.setResourceIds(dbKey);
try {
super.sendAsyncRequestWithoutResponse(null, channel, message);
} catch (FrameworkException e) {
if (e.getErrcode() == FrameworkErrorCode.ChannelIsNotWritable
&& serverAddress != null) {
releaseChannel(channel, serverAddress);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("remove channel:" + channel);
}
} else {
LOGGER.error("", "register failed", e);
}
} catch (TimeoutException e) {
LOGGER.error(e.getMessage());
}
}
代码示例来源:origin: google/guava
public void testToString_notDone() throws Exception {
AbstractFuture<Object> testFuture =
new AbstractFuture<Object>() {
@Override
public String pendingToString() {
return "cause=[Because this test isn't done]";
}
};
assertThat(testFuture.toString())
.matches(
"[^\\[]+\\[status=PENDING, info=\\[cause=\\[Because this test isn't done\\]\\]\\]");
try {
testFuture.get(1, TimeUnit.NANOSECONDS);
fail();
} catch (TimeoutException e) {
assertThat(e.getMessage()).contains("1 nanoseconds");
assertThat(e.getMessage()).contains("Because this test isn't done");
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timeout() throws Exception {
Future<?> f = Single.never().toFuture();
try {
f.get(100, TimeUnit.MILLISECONDS);
fail("Should have thrown");
} catch (TimeoutException expected) {
assertEquals(timeoutMessage(100, TimeUnit.MILLISECONDS), expected.getMessage());
}
}
代码示例来源:origin: alipay/sofa-rpc
throw new SofaTimeOutException("Future is not done when timeout.", ex);
} else {
throw new SofaTimeOutException(ex.getMessage(), ex);
代码示例来源:origin: google/guava
public void testServiceTimeoutOnStartUp() throws Exception {
TimeoutOnStartUp service = new TimeoutOnStartUp();
try {
service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
fail();
} catch (TimeoutException e) {
assertThat(e.getMessage()).contains(Service.State.STARTING.toString());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void getTimedOut() throws Exception {
try {
fo.get(1, TimeUnit.NANOSECONDS);
fail("Should have thrown");
} catch (TimeoutException expected) {
assertEquals(timeoutMessage(1, TimeUnit.NANOSECONDS), expected.getMessage());
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void getTimedOut() throws Exception {
try {
fs.get(1, TimeUnit.NANOSECONDS);
fail("Should have thrown");
} catch (TimeoutException expected) {
assertEquals(timeoutMessage(1, TimeUnit.NANOSECONDS), expected.getMessage());
}
}
}
代码示例来源:origin: apache/hive
throw new QueueException(ex.getMessage());
} catch (InterruptedException ex) {
代码示例来源:origin: confluentinc/ksql
} catch (final TimeoutException e) {
log.debug("Timeout while processing request", e);
SessionUtil.closeSilently(session, CloseCodes.TRY_AGAIN_LATER, e.getMessage());
return;
代码示例来源:origin: apache/ignite
/**
* @throws Exception Thrown in case of test failure.
*/
@Test
public void testInvokeAnyWithTimeout() throws Exception {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
ExecutorService srvc = createExecutorService(ignite);
Collection<Callable<Integer>> timeoutCmds = new ArrayList<>(2);
timeoutCmds.add(new TestCallable<>(5000));
timeoutCmds.add(new TestCallable<>(5000));
boolean ok = true;
try {
srvc.invokeAny(timeoutCmds, 1, TimeUnit.SECONDS);
ok = false;
}
catch (TimeoutException e) {
info("Task timeout elapsed: " + e.getMessage());
}
assert ok : "Timeout must be thrown.";
srvc.shutdown();
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception Thrown in case of test failure.
*/
@Test
public void testSubmitWithFutureTimeout() throws Exception {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
ExecutorService srvc = createExecutorService(ignite);
Future<Integer> fut = srvc.submit(new TestCallable<>(3000)); // Just sleep for 3 seconds.
boolean ok = true;
try {
fut.get(1, TimeUnit.SECONDS);
ok = false;
}
catch (TimeoutException e) {
info("Task timeout elapsed: " + e.getMessage());
}
assert ok : "Timeout must be thrown.";
srvc.shutdown();
}
代码示例来源:origin: confluentinc/ksql
public static void httpWaitForCommandSequenceNumber(
final CommandQueue commandQueue,
final KsqlRequest request,
final Duration timeout
) {
try {
waitForCommandSequenceNumber(commandQueue, request, timeout);
} catch (final InterruptedException e) {
final String errorMsg = "Interrupted while waiting for command queue to reach "
+ "specified command sequence number in request: " + request.getKsql();
throw new KsqlRestException(
Errors.serverErrorForStatement(e, errorMsg, new KsqlEntityList()));
} catch (final TimeoutException e) {
throw new KsqlRestException(Errors.commandQueueCatchUpTimeout(e.getMessage()));
}
}
代码示例来源:origin: cSploit/android
public void run() {
try {
//noinspection InfiniteLoopStatement
while(true) {
processCommand(grabCommand());
}
} catch (InterruptedException e) {
Logger.warning("interrupted");
} catch (TimeoutException e) {
Logger.error("Session timed out: " + e.getMessage());
} catch (RPCClient.MSFException e) {
System.errorLogging(e);
} catch (IOException e) {
System.errorLogging(e);
} finally {
stopSession();
}
}
代码示例来源:origin: ehcache/ehcache3
@Test
public void testLockWhenException() throws Exception {
ClusterTierClientEntity clusterTierClientEntity = mock(ClusterTierClientEntity.class);
LockManagerImpl lockManager = new LockManagerImpl(clusterTierClientEntity);
when(clusterTierClientEntity.invokeAndWaitForComplete(any(LockMessage.class), anyBoolean()))
.thenThrow(new UnknownClusterException(""), new TimeoutException("timed out test"));
try {
lockManager.lock(2L);
fail();
} catch (ServerStoreProxyException sspe) {
assertThat(sspe.getCause(), instanceOf(UnknownClusterException.class));
}
try {
lockManager.lock(2L);
fail();
} catch (TimeoutException e) {
assertThat(e.getMessage(), is("timed out test"));
}
}
内容来源于网络,如有侵权,请联系作者删除!