@Override public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { return cache.get(key, valueLoader); }
@Override public InternalVertex get(final long id, final Retriever<Long, InternalVertex> retriever) { final Long vertexId = id; InternalVertex vertex = cache.getIfPresent(vertexId); if (vertex == null) { InternalVertex newVertex = volatileVertices.get(vertexId); if (newVertex == null) { newVertex = retriever.get(vertexId); } assert newVertex!=null; try { vertex = cache.get(vertexId, new NewVertexCallable(newVertex)); } catch (Exception e) { throw new AssertionError("Should not happen: "+e.getMessage()); } assert vertex!=null; } return vertex; }
/** @since 11.0 */ @Override public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { return delegate().get(key, valueLoader); }
/** @since 11.0 */ @Override public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { return delegate().get(key, valueLoader); }
/** @since 11.0 */ @Override public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException { return delegate().get(key, valueLoader); }
private Schema<?> get(final Class<?> cls, final Cache<Class<?>, Schema<?>> cache) { try { return cache.get(cls, () -> RuntimeSchema.createFrom(cls)); } catch (ExecutionException e) { return null; } }
private Schema<?> get(final Class<?> cls, Cache<Class<?>, Schema<?>> cache) { try { return cache.get(cls, () -> RuntimeSchema.createFrom(cls)); } catch (ExecutionException e) { e.printStackTrace(); return null; } }
@Override public List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey, Optional<Config> runtimeConfig) { try { return this.ownImportMap.get(configKey, () -> this.fallback.getOwnImports(configKey, runtimeConfig)); } catch (ExecutionException ee) { throw new RuntimeException(ee); } }
@Override public LookupResult get(LookupCacheKey key, Callable<LookupResult> loader) { try (final Timer.Context ignored = lookupTimer()) { return cache.get(key, loader); } catch (ExecutionException e) { LOG.warn("Loading value from data adapter failed for key {}, returning empty result", key, e); return LookupResult.empty(); } }
public SliceQuery getQuery(final InternalRelationType type, Direction dir) { CacheEntry ce; try { ce = cache.get(type.longId(),new Callable<CacheEntry>() { @Override public CacheEntry call() throws Exception { return new CacheEntry(edgeSerializer,type); } }); } catch (ExecutionException e) { throw new AssertionError("Should not happen: " + e.getMessage()); } assert ce!=null; return ce.get(dir); }
/** * Constructs a {@link Path} that points to the location of the given version of the {@link ConfigStore} on HDFS. If * this {@link Path} does not exist, a {@link VersionDoesNotExistException} is thrown. */ private Path getVersionRoot(String version) throws VersionDoesNotExistException { try { return this.versions.get(version, new VersionRootLoader(version)); } catch (ExecutionException e) { throw new RuntimeException( String.format("Error while checking if version \"%s\" for store \"%s\" exists", version, getStoreURI()), e); } }
public SliceQuery getQuery(final InternalRelationType type, Direction dir) { CacheEntry ce; try { ce = cache.get(type.longId(), () -> new CacheEntry(edgeSerializer,type)); } catch (ExecutionException e) { throw new AssertionError("Should not happen: " + e.getMessage()); } assert ce!=null; return ce.get(dir); }
public void testLoader() throws ExecutionException { final Cache<Integer, Integer> cache = CacheBuilder.newBuilder().build(); Callable<Integer> loader = new Callable<Integer>() { private int i = 0; @Override public Integer call() throws Exception { return ++i; } }; cache.put(0, 10); assertEquals(Integer.valueOf(10), cache.get(0, loader)); assertEquals(Integer.valueOf(1), cache.get(20, loader)); assertEquals(Integer.valueOf(2), cache.get(34, loader)); cache.invalidate(0); assertEquals(Integer.valueOf(3), cache.get(0, loader)); cache.put(0, 10); cache.invalidateAll(); assertEquals(Integer.valueOf(4), cache.get(0, loader)); }
private List<T> doTraverseGraphRecursively(T node, NodePath<T> nodePath) { try { return this.traversalCache.get(node, () -> computeRecursiveTraversal(node, nodePath)); } catch (ExecutionException | UncheckedExecutionException ee) { throw unpackExecutionException(ee); } }
@Override public void serialize(T value, JsonGenerator generator, SerializerProvider provider) throws IOException { if (value == null) { provider.defaultSerializeNull(generator); return; } try { Class<?> type = value.getClass(); JsonSerializer<T> serializer = serializerCache.get(type, () -> createSerializer(provider, type)); serializer.serializeWithType(value, generator, provider, typeSerializer); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause != null) { throwIfInstanceOf(cause, IOException.class); } throw new RuntimeException(e); } }
private static SearchArgument getSearchArgumentFromString(Configuration conf, String sargString) { try { return isSargsCacheEnabled(conf)? getSargsCache(conf).get(sargString, () -> create(sargString)) : create(sargString); } catch (ExecutionException exception) { throw new RuntimeException(exception); } }
private static SearchArgument getSearchArgumentFromExpression(Configuration conf, String sargString) { try { return isSargsCacheEnabled(conf)? getSargsCache(conf).get(sargString, () -> create(conf, SerializationUtilities.deserializeExpression(sargString))) : create(conf, SerializationUtilities.deserializeExpression(sargString)); } catch (ExecutionException exception) { throw new RuntimeException(exception); } }
private void checkRateLimitAvailable(Request request, Response response) throws ExecutionException { TokenBucket tokenBucket = rateLimiters.get(currentUsername(), () -> TokenBuckets.builder() .withCapacity(requestsPerMinute) .withInitialTokens(requestsPerMinute) .withRefillStrategy(new FixedIntervalRefillStrategy(ticker, requestsPerMinute, 1, TimeUnit.MINUTES)) .build()); response.header("X-RateLimit-Limit", String.valueOf(requestsPerMinute)); response.header("X-RateLimit-Remaining", String.valueOf(tokenBucket.getNumTokens())); if (!tokenBucket.tryConsume()) { throw HaltApiResponses.haltBecauseRateLimitExceeded(); } } }
@Override public void read(Message message) { ReadBuffer content = message.getContent().asReadBuffer(); String senderId = message.getSenderId(); TransactionLogHeader.Entry txentry = TransactionLogHeader.parse(content,serializer,times); TransactionLogHeader txheader = txentry.getHeader(); StandardTransactionId transactionId = new StandardTransactionId(senderId,txheader.getId(), txheader.getTimestamp()); TxEntry entry; try { entry = txCache.get(transactionId,entryFactory); } catch (ExecutionException e) { throw new AssertionError("Unexpected exception",e); } entry.update(txentry); }