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


Java InvalidCacheLoadException类代码示例

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


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

示例1: waitForLoadingValue

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
V waitForLoadingValue(ReferenceEntry<K, V> e, K key, ValueReference<K, V> valueReference)
    throws ExecutionException {
  if (!valueReference.isLoading()) {
    throw new AssertionError();
  }

  checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
  // don't consider expiration as we're concurrent with loading
  try {
    V value = valueReference.waitForValue();
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    // re-read ticker now that loading has completed
    long now = map.ticker.read();
    recordRead(e, now);
    return value;
  } finally {
    statsCounter.recordMisses(1);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:LocalCache.java

示例2: getAndRecordStats

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/**
 * Waits uninterruptibly for {@code newValue} to be loaded, and then records loading stats.
 */
V getAndRecordStats(
    K key,
    int hash,
    LoadingValueReference<K, V> loadingValueReference,
    ListenableFuture<V> newValue)
    throws ExecutionException {
  V value = null;
  try {
    value = getUninterruptibly(newValue);
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
    storeLoadedValue(key, hash, loadingValueReference, value);
    return value;
  } finally {
    if (value == null) {
      statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
      removeLoadingValue(key, hash, loadingValueReference);
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:LocalCache.java

示例3: testBulkLoad_partial

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
public void testBulkLoad_partial() throws ExecutionException {
  final Object extraKey = new Object();
  final Object extraValue = new Object();
  CacheLoader<Object, Object> loader = new CacheLoader<Object, Object>() {
    @Override
    public Object load(Object key) throws Exception {
      throw new AssertionError();
    }

    @Override
    public Map<Object, Object> loadAll(Iterable<? extends Object> keys) throws Exception {
      Map<Object, Object> result = Maps.newHashMap();
      // ignore request keys
      result.put(extraKey, extraValue);
      return result;
    }
  };
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().build(loader);

  Object[] lookupKeys = new Object[] { new Object(), new Object(), new Object() };
  try {
    cache.getAll(asList(lookupKeys));
    fail();
  } catch (InvalidCacheLoadException expected) {}
  assertSame(extraValue, cache.asMap().get(extraKey));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:27,代码来源:CacheLoadingTest.java

示例4: testBulkLoadNull

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
public void testBulkLoadNull() throws ExecutionException {
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(constantLoader(null)));
  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 (InvalidCacheLoadException expected) {}
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:CacheLoadingTest.java

示例5: getStorableRepo

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
public Optional<Repository> getStorableRepo(final String repoName, final StorableIndexInfo indexInfo) {
    try {
        return Optional.fromNullable(cache.get(repoName, new Callable<Repository>() {
            @Override
            public Repository call() throws Exception {
                Repository repo = getStorableRepo(repoName);
                if (repo != null) {
                    if (indexInfo != null && indexInfo.getIndexDefinitions().size() > 0) {
                        repo.setIndexProducer(new IndexProducer(indexInfo.getIndexDefinitions()));
                    }
                    return repo;
                } else {
                    return null;
                }
            }
        }));
    } catch (ExecutionException | InvalidCacheLoadException e) {
        log.error(String.format("Error initializing repo for name [%s]: %s", repoName, ExceptionToString.format(e)));
        return Optional.absent();
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:22,代码来源:AbstractStorableRepoCache.java

示例6: waitForLoadingValue

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
V waitForLoadingValue(ReferenceEntry<K, V> e, K key, ValueReference<K, V> valueReference) throws ExecutionException {
  if (!valueReference.isLoading()) {
    throw new AssertionError();
  }
  checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
  // don't consider expiration as we're concurrent with loading
  try {
    V value = valueReference.waitForValue();
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    // re-read ticker now that loading has completed

    long now = map.ticker.read();
    recordRead(e, now);
    return value;
  } finally {
    statsCounter.recordMisses(1);
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:21,代码来源:LocalCache.java

示例7: getAndRecordStats

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/**
 * Waits uninterruptibly for {@code newValue} to be loaded, and then records loading stats.
 */

V getAndRecordStats(
  K key,
  int hash,
  LoadingValueReference<K, V> loadingValueReference,
  ListenableFuture<V> newValue) throws ExecutionException {
  V value = null;
  try {
    value = getUninterruptibly(newValue);
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
    storeLoadedValue(key, hash, loadingValueReference, value);
    return value;
  } finally {
    if (value == null) {
      statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
      removeLoadingValue(key, hash, loadingValueReference);
    }
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:26,代码来源:LocalCache.java

示例8: waitForLoadingValue

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
V waitForLoadingValue(ReferenceEntry<K, V> e, K key, ValueReference<K, V> valueReference) throws ExecutionException {
        if (!valueReference.isLoading()) {
    throw new AssertionError();
        }
        checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
  // don't consider expiration as we're concurrent with loading
        try {
    V value = valueReference.waitForValue();
    if (value == null) {
                                                                                                                        throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    // re-read ticker now that loading has completed

    long now = map.ticker.read();
    recordRead(e, now);
    return value;
        } finally {
          statsCounter.recordMisses(1);
        }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:21,代码来源:LocalCache.java

示例9: getAndRecordStats

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/**
 * Waits uninterruptibly for {@code newValue} to be loaded, and then records loading stats.
 */

V getAndRecordStats(
    K key,
    int hash,
    LoadingValueReference<K, V> loadingValueReference,
    ListenableFuture<V> newValue) throws ExecutionException {
        V value = null;
        try {
    value = getUninterruptibly(newValue);
    if (value == null) {
                                                                throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
    storeLoadedValue(key, hash, loadingValueReference, value);
    return value;
        } finally {
          if (value == null) {
            statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
            removeLoadingValue(key, hash, loadingValueReference);
          }
        }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:26,代码来源:LocalCache.java

示例10: waitForLoadingValue

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
V waitForLoadingValue(ReferenceEntry<K, V> e, K key, ValueReference<K, V> valueReference)
    throws ExecutionException {
  if (!valueReference.isLoading()) {
    throw new AssertionError();
  }

  checkState(!Thread.holdsLock(e), "Recursive load");
  // don't consider expiration as we're concurrent with loading
  try {
    V value = valueReference.waitForValue();
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    // re-read ticker now that loading has completed
    long now = map.ticker.read();
    recordRead(e, now);
    return value;
  } finally {
    statsCounter.recordMisses(1);
  }
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:LocalCache.java

示例11: getAndRecordStats

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/**
 * Waits uninterruptibly for {@code newValue} to be loaded, and then records loading stats.
 */
V getAndRecordStats(K key, int hash, LoadingValueReference<K, V> loadingValueReference,
    ListenableFuture<V> newValue) throws ExecutionException {
  V value = null;
  try {
    value = getUninterruptibly(newValue);
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
    storeLoadedValue(key, hash, loadingValueReference, value);
    return value;
  } finally {
    if (value == null) {
      statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
      removeLoadingValue(key, hash, loadingValueReference);
    }
  }
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:LocalCache.java

示例12: getAndRecordStats

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/** Waits uninterruptibly for {@code newValue} to be loaded, and then records loading stats. */
V getAndRecordStats(
    K key,
    int hash,
    LoadingValueReference<K, V> loadingValueReference,
    ListenableFuture<V> newValue)
    throws ExecutionException {
  V value = null;
  try {
    value = getUninterruptibly(newValue);
    if (value == null) {
      throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
    }
    statsCounter.recordLoadSuccess(loadingValueReference.elapsedNanos());
    storeLoadedValue(key, hash, loadingValueReference, value);
    return value;
  } finally {
    if (value == null) {
      statsCounter.recordLoadException(loadingValueReference.elapsedNanos());
      removeLoadingValue(key, hash, loadingValueReference);
    }
  }
}
 
开发者ID:google,项目名称:guava,代码行数:24,代码来源:LocalCache.java

示例13: testBulkLoadNull

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
public void testBulkLoadNull() throws ExecutionException {
  LoadingCache<Object, Object> cache =
      CacheBuilder.newBuilder().recordStats().build(bulkLoader(constantLoader(null)));
  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 (InvalidCacheLoadException expected) {
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
 
开发者ID:google,项目名称:guava,代码行数:21,代码来源:CacheLoadingTest.java

示例14: testGet_computeNull

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
public void testGet_computeNull() {
  LoadingCache<Object, Object> cache =
      CacheBuilder.newBuilder()
          .maximumSize(0)
          .removalListener(listener)
          .build(constantLoader(null));

  try {
    cache.getUnchecked(new Object());
    fail();
  } catch (InvalidCacheLoadException e) {
    /* expected */
  }

  assertTrue(listener.isEmpty());
  checkEmpty(cache);
}
 
开发者ID:google,项目名称:guava,代码行数:18,代码来源:NullCacheTest.java

示例15: waitForLoadingValue

import com.google.common.cache.CacheLoader.InvalidCacheLoadException; //导入依赖的package包/类
/**
 * 该entry以及存在,等待完成,被加载进来
 * 
 * @param e
 * @param key
 * @param valueReference
 * @return
 * @throws ExecutionException
 */
V waitForLoadingValue(ReferenceEntry<K, V> e, K key, ValueReference<K, V> valueReference)
        throws ExecutionException {
    if (!valueReference.isLoading()) {
        throw new AssertionError();
    }

    checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
    // don't consider expiration as we're concurrent with loading
    try {
        V value = valueReference.waitForValue();// 获取value引用
        if (value == null) {
            throw new InvalidCacheLoadException("CacheLoader returned null for key " + key + ".");
        }
        // re-read ticker now that loading has completed
        long now = map.ticker.read();
        recordRead(e, now);// 处理access队列
        return value;
    } finally {
        statsCounter.recordMisses(1);
    }
}
 
开发者ID:ketao1989,项目名称:cnGuava,代码行数:31,代码来源:LocalCache.java


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