@Test public void testGetRows() { Multiset<Row> rows = getRows( _configurations, ImmutableSet.of("configuration_u", "configuration_w"), ImmutableSet.of("configuration_v", "configuration_x"), _ospfTopology, createTableMetadata().toColumnMap(), ImmutableSet.copyOf(OspfSessionStatus.values())); Iterator<Row> i = rows.iterator(); assertThat( i.next(), allOf( hasColumn( COL_INTERFACE, equalTo(NodeInterfacePair.of("configuration_u", "int_u")), Schema.INTERFACE), hasColumn(COL_VRF, equalTo("vrf_u"), Schema.STRING), hasColumn(COL_IP, equalTo(Ip.parse("192.0.2.1")), Schema.IP), hasColumn(COL_AREA, equalTo(1L), Schema.LONG), hasColumn( COL_REMOTE_INTERFACE, equalTo(NodeInterfacePair.of("configuration_v", "int_v")), Schema.INTERFACE), hasColumn(COL_REMOTE_VRF, equalTo("vrf_v"), Schema.STRING), hasColumn(COL_REMOTE_IP, equalTo(Ip.parse("192.0.2.2")), Schema.IP), hasColumn(COL_REMOTE_AREA, equalTo(1L), Schema.LONG), hasColumn( COL_SESSION_STATUS, equalTo(OspfSessionStatus.ESTABLISHED.toString()), Schema.STRING))); Row r2 = i.next(); assertThat( r2, allOf( hasColumn( COL_INTERFACE, equalTo(NodeInterfacePair.of("configuration_w", "int_w")), Schema.INTERFACE), hasColumn(COL_VRF, equalTo("vrf_w"), Schema.STRING), hasColumn(COL_IP, equalTo(Ip.parse("192.0.2.3")), Schema.IP), hasColumn(COL_AREA, equalTo(1L), Schema.LONG), hasColumn( COL_REMOTE_INTERFACE, equalTo(NodeInterfacePair.of("configuration_x", "int_x")), Schema.INTERFACE), hasColumn(COL_REMOTE_VRF, equalTo("vrf_x"), Schema.STRING), hasColumn(COL_REMOTE_IP, equalTo(Ip.parse("192.0.2.4")), Schema.IP), hasColumn(COL_REMOTE_AREA, equalTo(1L), Schema.LONG), hasColumn( COL_SESSION_STATUS, equalTo(OspfSessionStatus.NETWORK_TYPE_MISMATCH.toString()), Schema.STRING))); }
@VisibleForTesting static Multiset<Row> getRows( Map<String, Configuration> configurations, Set<String> nodes, Set<String> remoteNodes, CandidateOspfTopology ospfTopology, Map<String, ColumnMetadata> columnMetadataMap, Set<OspfSessionStatus> statuses) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Configuration configuration = configurations.get(node); configuration .getVrfs() .values() .forEach( vrf -> { for (OspfProcess ospfProcess : vrf.getOspfProcesses().values()) { ospfProcess .getOspfNeighborConfigs() .keySet() .forEach( ospfNeighborConfigId -> { Set<OspfNeighborConfigId> filteredNeighbors = ospfTopology.neighbors(ospfNeighborConfigId).stream() .filter( neighborConfigId -> remoteNodes.contains(neighborConfigId.getHostname())) .collect(ImmutableSet.toImmutableSet()); rows.addAll( getRowsForAllNeighbors( configurations, ospfNeighborConfigId, filteredNeighbors, ospfTopology, columnMetadataMap, statuses)); }); } }); } return rows; }
OspfSessionCompatibilityAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( Map<String, Configuration> configurations, Set<String> nodes, Set<String> remoteNodes, CandidateOspfTopology ospfTopology, Map<String, ColumnMetadata> columnMetadataMap, Set<OspfSessionStatus> statuses) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Configuration configuration = configurations.get(node); configuration .getVrfs() .values() .forEach( vrf -> { for (OspfProcess ospfProcess : vrf.getOspfProcesses().values()) { ospfProcess .getOspfNeighborConfigs() .keySet() .forEach( ospfNeighborConfigId -> { Set<OspfNeighborConfigId> filteredNeighbors = ospfTopology.neighbors(ospfNeighborConfigId).stream() .filter( neighborConfigId -> remoteNodes.contains(neighborConfigId.getHostname())) .collect(ImmutableSet.toImmutableSet()); rows.addAll( getRowsForAllNeighbors( configurations, ospfNeighborConfigId, filteredNeighbors, ospfTopology, columnMetadataMap, statuses)); }); } }); } return rows; } }
OspfSessionCompatibilityAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( Map<String, Configuration> configurations, Set<String> nodes, Set<String> remoteNodes, CandidateOspfTopology ospfTopology, Map<String, ColumnMetadata> columnMetadataMap, Set<OspfSessionStatus> statuses) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Configuration configuration = configurations.get(node); configuration .getVrfs() .values() .forEach( vrf -> { for (OspfProcess ospfProcess : vrf.getOspfProcesses().values()) { ospfProcess .getOspfNeighborConfigs() .keySet() .forEach( ospfNeighborConfigId -> { Set<OspfNeighborConfigId> filteredNeighbors = ospfTopology.neighbors(ospfNeighborConfigId).stream() .filter( neighborConfigId -> remoteNodes.contains(neighborConfigId.getHostname())) .collect(ImmutableSet.toImmutableSet()); rows.addAll( getRowsForAllNeighbors( configurations, ospfNeighborConfigId, filteredNeighbors, ospfTopology, columnMetadataMap, statuses)); }); } }); } return rows; } OspfSessionCompatibilityAnswerer(Question question, IBatfish batfish); }
OspfSessionCompatibilityAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( Map<String, Configuration> configurations, Set<String> nodes, Set<String> remoteNodes, CandidateOspfTopology ospfTopology, Map<String, ColumnMetadata> columnMetadataMap, Set<OspfSessionStatus> statuses) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Configuration configuration = configurations.get(node); configuration .getVrfs() .values() .forEach( vrf -> { for (OspfProcess ospfProcess : vrf.getOspfProcesses().values()) { ospfProcess .getOspfNeighborConfigs() .keySet() .forEach( ospfNeighborConfigId -> { Set<OspfNeighborConfigId> filteredNeighbors = ospfTopology.neighbors(ospfNeighborConfigId).stream() .filter( neighborConfigId -> remoteNodes.contains(neighborConfigId.getHostname())) .collect(ImmutableSet.toImmutableSet()); rows.addAll( getRowsForAllNeighbors( configurations, ospfNeighborConfigId, filteredNeighbors, ospfTopology, columnMetadataMap, statuses)); }); } }); } return rows; } OspfSessionCompatibilityAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
OspfSessionCompatibilityAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( Map<String, Configuration> configurations, Set<String> nodes, Set<String> remoteNodes, CandidateOspfTopology ospfTopology, Map<String, ColumnMetadata> columnMetadataMap, Set<OspfSessionStatus> statuses) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Configuration configuration = configurations.get(node); configuration .getVrfs() .values() .forEach( vrf -> { for (OspfProcess ospfProcess : vrf.getOspfProcesses().values()) { ospfProcess .getOspfNeighborConfigs() .keySet() .forEach( ospfNeighborConfigId -> { Set<OspfNeighborConfigId> filteredNeighbors = ospfTopology.neighbors(ospfNeighborConfigId).stream() .filter( neighborConfigId -> remoteNodes.contains(neighborConfigId.getHostname())) .collect(ImmutableSet.toImmutableSet()); rows.addAll( getRowsForAllNeighbors( configurations, ospfNeighborConfigId, filteredNeighbors, ospfTopology, columnMetadataMap, statuses)); }); } }); } return rows; } OspfSessionCompatibilityAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }