Java 类com.google.common.util.concurrent.ExecutionError 实例源码

项目:drift    文件:SslContextFactory.java   
public ReloadableSslContext get(
        File trustCertificatesFile,
        Optional<File> clientCertificatesFile,
        Optional<File> privateKeyFile,
        Optional<String> privateKeyPassword,
        long sessionCacheSize,
        Duration sessionTimeout,
        List<String> ciphers)
{
    try {
        return cache.getUnchecked(new SslContextConfig(trustCertificatesFile, clientCertificatesFile, privateKeyFile, privateKeyPassword, sessionCacheSize, sessionTimeout, ciphers));
    }
    catch (UncheckedExecutionException | ExecutionError e) {
        throw new RuntimeException("Error initializing SSL context", e.getCause());
    }
}
项目:guava-mock    文件:CacheLoadingTest.java   
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
项目:googles-monorepo-demo    文件:CacheLoadingTest.java   
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
项目:hashsdn-controller    文件:OnDemandShardStateCache.java   
OnDemandShardState get() throws Exception {
    if (shardActor == null) {
        return OnDemandShardState.newBuilder().build();
    }

    try {
        return ONDEMAND_SHARD_STATE_CACHE.get(shardName, this::retrieveState);
    } catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        if (e.getCause() != null) {
            Throwables.propagateIfPossible(e.getCause(), Exception.class);
            throw new RuntimeException("unexpected", e.getCause());
        }

        throw e;
    }
}
项目:gtfs-lib    文件:GTFSFeed.java   
private static DB constructDB(String dbFile) {
        DB db;
        try{
            DBMaker dbMaker = DBMaker.newFileDB(new File(dbFile));
            db = dbMaker
                    .transactionDisable()
                    .mmapFileEnable()
                    .asyncWriteEnable()
                    .compressionEnable()
//                     .cacheSize(1024 * 1024) this bloats memory consumption
                    .make();
            return db;
        } catch (ExecutionError | IOError | Exception e) {
            LOG.error("Could not construct db from file.", e);
            return null;
        }
    }
项目:dynamodb-janusgraph-storage-backend    文件:AbstractDynamoDbStore.java   
@Override
public void acquireLock(final StaticBuffer key, final StaticBuffer column, final StaticBuffer expectedValue, final StoreTransaction txh) throws BackendException {
    final DynamoDbStoreTransaction tx = DynamoDbStoreTransaction.getTx(txh);
    final Pair<StaticBuffer, StaticBuffer> keyColumn = Pair.of(key, column);

    final DynamoDbStoreTransaction existing;
    try {
        existing = keyColumnLocalLocks.get(keyColumn, () -> tx);
    } catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw new TemporaryLockingException("Unable to acquire lock", e);
    }
    if (null != existing && tx != existing) {
        throw new TemporaryLockingException(String.format("tx %s already locked key-column %s when tx %s tried to lock", existing.toString(), keyColumn.toString(), tx.toString()));
    }

    // Titan's locking expects that only the first expectedValue for a given key/column should be used
    tx.putKeyColumnOnlyIfItIsNotYetChangedInTx(this, key, column, expectedValue);
}
项目:guava-libraries    文件:CacheLoadingTest.java   
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
项目:presto    文件:JoinProbeCompiler.java   
public OperatorFactory compileJoinOperatorFactory(int operatorId,
        PlanNodeId planNodeId,
        LookupSourceSupplier lookupSourceSupplier,
        List<? extends Type> probeTypes,
        List<Integer> probeJoinChannel,
        Optional<Integer> probeHashChannel,
        JoinType joinType)
{
    try {
        HashJoinOperatorFactoryFactory operatorFactoryFactory = joinProbeFactories.get(new JoinOperatorCacheKey(probeTypes, probeJoinChannel, probeHashChannel, joinType));
        return operatorFactoryFactory.createHashJoinOperatorFactory(operatorId, planNodeId, lookupSourceSupplier, probeTypes, probeJoinChannel, joinType);
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:guava    文件:CacheLoadingTest.java   
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache =
      CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
项目:guava    文件:CacheLoadingTest.java   
public void testBulkLoadError() throws ExecutionException {
  Error e = new Error();
  CacheLoader<Object, Object> loader = errorLoader(e);
  LoadingCache<Object, Object> cache =
      CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (ExecutionError expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
项目:guava-mock    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:googles-monorepo-demo    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
        checkNotNull(key);
        checkNotNull(loader);
        try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
            ReferenceEntry<K, V> e = getEntry(key, hash);
            if (e != null) {
                long now = map.ticker.read();
                V value = getLiveValue(e, now);
                if (value != null) {
                        recordRead(e, now);
                        statsCounter.recordHits(1);
                        return scheduleRefresh(e, key, hash, value, now, loader);
                }
                ValueReference<K, V> valueReference = e.getValueReference();
                if (valueReference.isLoading()) {
                        return waitForLoadingValue(e, key, valueReference);
                }
            }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
        } catch (ExecutionException ee) {
          Throwable cause = ee.getCause();
          if (cause instanceof Error) {
                                                                                       throw new ExecutionError((Error) cause);
          } else if (cause instanceof RuntimeException) {
            throw new UncheckedExecutionException(cause);
          }
          throw ee;
        } finally {
          postReadCleanup();
        }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:codebuff    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:bts    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:j2objc    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:guava-libraries    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:presto    文件:DatabaseShardManager.java   
private int getOrCreateNodeId(String nodeIdentifier)
{
    try {
        return nodeIdCache.getUnchecked(nodeIdentifier);
    }
    catch (UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:presto    文件:OrderingCompiler.java   
public PagesIndexOrdering compilePagesIndexOrdering(List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders)
{
    requireNonNull(sortTypes, "sortTypes is null");
    requireNonNull(sortChannels, "sortChannels is null");
    requireNonNull(sortOrders, "sortOrders is null");

    try {
        return pagesIndexOrderings.get(new PagesIndexComparatorCacheKey(sortTypes, sortChannels, sortOrders));
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:presto    文件:JoinCompiler.java   
public LookupSourceFactory compileLookupSourceFactory(List<? extends Type> types, List<Integer> joinChannels)
{
    try {
        return lookupSourceFactories.get(new CacheKey(types, joinChannels));
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:presto    文件:JoinCompiler.java   
public PagesHashStrategyFactory compilePagesHashStrategyFactory(List<Type> types, List<Integer> joinChannels)
{
    requireNonNull(types, "types is null");
    requireNonNull(joinChannels, "joinChannels is null");

    try {
        return new PagesHashStrategyFactory(hashStrategies.get(new CacheKey(types, joinChannels)));
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:presto    文件:CachingHiveMetastore.java   
private static <K, V> V get(LoadingCache<K, V> cache, K key)
{
    try {
        return cache.get(key);
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:presto    文件:CachingHiveMetastore.java   
private static <K, V> Map<K, V> getAll(LoadingCache<K, V> cache, Iterable<K> keys)
{
    try {
        return cache.getAll(keys);
    }
    catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
        throw Throwables.propagate(e.getCause());
    }
}
项目:VectorAttackScanner    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:guava    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:guava    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:sharepoint    文件:RareModificationCacheTest.java   
@Test(expected = ExecutionError.class)
public void testGetError() throws IOException {
  cache.get(new RareModificationCache.CacheKey<Object>() {
    @Override
    public Object computeValue() throws IOException {
      throw new Error();
    }
  });
}
项目:cnGuava    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
    checkNotNull(key);
    checkNotNull(loader);
    try {
        if (count != 0) { // 确保可见性, read-volatile
            // don't call getLiveEntry, which would ignore loading values
            ReferenceEntry<K, V> e = getEntry(key, hash);
            if (e != null) {
                long now = map.ticker.read();
                V value = getLiveValue(e, now);// 获取未过期的数据
                if (value != null) {
                    recordRead(e, now);// access队列,还有最近使用队列
                    statsCounter.recordHits(1);// 命中啦
                    return scheduleRefresh(e, key, hash, value, now, loader);// 调度refresh,如果设置了refresh时间的话
                }
                ValueReference<K, V> valueReference = e.getValueReference();
                if (valueReference.isLoading()) { // 只有strong引用,其他基本上都是false
                    return waitForLoadingValue(e, key, valueReference);
                }
            }
        }

        // at this point e is either null or expired;
        return lockedGetOrLoad(key, hash, loader);// 重新加载数据到cache
    } catch (ExecutionException ee) {
        Throwable cause = ee.getCause();
        if (cause instanceof Error) {
            throw new ExecutionError((Error) cause);
        } else if (cause instanceof RuntimeException) {
            throw new UncheckedExecutionException(cause);
        }
        throw ee;
    } finally {
        postReadCleanup();
    }
}
项目:elasticservices    文件:CounterCacheCompositeMonitor.java   
public void incr(final K key) {
    try {
        counters.get(key).increment();
    } catch (final UncheckedExecutionException | ExecutionException | ExecutionError e) {
        LOGGER.error("Error incrementing counter.", e);
    }
}
项目:org.openntf.domino    文件:LocalCache.java   
V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
  checkNotNull(key);
  checkNotNull(loader);
  try {
    if (count != 0) { // read-volatile
      // don't call getLiveEntry, which would ignore loading values
      ReferenceEntry<K, V> e = getEntry(key, hash);
      if (e != null) {
        long now = map.ticker.read();
        V value = getLiveValue(e, now);
        if (value != null) {
          recordRead(e, now);
          statsCounter.recordHits(1);
          return scheduleRefresh(e, key, hash, value, now, loader);
        }
        ValueReference<K, V> valueReference = e.getValueReference();
        if (valueReference.isLoading()) {
          return waitForLoadingValue(e, key, valueReference);
        }
      }
    }

    // at this point e is either null or expired;
    return lockedGetOrLoad(key, hash, loader);
  } catch (ExecutionException ee) {
    Throwable cause = ee.getCause();
    if (cause instanceof Error) {
      throw new ExecutionError((Error) cause);
    } else if (cause instanceof RuntimeException) {
      throw new UncheckedExecutionException(cause);
    }
    throw ee;
  } finally {
    postReadCleanup();
  }
}
项目:maker    文件:ParametrizedMethodMemoizer.java   
@Override
protected final StringConcatenationClient cacheCall() {
  StringConcatenationClient _client = new StringConcatenationClient() {
    @Override
    protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
      _builder.append("try {");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("return ");
      String _cacheFieldName = ParametrizedMethodMemoizer.this.cacheFieldName();
      _builder.append(_cacheFieldName, "\t");
      _builder.append(".get(");
      StringConcatenationClient _parametersToCacheKey = ParametrizedMethodMemoizer.this.parametersToCacheKey();
      _builder.append(_parametersToCacheKey, "\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("} catch (Throwable e) {");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("if (e instanceof ");
      _builder.append(ExecutionException.class, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("|| e instanceof ");
      _builder.append(UncheckedExecutionException.class, "\t\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("|| e instanceof ");
      _builder.append(ExecutionError.class, "\t\t");
      _builder.append(") {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("Throwable cause = e.getCause();");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("throw ");
      _builder.append(Exceptions.class, "\t\t");
      _builder.append(".sneakyThrow(cause);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("} else {");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("throw ");
      _builder.append(Exceptions.class, "\t\t");
      _builder.append(".sneakyThrow(e);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
    }
  };
  return _client;
}