@Test public void testComputeRoutesWithDestIpEdge() { String c1 = "c1"; String c2 = "c2"; String v1 = "v1"; String i1 = "i1"; String i2 = "i2"; AbstractRoute r1 = new ConnectedRoute(P1, i1); Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp = ImmutableMap.of(c1, ImmutableMap.of(v1, ImmutableMap.of(i1, ImmutableSet.of(r1)))); Edge e1 = Edge.of(c1, i1, c2, i2); Topology topology = new Topology(ImmutableSortedSet.of(e1)); Map<String, Map<String, Map<Edge, Set<AbstractRoute>>>> result = computeRoutesWithDestIpEdge(topology, routesWhereDstIpCanBeArpIp); assertThat( result, hasEntry( equalTo(c1), hasEntry(equalTo(v1), equalTo(ImmutableMap.of(e1, ImmutableSet.of(r1)))))); }
@VisibleForTesting static Map<String, Map<String, Map<Edge, Set<AbstractRoute>>>> computeRoutesWithDestIpEdge( Topology topology, Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithDestIpEdge").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( routesWhereDstIpCanBeArpIp, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().entrySet().stream() .flatMap( ifaceEntry -> { NodeInterfacePair out = NodeInterfacePair.of(nodeEntry.getKey(), ifaceEntry.getKey()); Set<AbstractRoute> routes = ifaceEntry.getValue(); return topology.getNeighbors(out).stream() .map( receiver -> Maps.immutableEntry(new Edge(out, receiver), routes)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)))); } finally { span.finish(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<Edge, Set<AbstractRoute>>>> computeRoutesWithDestIpEdge( Topology topology, Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithDestIpEdge").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( routesWhereDstIpCanBeArpIp, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().entrySet().stream() .flatMap( ifaceEntry -> { NodeInterfacePair out = NodeInterfacePair.of(nodeEntry.getKey(), ifaceEntry.getKey()); Set<AbstractRoute> routes = ifaceEntry.getValue(); return topology.getNeighbors(out).stream() .map( receiver -> Maps.immutableEntry(new Edge(out, receiver), routes)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)))); } finally { span.finish(); } } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, Map<Edge, Set<AbstractRoute>>>> computeRoutesWithDestIpEdge( Topology topology, Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithDestIpEdge").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( routesWhereDstIpCanBeArpIp, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().entrySet().stream() .flatMap( ifaceEntry -> { NodeInterfacePair out = NodeInterfacePair.of(nodeEntry.getKey(), ifaceEntry.getKey()); Set<AbstractRoute> routes = ifaceEntry.getValue(); return topology.getNeighbors(out).stream() .map( receiver -> Maps.immutableEntry(new Edge(out, receiver), routes)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)))); } 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<Edge, Set<AbstractRoute>>>> computeRoutesWithDestIpEdge( Topology topology, Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithDestIpEdge").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( routesWhereDstIpCanBeArpIp, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().entrySet().stream() .flatMap( ifaceEntry -> { NodeInterfacePair out = NodeInterfacePair.of(nodeEntry.getKey(), ifaceEntry.getKey()); Set<AbstractRoute> routes = ifaceEntry.getValue(); return topology.getNeighbors(out).stream() .map( receiver -> Maps.immutableEntry(new Edge(out, receiver), routes)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)))); } 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<Edge, Set<AbstractRoute>>>> computeRoutesWithDestIpEdge( Topology topology, Map<String, Map<String, Map<String, Set<AbstractRoute>>>> routesWhereDstIpCanBeArpIp) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeRoutesWithDestIpEdge").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; return toImmutableMap( routesWhereDstIpCanBeArpIp, Entry::getKey, nodeEntry -> toImmutableMap( nodeEntry.getValue(), Entry::getKey, vrfEntry -> vrfEntry.getValue().entrySet().stream() .flatMap( ifaceEntry -> { NodeInterfacePair out = NodeInterfacePair.of(nodeEntry.getKey(), ifaceEntry.getKey()); Set<AbstractRoute> routes = ifaceEntry.getValue(); return topology.getNeighbors(out).stream() .map( receiver -> Maps.immutableEntry(new Edge(out, receiver), routes)); }) .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue)))); } 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();  }