@Test public void testComputeRoutesWithNextHop() { String c1 = "c1"; String v1 = "v1"; String v2 = "v2"; String i1 = "i1"; ConnectedRoute r1 = new ConnectedRoute(P1, i1); MockFib mockFib = MockFib.builder() .setFibEntries( ImmutableMap.of( Ip.AUTO, ImmutableSet.of( new FibEntry(new FibForward(Ip.AUTO, i1), ImmutableList.of(r1))))) .build(); Map<String, Map<String, Fib>> fibs = ImmutableMap.of( c1, ImmutableMap.of( v1, mockFib, v2, mockFib)); Configuration config = _cb.setHostname(c1).build(); Vrf vrf1 = _vb.setName(v1).setOwner(config).build(); _vb.setName(v2).setOwner(config).build(); _ib.setName(i1).setVrf(vrf1).setOwner(config).build(); Map<String, Map<String, Map<String, Set<AbstractRoute>>>> result = ForwardingAnalysisImpl.computeRoutesWithNextHop(fibs); assertThat( result, equalTo( ImmutableMap.of( c1, ImmutableMap.of( v1, ImmutableMap.of(i1, ImmutableSet.of(r1)), v2, ImmutableMap.of(i1, ImmutableSet.of(r1)))))); }
@VisibleForTesting static Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithNextHop( Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithNextHop").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( fibs, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().allEntries().stream() .filter(fibEntry -> fibEntry.getAction() instanceof FibForward) .collect( Collectors.groupingBy( fibEntry -> ((FibForward) fibEntry.getAction()).getInterfaceName(), Collectors.mapping( FibEntry::getTopLevelRoute, Collectors.toSet()))))); } finally { span.finish(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithNextHop( Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithNextHop").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( fibs, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().allEntries().stream() .filter(fibEntry -> fibEntry.getAction() instanceof FibForward) .collect( Collectors.groupingBy( fibEntry -> ((FibForward) fibEntry.getAction()).getInterfaceName(), Collectors.mapping( FibEntry::getTopLevelRoute, Collectors.toSet()))))); } finally { span.finish(); } } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithNextHop( Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithNextHop").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( fibs, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().allEntries().stream() .filter(fibEntry -> fibEntry.getAction() instanceof FibForward) .collect( Collectors.groupingBy( fibEntry -> ((FibForward) fibEntry.getAction()).getInterfaceName(), Collectors.mapping( FibEntry::getTopLevelRoute, Collectors.toSet()))))); } finally { span.finish(); } } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithNextHop( Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithNextHop").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( fibs, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().allEntries().stream() .filter(fibEntry -> fibEntry.getAction() instanceof FibForward) .collect( Collectors.groupingBy( fibEntry -> ((FibForward) fibEntry.getAction()).getInterfaceName(), Collectors.mapping( FibEntry::getTopLevelRoute, Collectors.toSet()))))); } finally { span.finish(); } } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); @Nonnull @Override Map<String, Map<String, Map<String, IpSpace>>> getAcceptsIps(); @Override Map<String, Map<String, IpSpace>> getArpReplies(); @Override Map<String, Map<String, Map<Edge, IpSpace>>> getArpTrueEdge(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNextVrfIps(); @Override Map<String, Map<String, IpSpace>> getNullRoutedIps(); @Override Map<String, Map<String, IpSpace>> getRoutableIps(); @Override Map<String, Map<String, Map<String, IpSpace>>> getDeliveredToSubnet(); @Override Map<String, Map<String, Map<String, IpSpace>>> getExitsNetwork(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNeighborUnreachable(); @Override Map<String, Map<String, Map<String, IpSpace>>> getInsufficientInfo(); }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithNextHop( Map<String, Map<String, Fib>> fibs) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithNextHop").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( fibs, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().allEntries().stream() .filter(fibEntry -> fibEntry.getAction() instanceof FibForward) .collect( Collectors.groupingBy( fibEntry -> ((FibForward) fibEntry.getAction()).getInterfaceName(), Collectors.mapping( FibEntry::getTopLevelRoute, Collectors.toSet()))))); } finally { span.finish(); } } ForwardingAnalysisImpl(
      Map<String, Configuration> configurations,
      Map<String, Map<String, Fib>> fibs,
      Topology topology,
      Map<Location, LocationInfo> locationInfo); @Nonnull @Override Map<String, Map<String, Map<String, IpSpace>>> getAcceptsIps(); @Override Map<String, Map<String, IpSpace>> getArpReplies(); @Override Map<String, Map<String, Map<Edge, IpSpace>>> getArpTrueEdge(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNextVrfIps(); @Override Map<String, Map<String, IpSpace>> getNullRoutedIps(); @Override Map<String, Map<String, IpSpace>> getRoutableIps(); @Override Map<String, Map<String, Map<String, IpSpace>>> getDeliveredToSubnet(); @Override Map<String, Map<String, Map<String, IpSpace>>> getExitsNetwork(); @Override Map<String, Map<String, Map<String, IpSpace>>> getNeighborUnreachable(); @Override Map<String, Map<String, Map<String, IpSpace>>> getInsufficientInfo();  }