import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.HashedWheelTimer;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
// Count all flows we read from datastore for debugging purposes.
// This number do not always represent how many flows were actually added
// to DeviceFlowRegistry, because of possible duplicates.
- long flowCount = Optional.ofNullable(result)
- .map(Collections::singleton)
- .orElse(Collections.emptySet())
- .stream()
- .flatMap(Collection::stream)
- .filter(Objects::nonNull)
- .flatMap(flowCapableNodeOptional
- -> com.google.common.base.Optional.fromJavaUtil(flowCapableNodeOptional).asSet().stream())
- .filter(Objects::nonNull)
- .filter(flowCapableNode -> flowCapableNode.getTable() != null)
- .flatMap(flowCapableNode -> flowCapableNode.getTable().stream())
- .filter(Objects::nonNull)
- .filter(table -> table.getFlow() != null)
- .flatMap(table -> table.getFlow().stream())
- .filter(Objects::nonNull)
- .count();
+ long flowCount = 0;
+ if (result != null) {
+ for (Optional<FlowCapableNode> optNode : result) {
+ if (optNode.isPresent()) {
+ flowCount += optNode.get().nonnullTable().stream()
+ .filter(Objects::nonNull)
+ .flatMap(table -> table.nonnullFlow().stream())
+ .filter(Objects::nonNull)
+ .count();
+ }
+ }
+ }
LOG.debug("Finished filling flow registry with {} flows for node: {}", flowCount, deviceInfo);
}