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


Java UncheckedTimeoutException类代码示例

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


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

示例1: run

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public void run() {
    try {
        if (jobControl.isActive(name())) {
            try (Lock lock = jobControl.curator().lockMaintenanceJob(name())) {
                maintain();
            }
        }
    }
    catch (UncheckedTimeoutException e) {
        // another controller instance is running this job at the moment; ok
    }
    catch (Throwable t) {
        log.log(Level.WARNING, this + " failed. Will retry in " + maintenanceInterval.toMinutes() + " minutes", t);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:17,代码来源:Maintainer.java

示例2: acquire

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public boolean acquire(long timeout, TimeUnit unit) {
    if (throwExceptionOnLock)
        throw new CuratorLockException("Thrown by mock");
    if (timeoutOnLock) return false;
    
    try {
        lock = locks.lock(path, timeout, unit);
        return true;
    }
    catch (UncheckedTimeoutException e) {
        return false;
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:15,代码来源:MockCurator.java

示例3: acquire

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
/** Take the lock with the given timeout. This may be called multiple times from the same thread - each matched by a close */
public void acquire(Duration timeout) {
    boolean acquired;
    try {
        acquired = mutex.acquire(timeout.toMillis(), TimeUnit.MILLISECONDS);
    }
    catch (Exception e) {
        throw new RuntimeException("Exception acquiring lock '" + lockPath + "'", e);
    }

    if (! acquired) throw new UncheckedTimeoutException("Timed out after waiting " + timeout.toString() +
                                                        " to acquire lock '" + lockPath + "'");
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:14,代码来源:Lock.java

示例4: test_application_lock_failure

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Test
public void test_application_lock_failure() throws InterruptedException, IOException {
    String message = "Timed out after waiting PT1M to acquire lock '/provision/v1/locks/foo/bar/default'";
    SessionThrowingException session =
            new SessionThrowingException(new ApplicationLockException(new UncheckedTimeoutException(message)));
    localRepo.addSession(session);
    HttpResponse response = createHandler()
            .handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertEquals(500, response.getStatus());
    Slime data = getData(response);
    assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.errorCodes.APPLICATION_LOCK_FAILURE.name()));
    assertThat(data.get().field("message").asString(), is(message));
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:14,代码来源:SessionPrepareHandlerTest.java

示例5: lock

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
/** Acquires the single cluster-global, reentrant lock with the specified timeout for active nodes of this application */
public Lock lock(ApplicationId application, Duration timeout) {
    try {
        return lock(lockPath(application), timeout);
    }
    catch (UncheckedTimeoutException e) {
        throw new ApplicationLockException(e);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:10,代码来源:CuratorDatabaseClient.java

示例6: backupShard

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public void backupShard(UUID uuid, File source)
{
    try {
        store.backupShard(uuid, source);
    }
    catch (UncheckedTimeoutException e) {
        throw new PrestoException(RAPTOR_BACKUP_TIMEOUT, "Shard backup timed out");
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TimeoutBackupStore.java

示例7: restoreShard

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public void restoreShard(UUID uuid, File target)
{
    try {
        store.restoreShard(uuid, target);
    }
    catch (UncheckedTimeoutException e) {
        throw new PrestoException(RAPTOR_BACKUP_TIMEOUT, "Shard restore timed out");
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TimeoutBackupStore.java

示例8: deleteShard

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public void deleteShard(UUID uuid)
{
    try {
        store.deleteShard(uuid);
    }
    catch (UncheckedTimeoutException e) {
        throw new PrestoException(RAPTOR_BACKUP_TIMEOUT, "Shard delete timed out");
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TimeoutBackupStore.java

示例9: shardExists

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
public boolean shardExists(UUID uuid)
{
    try {
        return store.shardExists(uuid);
    }
    catch (UncheckedTimeoutException e) {
        throw new PrestoException(RAPTOR_BACKUP_TIMEOUT, "Shard existence check timed out");
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TimeoutBackupStore.java

示例10: query

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
private JoinQueryResultDto query(QueryType type, JoinQuery joinQuery,
                                 CountStatsData.Builder countBuilder, QueryScope scope, QueryMode mode) {

  boolean havePermit = false;
  try {
    havePermit = acquireSemaphorePermit();
    if (havePermit)
      return unsafeQuery(type, joinQuery, countBuilder, scope, mode);
    else
      throw new UncheckedTimeoutException("Too many queries in a short time. Please retry later.");
  } finally {
    if (havePermit)
      releaseSemaphorePermit();
  }
}
 
开发者ID:obiba,项目名称:mica2,代码行数:16,代码来源:JoinQueryExecutor.java

示例11: getErrorDto

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Override
protected GeneratedMessage.ExtendableMessage<?> getErrorDto(UncheckedTimeoutException e) {
  return ErrorDtos.ClientErrorDto.newBuilder()
    .setCode(getStatus().getStatusCode())
    .setMessageTemplate("server.error.search.timeout")
    .setMessage(e.getMessage())
    .build();
}
 
开发者ID:obiba,项目名称:mica2,代码行数:9,代码来源:UncheckedTimeoutExceptionMapper.java

示例12: createRealConnection

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
/**
 * Creates a real database connection, failing if one is not obtained in the specified time.
 * @param timeoutMillis The timeout in milliseconds.
 * @return The connection.
 * @throws SQLException on connection problem or timeout waiting for connection.
 */
private Connection createRealConnection(final long timeoutMillis) throws SQLException {

   if(timeoutMillis < 1L) {

      String usePassword = getPassword();

      Connection conn = dbConnection.datasource == null ?
              DriverManager.getConnection(dbConnection.connectionString, dbConnection.user, usePassword) :
              dbConnection.datasource.getConnection(dbConnection.user, usePassword);
      if(conn != null) {
         return conn;
      } else {
         throw new SQLException("Unable to create connection: driver/datasource returned [null]");
      }

   } else {

      try {
         return connectionTimeLimiter.callWithTimeout(new Callable<Connection>() {
            public Connection call() throws Exception {
               return createRealConnection(0L);
            }
         }, timeoutMillis, TimeUnit.MILLISECONDS, true);
      } catch(UncheckedTimeoutException ute) {
         throw new SQLException("Unable to create connection after waiting " + timeoutMillis + " ms");
      } catch(Exception e) {
         if(e instanceof SQLException) {
            throw (SQLException)e;
         } else {
            throw new SQLException("Unable to create connection: driver/datasource", e);
         }
      }
   }
}
 
开发者ID:attribyte,项目名称:acp,代码行数:41,代码来源:ConnectionPoolSegment.java

示例13: shouldTriggerTimeout

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
@Test(expected = UncheckedTimeoutException.class)
public void shouldTriggerTimeout() throws Exception {
    new SimpleTimeLimiter().callWithTimeout(
            () -> doSomeHeavyWeightOperation(), NOT_ENOUGH_MS, MILLISECONDS, true);
}
 
开发者ID:webdizz,项目名称:fault-tolerance-talk,代码行数:6,代码来源:AnyOperationTimeoutTest.java

示例14: checkTimeout

import com.google.common.util.concurrent.UncheckedTimeoutException; //导入依赖的package包/类
/**
 * Throws UncheckedTimeoutException if current time is past the provided timeout timestamp.
 * @param timeoutTS timestamp of when the query times out in milliseconds
 */
public void checkTimeout(long timeoutTS) {
    if(System.currentTimeMillis() > timeoutTS) {
        throw new UncheckedTimeoutException("The query took longer than the allowed timeout of " + executionTimeout.toString(PeriodFormat.getDefault()));
    }
}
 
开发者ID:indeedeng,项目名称:iql,代码行数:10,代码来源:IQLQuery.java


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