@Test public void testVxlanEdgeToRows() { NetworkConfigurations nc = buildVxlanNetworkConfigurations(); Map<String, Configuration> configurations = nc.getMap(); Set<String> includeNodes = configurations.keySet(); Set<String> includeRemoteNodes = configurations.keySet(); VxlanNode node1 = VxlanNode.builder().setHostname(VXLAN_NODE1).setVni(VXLAN_VNI).build(); VxlanNode node2 = VxlanNode.builder().setHostname(VXLAN_NODE2).setVni(VXLAN_VNI).build(); assertThat( vxlanEdgeToRows(nc, includeNodes, includeRemoteNodes, EndpointPair.unordered(node1, node2)) .collect(ImmutableList.toImmutableList()), containsInAnyOrder(vxlanEdgeToRow(nc, node1, node2), vxlanEdgeToRow(nc, node2, node1))); assertThat( vxlanEdgeToRows( nc, ImmutableSet.of(VXLAN_NODE1), includeRemoteNodes, EndpointPair.unordered(node1, node2)) .collect(ImmutableList.toImmutableList()), containsInAnyOrder(vxlanEdgeToRow(nc, node1, node2))); assertThat( vxlanEdgeToRows( nc, includeNodes, ImmutableSet.of(VXLAN_NODE1), EndpointPair.unordered(node1, node2)) .collect(ImmutableList.toImmutableList()), containsInAnyOrder(vxlanEdgeToRow(nc, node2, node1))); }
@VisibleForTesting static Stream<Row> vxlanEdgeToRows( NetworkConfigurations nc, Set<String> includeNodes, Set<String> includeRemoteNodes, EndpointPair<VxlanNode> edge) { VxlanNode node1 = edge.nodeU(); VxlanNode node2 = edge.nodeV(); String h1 = node1.getHostname(); String h2 = node2.getHostname(); Stream.Builder<Row> builder = Stream.builder(); if (includeNodes.contains(h1) && includeRemoteNodes.contains(h2)) { builder.add(vxlanEdgeToRow(nc, node1, node2)); } if (includeNodes.contains(h2) && includeRemoteNodes.contains(h1)) { builder.add(vxlanEdgeToRow(nc, node2, node1)); } return builder.build(); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Stream<Row> vxlanEdgeToRows( NetworkConfigurations nc, Set<String> includeNodes, Set<String> includeRemoteNodes, EndpointPair<VxlanNode> edge) { VxlanNode node1 = edge.nodeU(); VxlanNode node2 = edge.nodeV(); String h1 = node1.getHostname(); String h2 = node2.getHostname(); Stream.Builder<Row> builder = Stream.builder(); if (includeNodes.contains(h1) && includeRemoteNodes.contains(h2)) { builder.add(vxlanEdgeToRow(nc, node1, node2)); } if (includeNodes.contains(h2) && includeRemoteNodes.contains(h1)) { builder.add(vxlanEdgeToRow(nc, node2, node1)); } return builder.build(); } }
EdgesAnswerer extends Answerer { @VisibleForTesting static Stream<Row> vxlanEdgeToRows( NetworkConfigurations nc, Set<String> includeNodes, Set<String> includeRemoteNodes, EndpointPair<VxlanNode> edge) { VxlanNode node1 = edge.nodeU(); VxlanNode node2 = edge.nodeV(); String h1 = node1.getHostname(); String h2 = node2.getHostname(); Stream.Builder<Row> builder = Stream.builder(); if (includeNodes.contains(h1) && includeRemoteNodes.contains(h2)) { builder.add(vxlanEdgeToRow(nc, node1, node2)); } if (includeNodes.contains(h2) && includeRemoteNodes.contains(h1)) { builder.add(vxlanEdgeToRow(nc, node2, node1)); } return builder.build(); } EdgesAnswerer(Question question, IBatfish batfish); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Stream<Row> vxlanEdgeToRows( NetworkConfigurations nc, Set<String> includeNodes, Set<String> includeRemoteNodes, EndpointPair<VxlanNode> edge) { VxlanNode node1 = edge.nodeU(); VxlanNode node2 = edge.nodeV(); String h1 = node1.getHostname(); String h2 = node2.getHostname(); Stream.Builder<Row> builder = Stream.builder(); if (includeNodes.contains(h1) && includeRemoteNodes.contains(h2)) { builder.add(vxlanEdgeToRow(nc, node1, node2)); } if (includeNodes.contains(h2) && includeRemoteNodes.contains(h1)) { builder.add(vxlanEdgeToRow(nc, node2, node1)); } return builder.build(); } EdgesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Stream<Row> vxlanEdgeToRows( NetworkConfigurations nc, Set<String> includeNodes, Set<String> includeRemoteNodes, EndpointPair<VxlanNode> edge) { VxlanNode node1 = edge.nodeU(); VxlanNode node2 = edge.nodeV(); String h1 = node1.getHostname(); String h2 = node2.getHostname(); Stream.Builder<Row> builder = Stream.builder(); if (includeNodes.contains(h1) && includeRemoteNodes.contains(h2)) { builder.add(vxlanEdgeToRow(nc, node1, node2)); } if (includeNodes.contains(h2) && includeRemoteNodes.contains(h1)) { builder.add(vxlanEdgeToRow(nc, node2, node1)); } return builder.build(); } EdgesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }