Esempio n. 1
0
  @Override
  public Collection<Resource> getResources(ResourceConsumer consumer) {
    checkNotNull(consumer);

    // NOTE: getting all entries may become performance bottleneck
    // TODO: revisit for better backend data structure
    Stream<DiscreteResource> discreteStream =
        discreteConsumers
            .entrySet()
            .stream()
            .filter(x -> x.getValue().value().equals(consumer))
            .map(Map.Entry::getKey);

    Stream<ContinuousResource> continuousStream =
        continuousConsumers
            .values()
            .stream()
            .flatMap(
                x ->
                    x.value()
                        .allocations()
                        .stream()
                        .map(y -> Maps.immutableEntry(x.value().original(), y)))
            .filter(x -> x.getValue().consumer().equals(consumer))
            .map(x -> x.getKey());

    return Stream.concat(discreteStream, continuousStream).collect(Collectors.toList());
  }
 @Override
 public Map<TunnelId, ResourceConsumer> getTunnelInfos() {
   return tunnelInfoMap
       .entrySet()
       .stream()
       .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
 }