@Test public void testComputeLayer1PhysicalTopology() { String c1Name = "c1"; String c2Name = "c2"; String c1i1Name = "c1i1"; String c1i2Name = "c1i2"; String c2i1Name = "c2i1"; String c2i2Name = "c2i2"; Configuration c1 = _cb.setHostname(c1Name).build(); Vrf v1 = _vb.setOwner(c1).build(); _ib.setOwner(c1).setVrf(v1); _ib.setName(c1i1Name).build(); _ib.setName(c1i2Name).build(); Configuration c2 = _cb.setHostname(c2Name).build(); Vrf v2 = _vb.setOwner(c2).build(); _ib.setOwner(c2).setVrf(v2); _ib.setName(c2i1Name).build(); _ib.setName(c2i2Name).setActive(false).build(); Map<String, Configuration> configurations = ImmutableMap.of(c1Name, c1, c2Name, c2); Layer1Topology rawLayer1Topology = new Layer1Topology( ImmutableSet.of( new Layer1Edge(new Layer1Node(c1Name, c1i1Name), new Layer1Node(c2Name, c2i1Name)), new Layer1Edge(new Layer1Node(c2Name, c2i1Name), new Layer1Node(c1Name, c1i1Name)), new Layer1Edge(new Layer1Node(c1Name, c1i2Name), new Layer1Node(c2Name, c2i2Name)), new Layer1Edge( new Layer1Node(c2Name, c2i2Name), new Layer1Node(c1Name, c1i2Name)))); assertThat( TopologyUtil.cleanLayer1PhysicalTopology(rawLayer1Topology, configurations) .getGraph() .edges(), containsInAnyOrder( new Layer1Edge(new Layer1Node(c1Name, c1i1Name), new Layer1Node(c2Name, c2i1Name)), new Layer1Edge(new Layer1Node(c2Name, c2i1Name), new Layer1Node(c1Name, c1i1Name)))); }
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);  }