@Test public void testTransformInterAreaRoutesOnExportNonABR() { OspfInterAreaRoute route0 = OspfInterAreaRoute.builder() .setArea(0) .setNetwork(Prefix.ZERO) .setMetric(1) .setNextHopIp(Ip.parse("8.8.8.8")) .build(); OspfInterAreaRoute route1 = OspfInterAreaRoute.builder() .setArea(1) .setNetwork(Prefix.parse("1.0.0.0/8")) .setMetric(42) .setNextHopIp(Ip.parse("8.8.8.8")) .build(); final Ip nextHopIp = Ip.parse("9.9.9.9"); final RibDelta<OspfInterAreaRoute> delta = RibDelta.<OspfInterAreaRoute>builder().add(route0).add(route1).build(); Ip neighborIp = Ip.parse("2.2.2.2"); Collection<RouteAdvertisement<OspfInterAreaRoute>> transformed = transformInterAreaRoutesOnExportNonABR(delta, AREA0_CONFIG, neighborIp, nextHopIp, null); assertThat( transformed, contains( hasRoute( allOf( hasPrefix(route0.getNetwork()), hasNextHopIp(equalTo(nextHopIp)), hasMetric(route0.getMetric()))))); transformed = transformInterAreaRoutesOnExportNonABR(delta, AREA0_CONFIG, neighborIp, nextHopIp, 999L); assertThat( transformed, contains( hasRoute( allOf( hasPrefix(route0.getNetwork()), hasNextHopIp(equalTo(nextHopIp)), hasMetric(999L))))); }
@VisibleForTesting static Collection<RouteAdvertisement<OspfInterAreaRoute>> transformInterAreaRoutesOnExportNonABR( RibDelta<OspfInterAreaRoute> delta, OspfArea areaConfig, Ip neighborIp, Ip nextHopIp, @Nullable Long customMetric) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .filter(r -> !r.getRoute().getNextHopIp().equals(neighborIp)) .map( r -> r.toBuilder() .setRoute( r.getRoute() .toBuilder() .setMetric(firstNonNull(customMetric, r.getRoute().getMetric())) .setNextHopIp(nextHopIp) .build()) .build()) .collect(ImmutableSet.toImmutableSet()); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Collection<RouteAdvertisement<OspfInterAreaRoute>> transformInterAreaRoutesOnExportNonABR( RibDelta<OspfInterAreaRoute> delta, OspfArea areaConfig, Ip neighborIp, Ip nextHopIp, @Nullable Long customMetric) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .filter(r -> !r.getRoute().getNextHopIp().equals(neighborIp)) .map( r -> r.toBuilder() .setRoute( r.getRoute() .toBuilder() .setMetric(firstNonNull(customMetric, r.getRoute().getMetric())) .setNextHopIp(nextHopIp) .build()) .build()) .collect(ImmutableSet.toImmutableSet()); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Collection<RouteAdvertisement<OspfInterAreaRoute>> transformInterAreaRoutesOnExportNonABR( RibDelta<OspfInterAreaRoute> delta, OspfArea areaConfig, Ip neighborIp, Ip nextHopIp, @Nullable Long customMetric) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .filter(r -> !r.getRoute().getNextHopIp().equals(neighborIp)) .map( r -> r.toBuilder() .setRoute( r.getRoute() .toBuilder() .setMetric(firstNonNull(customMetric, r.getRoute().getMetric())) .setNextHopIp(nextHopIp) .build()) .build()) .collect(ImmutableSet.toImmutableSet()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Collection<RouteAdvertisement<OspfInterAreaRoute>> transformInterAreaRoutesOnExportNonABR( RibDelta<OspfInterAreaRoute> delta, OspfArea areaConfig, Ip neighborIp, Ip nextHopIp, @Nullable Long customMetric) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .filter(r -> !r.getRoute().getNextHopIp().equals(neighborIp)) .map( r -> r.toBuilder() .setRoute( r.getRoute() .toBuilder() .setMetric(firstNonNull(customMetric, r.getRoute().getMetric())) .setNextHopIp(nextHopIp) .build()) .build()) .collect(ImmutableSet.toImmutableSet()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Collection<RouteAdvertisement<OspfInterAreaRoute>> transformInterAreaRoutesOnExportNonABR( RibDelta<OspfInterAreaRoute> delta, OspfArea areaConfig, Ip neighborIp, Ip nextHopIp, @Nullable Long customMetric) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .filter(r -> !r.getRoute().getNextHopIp().equals(neighborIp)) .map( r -> r.toBuilder() .setRoute( r.getRoute() .toBuilder() .setMetric(firstNonNull(customMetric, r.getRoute().getMetric())) .setNextHopIp(nextHopIp) .build()) .build()) .collect(ImmutableSet.toImmutableSet()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty();  }