@Test public void testComputeSomeoneReplies() { String c1 = "c1"; String i1 = "i1"; String c2 = "c2"; String i2 = "i2"; Edge e1 = Edge.of(c1, i1, c2, i2); Map<String, Map<String, IpSpace>> arpReplies = ImmutableMap.of(c2, ImmutableMap.of(i2, P1.toIpSpace())); Topology topology = new Topology(ImmutableSortedSet.of(e1)); Map<String, Map<String, IpSpace>> result = computeSomeoneReplies(topology, arpReplies); assertThat(result, hasEntry(equalTo(c1), hasEntry(equalTo(i1), containsIp(P1.getStartIp())))); assertThat(result, hasEntry(equalTo(c1), hasEntry(equalTo(i1), containsIp(P1.getEndIp())))); assertThat( result, hasEntry(equalTo(c1), hasEntry(equalTo(i1), not(containsIp(P2.getStartIp()))))); }
@VisibleForTesting static Map<String, Map<String, IpSpace>> computeSomeoneReplies( Topology topology, Map<String, Map<String, IpSpace>> arpReplies) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeSomeoneReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; Map<String, Map<String, AclIpSpace.Builder>> someoneRepliesByNode = new HashMap<>(); topology .getEdges() .forEach( edge -> someoneRepliesByNode .computeIfAbsent(edge.getNode1(), n -> new HashMap<>()) .computeIfAbsent(edge.getInt1(), i -> AclIpSpace.builder()) .thenPermitting((arpReplies.get(edge.getNode2()).get(edge.getInt2())))); return someoneRepliesByNode.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByNodeEntry -> someoneRepliesByNodeEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByInterfaceEntry -> someoneRepliesByInterfaceEntry.getValue().build())))); } finally { span.finish(); } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeSomeoneReplies( Topology topology, Map<String, Map<String, IpSpace>> arpReplies) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeSomeoneReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; Map<String, Map<String, AclIpSpace.Builder>> someoneRepliesByNode = new HashMap<>(); topology .getEdges() .forEach( edge -> someoneRepliesByNode .computeIfAbsent(edge.getNode1(), n -> new HashMap<>()) .computeIfAbsent(edge.getInt1(), i -> AclIpSpace.builder()) .thenPermitting((arpReplies.get(edge.getNode2()).get(edge.getInt2())))); return someoneRepliesByNode.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByNodeEntry -> someoneRepliesByNodeEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByInterfaceEntry -> someoneRepliesByInterfaceEntry.getValue().build())))); } finally { span.finish(); } } }
ForwardingAnalysisImpl implements ForwardingAnalysis, Serializable { @VisibleForTesting static Map<String, Map<String, IpSpace>> computeSomeoneReplies( Topology topology, Map<String, Map<String, IpSpace>> arpReplies) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeSomeoneReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; Map<String, Map<String, AclIpSpace.Builder>> someoneRepliesByNode = new HashMap<>(); topology .getEdges() .forEach( edge -> someoneRepliesByNode .computeIfAbsent(edge.getNode1(), n -> new HashMap<>()) .computeIfAbsent(edge.getInt1(), i -> AclIpSpace.builder()) .thenPermitting((arpReplies.get(edge.getNode2()).get(edge.getInt2())))); return someoneRepliesByNode.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByNodeEntry -> someoneRepliesByNodeEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByInterfaceEntry -> someoneRepliesByInterfaceEntry.getValue().build())))); } 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, IpSpace>> computeSomeoneReplies( Topology topology, Map<String, Map<String, IpSpace>> arpReplies) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeSomeoneReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; Map<String, Map<String, AclIpSpace.Builder>> someoneRepliesByNode = new HashMap<>(); topology .getEdges() .forEach( edge -> someoneRepliesByNode .computeIfAbsent(edge.getNode1(), n -> new HashMap<>()) .computeIfAbsent(edge.getInt1(), i -> AclIpSpace.builder()) .thenPermitting((arpReplies.get(edge.getNode2()).get(edge.getInt2())))); return someoneRepliesByNode.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByNodeEntry -> someoneRepliesByNodeEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByInterfaceEntry -> someoneRepliesByInterfaceEntry.getValue().build())))); } 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, IpSpace>> computeSomeoneReplies( Topology topology, Map<String, Map<String, IpSpace>> arpReplies) { Span span = GlobalTracer.get().buildSpan("ForwardingAnalysisImpl.computeSomeoneReplies").start(); try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) { assert scope != null; Map<String, Map<String, AclIpSpace.Builder>> someoneRepliesByNode = new HashMap<>(); topology .getEdges() .forEach( edge -> someoneRepliesByNode .computeIfAbsent(edge.getNode1(), n -> new HashMap<>()) .computeIfAbsent(edge.getInt1(), i -> AclIpSpace.builder()) .thenPermitting((arpReplies.get(edge.getNode2()).get(edge.getInt2())))); return someoneRepliesByNode.entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByNodeEntry -> someoneRepliesByNodeEntry.getValue().entrySet().stream() .collect( ImmutableMap.toImmutableMap( Entry::getKey , someoneRepliesByInterfaceEntry -> someoneRepliesByInterfaceEntry.getValue().build())))); } 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();  }