コード例 #1
0
 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();
 }
コード例 #2
0
 @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();
 }
コード例 #3
0
  @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;
    }
  }
コード例 #4
0
 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);
     }
   }
 }
コード例 #5
0
ファイル: ResourceCounter.java プロジェクト: pirater/aurora
  /**
   * 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();
  }
コード例 #6
0
 ImmutableList<JavaFileObject> getOutputFiles() {
   return ImmutableList.copyOf(inMemoryFileObjects.asMap().values());
 }
コード例 #7
0
ファイル: WorkerTracker.java プロジェクト: jhorwit2/hydra
 public Collection<WorkerData> values() {
   return workerCache.asMap().values();
 }
コード例 #8
0
 Iterable<PEXSubject> getActiveSubjects() {
   return subjectCache.asMap().values();
 }
コード例 #9
0
 boolean remove(K key) {
   return delegate.asMap().remove(key) != null;
 }
コード例 #10
0
 @Override
 public Set<DefinitionKey> getAllKeys() {
   return localCache.asMap().keySet();
 }