@Test public void testIncompleteLayer1TopologyHandlingUnusable() { String n1Name = "n1"; String n2Name = "n2"; String nCorruptName = "n"; String iName = "i1"; Layer1Node n1 = new Layer1Node(n1Name, iName); Layer1Node n2 = new Layer1Node(n2Name, iName); Layer1Node nCorrupt = new Layer1Node(nCorruptName, iName); _ib.setActive(true).setName(iName); Configuration c1 = _cb.setHostname(n1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1).build(); Configuration c2 = _cb.setHostname(n2Name).build(); Vrf v2 = _vb.setOwner(c2).build(); _ib.setOwner(c2).setVrf(v2).build(); Layer1Topology rawLayer1Topology = new Layer1Topology(ImmutableList.of(new Layer1Edge(n1, n2), new Layer1Edge(n2, nCorrupt))); Map<String, Configuration> configurations = ImmutableMap.of(n1Name, c1, n2Name, c2); Layer1Topology layer1PhysicalTopology = TopologyUtil.cleanLayer1PhysicalTopology(rawLayer1Topology, configurations); assertThat( layer1PhysicalTopology.getGraph().edges(), containsInAnyOrder(new Layer1Edge(n1, n2), new Layer1Edge(n2, n1))); }
public static @Nonnull Layer1Topology cleanLayer1PhysicalTopology( @Nonnull Layer1Topology rawLayer1Topology, @Nonnull Map<String, Configuration> configurations) { ImmutableSet.Builder<Layer1Edge> edges = ImmutableSet.builder(); rawLayer1Topology.getGraph().edges().stream() .filter( edge -> { Interface i1 = getInterface(edge.getNode1(), configurations); Interface i2 = getInterface(edge.getNode2(), configurations); return i1 != null && i2 != null && i1.getActive() && i2.getActive(); }) .forEach( edge -> { edges.add(edge); edges.add(edge.reverse()); }); return new Layer1Topology(edges.build()); }
TopologyUtil { public static @Nonnull Layer1Topology cleanLayer1PhysicalTopology( @Nonnull Layer1Topology rawLayer1Topology, @Nonnull Map<String, Configuration> configurations) { ImmutableSet.Builder<Layer1Edge> edges = ImmutableSet.builder(); rawLayer1Topology.getGraph().edges().stream() .filter( edge -> { Interface i1 = getInterface(edge.getNode1(), configurations); Interface i2 = getInterface(edge.getNode2(), configurations); return i1 != null && i2 != null && i1.getActive() && i2.getActive(); }) .forEach( edge -> { edges.add(edge); edges.add(edge.reverse()); }); return new Layer1Topology(edges.build()); } }
TopologyUtil { public static @Nonnull Layer1Topology cleanLayer1PhysicalTopology( @Nonnull Layer1Topology rawLayer1Topology, @Nonnull Map<String, Configuration> configurations) { ImmutableSet.Builder<Layer1Edge> edges = ImmutableSet.builder(); rawLayer1Topology.getGraph().edges().stream() .filter( edge -> { Interface i1 = getInterface(edge.getNode1(), configurations); Interface i2 = getInterface(edge.getNode2(), configurations); return i1 != null && i2 != null && i1.getActive() && i2.getActive(); }) .forEach( edge -> { edges.add(edge); edges.add(edge.reverse()); }); return new Layer1Topology(edges.build()); } private  TopologyUtil(); }
TopologyUtil { public static @Nonnull Layer1Topology cleanLayer1PhysicalTopology( @Nonnull Layer1Topology rawLayer1Topology, @Nonnull Map<String, Configuration> configurations) { ImmutableSet.Builder<Layer1Edge> edges = ImmutableSet.builder(); rawLayer1Topology.getGraph().edges().stream() .filter( edge -> { Interface i1 = getInterface(edge.getNode1(), configurations); Interface i2 = getInterface(edge.getNode2(), configurations); return i1 != null && i2 != null && i1.getActive() && i2.getActive(); }) .forEach( edge -> { edges.add(edge); edges.add(edge.reverse()); }); return new Layer1Topology(edges.build()); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine); }
TopologyUtil { public static @Nonnull Layer1Topology cleanLayer1PhysicalTopology( @Nonnull Layer1Topology rawLayer1Topology, @Nonnull Map<String, Configuration> configurations) { ImmutableSet.Builder<Layer1Edge> edges = ImmutableSet.builder(); rawLayer1Topology.getGraph().edges().stream() .filter( edge -> { Interface i1 = getInterface(edge.getNode1(), configurations); Interface i2 = getInterface(edge.getNode2(), configurations); return i1 != null && i2 != null && i1.getActive() && i2.getActive(); }) .forEach( edge -> { edges.add(edge); edges.add(edge.reverse()); }); return new Layer1Topology(edges.build()); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine);  }