本文整理汇总了Java中com.google.common.util.concurrent.ExecutionError类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionError类的具体用法?Java ExecutionError怎么用?Java ExecutionError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionError类属于com.google.common.util.concurrent包,在下文中一共展示了ExecutionError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例2: testBulkLoadError
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
示例3: get
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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;
}
}
示例4: constructDB
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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;
}
}
示例5: acquireLock
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
@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);
}
示例6: compileJoinOperatorFactory
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例7: testBulkLoadError
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
示例8: get
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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();
}
}
示例9: get
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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();
}
}
示例10: getOrCreateNodeId
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
private int getOrCreateNodeId(String nodeIdentifier)
{
try {
return nodeIdCache.getUnchecked(nodeIdentifier);
}
catch (UncheckedExecutionException | ExecutionError e) {
throw Throwables.propagate(e.getCause());
}
}
示例11: compilePagesIndexOrdering
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例12: compileLookupSourceFactory
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例13: compilePagesHashStrategyFactory
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例14: get
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}
示例15: getAll
import com.google.common.util.concurrent.ExecutionError; //导入依赖的package包/类
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());
}
}