當前位置: 首頁>>代碼示例>>Java>>正文


Java TimeoutException.getMessage方法代碼示例

本文整理匯總了Java中java.util.concurrent.TimeoutException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java TimeoutException.getMessage方法的具體用法?Java TimeoutException.getMessage怎麽用?Java TimeoutException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.TimeoutException的用法示例。


在下文中一共展示了TimeoutException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
private void init() throws IOException {
    ConnectionFactory factory = new ConnectionFactory();
    factory.setAutomaticRecoveryEnabled(true);
    factory.setHost(this.server);
    if (this.port > 0) factory.setPort(this.port);
    if (this.username != null && this.username.length() > 0) factory.setUsername(this.username);
    if (this.password != null && this.password.length() > 0) factory.setPassword(this.password);
    try {
        this.connection = factory.newConnection();
        //Map<String, Object> map = this.connection.getServerProperties();
        if (!this.connection.isOpen()) throw new IOException("no connection");
        this.channel = connection.createChannel();
        if (!this.channel.isOpen()) throw new IOException("no channel");
        this.queues = new ConcurrentHashMap<>();
    } catch (TimeoutException e) {
        throw new IOException(e.getMessage());
    }
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:19,代碼來源:RabbitQueueFactory.java

示例2: waitForStart

import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
@SuppressWarnings({"SleepWhileHoldingLock", "SleepWhileInLoop"})
private boolean waitForStart() throws DatabaseException {
    int tries = 0;
    while (tries <= 5 && !stopWaiting) {
        tries++;

        try {
            // wait for perform start command first
            Thread.sleep(2000);
        } catch (InterruptedException ie) {
            LOGGER.log(Level.INFO, "Interrupted waiting for server to start", ie);
            Thread.currentThread().interrupt();
            return false;
        }

        try {
            server.reconnect();
            return true;
        } catch (DatabaseException dbe) {
            errorMessage = dbe.getMessage();
            LOGGER.log(Level.INFO, null, dbe);
            if (! DatabaseUtils.isCommunicationsException(dbe)) {
                throw dbe;
            }
        } catch (TimeoutException te) {
            errorMessage = te.getMessage();
            LOGGER.log(Level.INFO, null, te);
        }

    }

    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:StartManager.java

示例3: getDoneFromTimeoutOverload

import java.util.concurrent.TimeoutException; //導入方法依賴的package包/類
/**
 * 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;
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:TestPlatform.java


注:本文中的java.util.concurrent.TimeoutException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。