@Test public void processUpdated_fail_noService() throws Exception { final List<RoutingDefinition> outcome = new ArrayList<>(); reactor.processUpdated(mapDifference, outcome); final RoutingDefinition expected = rightSide.get(1); Assert.assertEquals(1, outcome.size()); final RoutingDefinition actual = outcome.get(0); Assert.assertEquals(expected, distillDefinition(actual)); Assert.assertFalse(actual.isConsistent()); Assert.assertEquals("route can not be updated - missing routingService", actual.getInfo()); }
@VisibleForTesting void processUpdated(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesDiffering().forEach((vIface, routingDiff) -> { final Routing routing = routingServiceMap.get(vIface); if (routing != null) { findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final RoutingDefinition outcomingRouteDef; final boolean succeededRemoval = routing.removeRouteForCurrentService(); if (succeededRemoval) { final RoutingDefinition newRoutingDefinition = routingDiff.rightValue(); routing.setNetmask(newRoutingDefinition.getNetmask()) .setInterface(newRoutingDefinition.getInterface()); final boolean succeededAddition = routing.addRouteForCurrentService(); if (succeededAddition) { routing.updateArpTableForCurrentService(); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), true, "updated"); } else { outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be created (by update)"); } } else { LOG.warn("Route cannot be closed (U): {}", routing); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.leftValue(), false, "route can not be closed (by update)"); } findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add(outcomingRouteDef); } else { outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be updated - missing routingService")); } }); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processUpdated(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesDiffering().forEach((vIface, routingDiff) -> { final Routing routing = routingServiceMap.get(vIface); if (routing != null) { findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final RoutingDefinition outcomingRouteDef; final boolean succeededRemoval = routing.removeRouteForCurrentService(); if (succeededRemoval) { final RoutingDefinition newRoutingDefinition = routingDiff.rightValue(); routing.setNetmask(newRoutingDefinition.getNetmask()) .setInterface(newRoutingDefinition.getInterface()); final boolean succeededAddition = routing.addRouteForCurrentService(); if (succeededAddition) { routing.updateArpTableForCurrentService(); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), true, "updated"); } else { outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be created (by update)"); } } else { LOG.warn("Route cannot be closed (U): {}", routing); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.leftValue(), false, "route can not be closed (by update)"); } findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add(outcomingRouteDef); } else { outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be updated - missing routingService")); } }); } }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processUpdated(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesDiffering().forEach((vIface, routingDiff) -> { final Routing routing = routingServiceMap.get(vIface); if (routing != null) { findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final RoutingDefinition outcomingRouteDef; final boolean succeededRemoval = routing.removeRouteForCurrentService(); if (succeededRemoval) { final RoutingDefinition newRoutingDefinition = routingDiff.rightValue(); routing.setNetmask(newRoutingDefinition.getNetmask()) .setInterface(newRoutingDefinition.getInterface()); final boolean succeededAddition = routing.addRouteForCurrentService(); if (succeededAddition) { routing.updateArpTableForCurrentService(); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), true, "updated"); } else { outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be created (by update)"); } } else { LOG.warn("Route cannot be closed (U): {}", routing); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.leftValue(), false, "route can not be closed (by update)"); } findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add(outcomingRouteDef); } else { outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be updated - missing routingService")); } }); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processUpdated(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesDiffering().forEach((vIface, routingDiff) -> { final Routing routing = routingServiceMap.get(vIface); if (routing != null) { findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final RoutingDefinition outcomingRouteDef; final boolean succeededRemoval = routing.removeRouteForCurrentService(); if (succeededRemoval) { final RoutingDefinition newRoutingDefinition = routingDiff.rightValue(); routing.setNetmask(newRoutingDefinition.getNetmask()) .setInterface(newRoutingDefinition.getInterface()); final boolean succeededAddition = routing.addRouteForCurrentService(); if (succeededAddition) { routing.updateArpTableForCurrentService(); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), true, "updated"); } else { outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be created (by update)"); } } else { LOG.warn("Route cannot be closed (U): {}", routing); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.leftValue(), false, "route can not be closed (by update)"); } findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add(outcomingRouteDef); } else { outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be updated - missing routingService")); } }); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); @Override FluentFuture<? extends CommitInfo> updateRouting(@Nullable final SxpClusterRoute oldRoute,
                                                            @Nullable final SxpClusterRoute newRoute); @Override FluentFuture<? extends CommitInfo> wipeRouting(); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processUpdated(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesDiffering().forEach((vIface, routingDiff) -> { final Routing routing = routingServiceMap.get(vIface); if (routing != null) { findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final RoutingDefinition outcomingRouteDef; final boolean succeededRemoval = routing.removeRouteForCurrentService(); if (succeededRemoval) { final RoutingDefinition newRoutingDefinition = routingDiff.rightValue(); routing.setNetmask(newRoutingDefinition.getNetmask()) .setInterface(newRoutingDefinition.getInterface()); final boolean succeededAddition = routing.addRouteForCurrentService(); if (succeededAddition) { routing.updateArpTableForCurrentService(); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), true, "updated"); } else { outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be created (by update)"); } } else { LOG.warn("Route cannot be closed (U): {}", routing); outcomingRouteDef = RouteUtil.createOperationalRouteDefinition(routingDiff.leftValue(), false, "route can not be closed (by update)"); } findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add(outcomingRouteDef); } else { outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDiff.rightValue(), false, "route can not be updated - missing routingService")); } }); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); @Override FluentFuture<? extends CommitInfo> updateRouting(@Nullable final SxpClusterRoute oldRoute,
                                                            @Nullable final SxpClusterRoute newRoute); @Override FluentFuture<? extends CommitInfo> wipeRouting();  }