@Test public void processAdded() throws Exception { final List<RoutingDefinition> outcome = new ArrayList<>(); Mockito.when(routingService.addRouteForCurrentService()).thenReturn(true); reactor.processAdded(mapDifference, outcome); final RoutingDefinition expected = rightSide.get(2); Assert.assertEquals(1, outcome.size()); final RoutingDefinition actual = outcome.get(0); Assert.assertEquals(expected, distillDefinition(actual)); Assert.assertTrue(actual.isConsistent()); Assert.assertEquals("added", actual.getInfo()); }
@VisibleForTesting void processAdded(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesOnlyOnRight().forEach((vIface, routingDef) -> { final boolean readyToAdd; final Routing existingRouting = routingServiceMap.get(vIface); if (existingRouting != null) { LOG.info("Found unexpected route -> closing it: {}", existingRouting); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final boolean removalSucceded = existingRouting.removeRouteForCurrentService(); if (!removalSucceded) { LOG.warn("Route cannot be closed (cleaning before A): {}", existingRouting); RoutingDefinition oldDefinition = RouteUtil.extractRoutingDefinition(existingRouting); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(oldDefinition, false, "route can not be closed (by cleaning before add)")); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); readyToAdd = false; } else { readyToAdd = true; } } else { readyToAdd = true; } if (readyToAdd) { final Routing routeService = routingServiceFactory.instantiateRoutingService(routingDef); routingServiceMap.put(vIface, routeService); final boolean succeeded = routeService.addRouteForCurrentService(); if (succeeded) { routeService.updateArpTableForCurrentService(); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDef, true, "added")); } else { LOG.warn("Route can not be created (by add): {}", routeService); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(routingDef, false, "route can not be created (by add)")); } } }); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processAdded(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesOnlyOnRight().forEach((vIface, routingDef) -> { final boolean readyToAdd; final Routing existingRouting = routingServiceMap.get(vIface); if (existingRouting != null) { LOG.info("Found unexpected route -> closing it: {}", existingRouting); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final boolean removalSucceded = existingRouting.removeRouteForCurrentService(); if (!removalSucceded) { LOG.warn("Route cannot be closed (cleaning before A): {}", existingRouting); RoutingDefinition oldDefinition = RouteUtil.extractRoutingDefinition(existingRouting); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(oldDefinition, false, "route can not be closed (by cleaning before add)")); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); readyToAdd = false; } else { readyToAdd = true; } } else { readyToAdd = true; } if (readyToAdd) { final Routing routeService = routingServiceFactory.instantiateRoutingService(routingDef); routingServiceMap.put(vIface, routeService); final boolean succeeded = routeService.addRouteForCurrentService(); if (succeeded) { routeService.updateArpTableForCurrentService(); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDef, true, "added")); } else { LOG.warn("Route can not be created (by add): {}", routeService); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(routingDef, false, "route can not be created (by add)")); } } }); } }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processAdded(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesOnlyOnRight().forEach((vIface, routingDef) -> { final boolean readyToAdd; final Routing existingRouting = routingServiceMap.get(vIface); if (existingRouting != null) { LOG.info("Found unexpected route -> closing it: {}", existingRouting); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final boolean removalSucceded = existingRouting.removeRouteForCurrentService(); if (!removalSucceded) { LOG.warn("Route cannot be closed (cleaning before A): {}", existingRouting); RoutingDefinition oldDefinition = RouteUtil.extractRoutingDefinition(existingRouting); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(oldDefinition, false, "route can not be closed (by cleaning before add)")); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); readyToAdd = false; } else { readyToAdd = true; } } else { readyToAdd = true; } if (readyToAdd) { final Routing routeService = routingServiceFactory.instantiateRoutingService(routingDef); routingServiceMap.put(vIface, routeService); final boolean succeeded = routeService.addRouteForCurrentService(); if (succeeded) { routeService.updateArpTableForCurrentService(); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDef, true, "added")); } else { LOG.warn("Route can not be created (by add): {}", routeService); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(routingDef, false, "route can not be created (by add)")); } } }); } RouteReactorImpl(final DataBroker dataBroker, final RoutingServiceFactory routingServiceFactory); }
RouteReactorImpl implements RouteReactor { @VisibleForTesting void processAdded(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesOnlyOnRight().forEach((vIface, routingDef) -> { final boolean readyToAdd; final Routing existingRouting = routingServiceMap.get(vIface); if (existingRouting != null) { LOG.info("Found unexpected route -> closing it: {}", existingRouting); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final boolean removalSucceded = existingRouting.removeRouteForCurrentService(); if (!removalSucceded) { LOG.warn("Route cannot be closed (cleaning before A): {}", existingRouting); RoutingDefinition oldDefinition = RouteUtil.extractRoutingDefinition(existingRouting); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(oldDefinition, false, "route can not be closed (by cleaning before add)")); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); readyToAdd = false; } else { readyToAdd = true; } } else { readyToAdd = true; } if (readyToAdd) { final Routing routeService = routingServiceFactory.instantiateRoutingService(routingDef); routingServiceMap.put(vIface, routeService); final boolean succeeded = routeService.addRouteForCurrentService(); if (succeeded) { routeService.updateArpTableForCurrentService(); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDef, true, "added")); } else { LOG.warn("Route can not be created (by add): {}", routeService); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(routingDef, false, "route can not be created (by add)")); } } }); } 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 processAdded(final MapDifference<IpAddress, RoutingDefinition> routingDifference, final List<RoutingDefinition> outcomingRouteDefinitions) { routingDifference.entriesOnlyOnRight().forEach((vIface, routingDef) -> { final boolean readyToAdd; final Routing existingRouting = routingServiceMap.get(vIface); if (existingRouting != null) { LOG.info("Found unexpected route -> closing it: {}", existingRouting); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::shutdown); final boolean removalSucceded = existingRouting.removeRouteForCurrentService(); if (!removalSucceded) { LOG.warn("Route cannot be closed (cleaning before A): {}", existingRouting); RoutingDefinition oldDefinition = RouteUtil.extractRoutingDefinition(existingRouting); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(oldDefinition, false, "route can not be closed (by cleaning before add)")); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); readyToAdd = false; } else { readyToAdd = true; } } else { readyToAdd = true; } if (readyToAdd) { final Routing routeService = routingServiceFactory.instantiateRoutingService(routingDef); routingServiceMap.put(vIface, routeService); final boolean succeeded = routeService.addRouteForCurrentService(); if (succeeded) { routeService.updateArpTableForCurrentService(); findSxpNodesOnVirtualIp(vIface).forEach(SxpNode::start); outcomingRouteDefinitions.add( RouteUtil.createOperationalRouteDefinition(routingDef, true, "added")); } else { LOG.warn("Route can not be created (by add): {}", routeService); outcomingRouteDefinitions.add(RouteUtil.createOperationalRouteDefinition(routingDef, false, "route can not be created (by add)")); } } }); } 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();  }