ImmutableList<JavaFileObject> getGeneratedSources() { ImmutableList.Builder<JavaFileObject> result = ImmutableList.builder(); for (Entry<URI, JavaFileObject> entry : inMemoryFileObjects.asMap().entrySet()) { if (entry.getKey().getPath().startsWith("/" + StandardLocation.SOURCE_OUTPUT.name()) && (entry.getValue().getKind() == Kind.SOURCE)) { result.add(entry.getValue()); } } return result.build(); }
@Override public Map<Subject, Boolean> getAllWithPermission(Set<Context> contexts, String permission) { final ImmutableMap.Builder<Subject, Boolean> ret = ImmutableMap.builder(); for (PEXSubject subject : subjectCache.asMap().values()) { Tristate permissionValue = subject.getPermissionValue( contexts == null ? subject.getActiveContexts() : contexts, permission); if (permissionValue != Tristate.UNDEFINED) { ret.put(subject, permissionValue.asBoolean()); } } return ret.build(); }
@Override public void close() { if (state.equals(ReaderWriterState.OPEN)) { LOG.debug("Closing all cached writers for view:{}", view); for (DatasetWriter<E> writer : cachedWriters.asMap().values()) { LOG.debug("Closing partition writer:{}", writer); writer.close(); } state = ReaderWriterState.CLOSED; } }
public static void updateRates(String type, long rate) { LOGGER.debug("updateRates : type={}, rate={}", type, rate); Iterator<RateLimiterDescriptor> iterator = rateLimiterMap.asMap().keySet().iterator(); while (iterator.hasNext()) { RateLimiterDescriptor oldRateDesc = iterator.next(); if (type.equals(oldRateDesc.getType())) { LOGGER.trace("updateRates : invalidated rate={}", oldRateDesc); rateLimiterMap.invalidate(oldRateDesc); RateLimiterDescriptor newRateDesc = new RateLimiterDescriptor(oldRateDesc.getType(), oldRateDesc.getAppId(), rate); LOGGER.trace("updateRates : updating rate desc={}, rate={}", newRateDesc, rate); rateLimiterMap.put(newRateDesc, RateLimiter.create(rate)); rateLimiterMap.refresh(newRateDesc); } } }
/** * Computes arbitrary resource aggregates based on a query, a filter, and a grouping function. * * @param query Query to select tasks for aggregation. * @param filter Filter to apply on query result tasks. * @param keyFunction Function to define aggregation groupings. * @param <K> Key type. * @return A map from the keys to their aggregates based on the tasks fetched. * @throws StorageException if there was a problem fetching tasks from storage. */ public <K> Map<K, Metric> computeAggregates( Query.Builder query, Predicate<ITaskConfig> filter, Function<ITaskConfig, K> keyFunction) throws StorageException { LoadingCache<K, Metric> metrics = CacheBuilder.newBuilder() .build( new CacheLoader<K, Metric>() { @Override public Metric load(K key) { return new Metric(); } }); for (ITaskConfig task : Iterables.filter(getTasks(query), filter)) { metrics.getUnchecked(keyFunction.apply(task)).accumulate(task); } return metrics.asMap(); }
ImmutableList<JavaFileObject> getOutputFiles() { return ImmutableList.copyOf(inMemoryFileObjects.asMap().values()); }
public Collection<WorkerData> values() { return workerCache.asMap().values(); }
Iterable<PEXSubject> getActiveSubjects() { return subjectCache.asMap().values(); }
boolean remove(K key) { return delegate.asMap().remove(key) != null; }
@Override public Set<DefinitionKey> getAllKeys() { return localCache.asMap().keySet(); }