@Test public void shouldBuildAvailableNetworkUsingSymmetricCostStrategy() throws RecoverableException { Flow flow = getFlow(false); Isl isl = getIsl(flow); when(config.getNetworkStrategy()).thenReturn("SYMMETRIC_COST"); when(islRepository.findSymmetricActiveWithAvailableBandwidth(flow.getBandwidth(), flow.getEncapsulationType())) .thenReturn(Collections.singletonList(isl)); AvailableNetwork availableNetwork = availableNetworkFactory.getAvailableNetwork(flow, Collections.emptyList()); assertAvailableNetworkIsCorrect(isl, availableNetwork); }
public AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources) throws RecoverableException { BuildStrategy buildStrategy = BuildStrategy.from(config.getNetworkStrategy()); AvailableNetwork network = new AvailableNetwork(); try { Collection<Isl> links = getAvailableIsls(buildStrategy, flow); links.forEach(network::addLink); if (!reusePathsResources.isEmpty() && !flow.isIgnoreBandwidth()) { reusePathsResources.forEach(pathId -> { Collection<Isl> flowLinks = islRepository.findActiveAndOccupiedByFlowPathWithAvailableBandwidth( pathId, flow.getBandwidth(), flow.getEncapsulationType()); flowLinks.forEach(network::addLink); }); } } catch (PersistenceException e) { throw new RecoverableException("An error from the database", e); } if (flow.getGroupId() != null) { log.info("Filling AvailableNetwork diverse weighs for group with id {}", flow.getGroupId()); Collection<PathId> flowPaths = flowPathRepository.findPathIdsByFlowGroupId(flow.getGroupId()); if (!reusePathsResources.isEmpty()) { flowPaths = flowPaths.stream() .filter(s -> !reusePathsResources.contains(s)) .collect(Collectors.toList()); } flowPaths.forEach(pathId -> flowPathRepository.findById(pathId) .ifPresent(flowPath -> { network.processDiversitySegments(flowPath.getSegments()); network.processDiversitySegmentsWithPop(flowPath.getSegments()); })); } return network; }
AvailableNetworkFactory { public AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources) throws RecoverableException { BuildStrategy buildStrategy = BuildStrategy.from(config.getNetworkStrategy()); AvailableNetwork network = new AvailableNetwork(); try { Collection<Isl> links = getAvailableIsls(buildStrategy, flow); links.forEach(network::addLink); if (!reusePathsResources.isEmpty() && !flow.isIgnoreBandwidth()) { reusePathsResources.forEach(pathId -> { Collection<Isl> flowLinks = islRepository.findActiveAndOccupiedByFlowPathWithAvailableBandwidth( pathId, flow.getBandwidth(), flow.getEncapsulationType()); flowLinks.forEach(network::addLink); }); } } catch (PersistenceException e) { throw new RecoverableException("An error from the database", e); } if (flow.getGroupId() != null) { log.info("Filling AvailableNetwork diverse weighs for group with id {}", flow.getGroupId()); Collection<PathId> flowPaths = flowPathRepository.findPathIdsByFlowGroupId(flow.getGroupId()); if (!reusePathsResources.isEmpty()) { flowPaths = flowPaths.stream() .filter(s -> !reusePathsResources.contains(s)) .collect(Collectors.toList()); } flowPaths.forEach(pathId -> flowPathRepository.findById(pathId) .ifPresent(flowPath -> { network.processDiversitySegments(flowPath.getSegments()); network.processDiversitySegmentsWithPop(flowPath.getSegments()); })); } return network; } }
AvailableNetworkFactory { public AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources) throws RecoverableException { BuildStrategy buildStrategy = BuildStrategy.from(config.getNetworkStrategy()); AvailableNetwork network = new AvailableNetwork(); try { Collection<Isl> links = getAvailableIsls(buildStrategy, flow); links.forEach(network::addLink); if (!reusePathsResources.isEmpty() && !flow.isIgnoreBandwidth()) { reusePathsResources.forEach(pathId -> { Collection<Isl> flowLinks = islRepository.findActiveAndOccupiedByFlowPathWithAvailableBandwidth( pathId, flow.getBandwidth(), flow.getEncapsulationType()); flowLinks.forEach(network::addLink); }); } } catch (PersistenceException e) { throw new RecoverableException("An error from the database", e); } if (flow.getGroupId() != null) { log.info("Filling AvailableNetwork diverse weighs for group with id {}", flow.getGroupId()); Collection<PathId> flowPaths = flowPathRepository.findPathIdsByFlowGroupId(flow.getGroupId()); if (!reusePathsResources.isEmpty()) { flowPaths = flowPaths.stream() .filter(s -> !reusePathsResources.contains(s)) .collect(Collectors.toList()); } flowPaths.forEach(pathId -> flowPathRepository.findById(pathId) .ifPresent(flowPath -> { network.processDiversitySegments(flowPath.getSegments()); network.processDiversitySegmentsWithPop(flowPath.getSegments()); })); } return network; } AvailableNetworkFactory(PathComputerConfig config, RepositoryFactory repositoryFactory); }
AvailableNetworkFactory { public AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources) throws RecoverableException { BuildStrategy buildStrategy = BuildStrategy.from(config.getNetworkStrategy()); AvailableNetwork network = new AvailableNetwork(); try { Collection<Isl> links = getAvailableIsls(buildStrategy, flow); links.forEach(network::addLink); if (!reusePathsResources.isEmpty() && !flow.isIgnoreBandwidth()) { reusePathsResources.forEach(pathId -> { Collection<Isl> flowLinks = islRepository.findActiveAndOccupiedByFlowPathWithAvailableBandwidth( pathId, flow.getBandwidth(), flow.getEncapsulationType()); flowLinks.forEach(network::addLink); }); } } catch (PersistenceException e) { throw new RecoverableException("An error from the database", e); } if (flow.getGroupId() != null) { log.info("Filling AvailableNetwork diverse weighs for group with id {}", flow.getGroupId()); Collection<PathId> flowPaths = flowPathRepository.findPathIdsByFlowGroupId(flow.getGroupId()); if (!reusePathsResources.isEmpty()) { flowPaths = flowPaths.stream() .filter(s -> !reusePathsResources.contains(s)) .collect(Collectors.toList()); } flowPaths.forEach(pathId -> flowPathRepository.findById(pathId) .ifPresent(flowPath -> { network.processDiversitySegments(flowPath.getSegments()); network.processDiversitySegmentsWithPop(flowPath.getSegments()); })); } return network; } AvailableNetworkFactory(PathComputerConfig config, RepositoryFactory repositoryFactory); AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources); }
AvailableNetworkFactory { public AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources) throws RecoverableException { BuildStrategy buildStrategy = BuildStrategy.from(config.getNetworkStrategy()); AvailableNetwork network = new AvailableNetwork(); try { Collection<Isl> links = getAvailableIsls(buildStrategy, flow); links.forEach(network::addLink); if (!reusePathsResources.isEmpty() && !flow.isIgnoreBandwidth()) { reusePathsResources.forEach(pathId -> { Collection<Isl> flowLinks = islRepository.findActiveAndOccupiedByFlowPathWithAvailableBandwidth( pathId, flow.getBandwidth(), flow.getEncapsulationType()); flowLinks.forEach(network::addLink); }); } } catch (PersistenceException e) { throw new RecoverableException("An error from the database", e); } if (flow.getGroupId() != null) { log.info("Filling AvailableNetwork diverse weighs for group with id {}", flow.getGroupId()); Collection<PathId> flowPaths = flowPathRepository.findPathIdsByFlowGroupId(flow.getGroupId()); if (!reusePathsResources.isEmpty()) { flowPaths = flowPaths.stream() .filter(s -> !reusePathsResources.contains(s)) .collect(Collectors.toList()); } flowPaths.forEach(pathId -> flowPathRepository.findById(pathId) .ifPresent(flowPath -> { network.processDiversitySegments(flowPath.getSegments()); network.processDiversitySegmentsWithPop(flowPath.getSegments()); })); } return network; } AvailableNetworkFactory(PathComputerConfig config, RepositoryFactory repositoryFactory); AvailableNetwork getAvailableNetwork(Flow flow, Collection<PathId> reusePathsResources);  }