@Test public void findNPathsByDefaultEncapsulationAndCost() throws SwitchNotFoundException, RecoverableException, UnroutableFlowException { kildaConfigurationRepository.find().ifPresent(config -> { config.setFlowEncapsulationType(VXLAN); }); List<PathsInfoData> paths = pathsService.getPaths(SWITCH_ID_1, SWITCH_ID_2, null, COST); assertVxlanAndCostPathes(paths); }
public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitchId)) { throw new IllegalArgumentException( String.format("Source and destination switch IDs are equal: '%s'", srcSwitchId)); } if (!switchRepository.exists(srcSwitchId)) { throw new SwitchNotFoundException(srcSwitchId); } if (!switchRepository.exists(dstSwitchId)) { throw new SwitchNotFoundException(dstSwitchId); } KildaConfiguration kildaConfiguration = kildaConfigurationRepository.getOrDefault(); FlowEncapsulationType flowEncapsulationType = Optional.ofNullable(requestEncapsulationType) .orElse(kildaConfiguration.getFlowEncapsulationType()); PathComputationStrategy pathComputationStrategy = Optional.ofNullable(requestPathComputationStrategy) .orElse(kildaConfiguration.getPathComputationStrategy()); List<Path> flowPaths = pathComputer.getNPaths(srcSwitchId, dstSwitchId, MAX_PATH_COUNT, flowEncapsulationType, pathComputationStrategy); return flowPaths.stream().map(PathMapper.INSTANCE::map) .map(path -> PathsInfoData.builder().path(path).build()) .collect(Collectors.toList()); }
PathsService { public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitchId)) { throw new IllegalArgumentException( String.format("Source and destination switch IDs are equal: '%s'", srcSwitchId)); } if (!switchRepository.exists(srcSwitchId)) { throw new SwitchNotFoundException(srcSwitchId); } if (!switchRepository.exists(dstSwitchId)) { throw new SwitchNotFoundException(dstSwitchId); } KildaConfiguration kildaConfiguration = kildaConfigurationRepository.getOrDefault(); FlowEncapsulationType flowEncapsulationType = Optional.ofNullable(requestEncapsulationType) .orElse(kildaConfiguration.getFlowEncapsulationType()); PathComputationStrategy pathComputationStrategy = Optional.ofNullable(requestPathComputationStrategy) .orElse(kildaConfiguration.getPathComputationStrategy()); List<Path> flowPaths = pathComputer.getNPaths(srcSwitchId, dstSwitchId, MAX_PATH_COUNT, flowEncapsulationType, pathComputationStrategy); return flowPaths.stream().map(PathMapper.INSTANCE::map) .map(path -> PathsInfoData.builder().path(path).build()) .collect(Collectors.toList()); } }
PathsService { public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitchId)) { throw new IllegalArgumentException( String.format("Source and destination switch IDs are equal: '%s'", srcSwitchId)); } if (!switchRepository.exists(srcSwitchId)) { throw new SwitchNotFoundException(srcSwitchId); } if (!switchRepository.exists(dstSwitchId)) { throw new SwitchNotFoundException(dstSwitchId); } KildaConfiguration kildaConfiguration = kildaConfigurationRepository.getOrDefault(); FlowEncapsulationType flowEncapsulationType = Optional.ofNullable(requestEncapsulationType) .orElse(kildaConfiguration.getFlowEncapsulationType()); PathComputationStrategy pathComputationStrategy = Optional.ofNullable(requestPathComputationStrategy) .orElse(kildaConfiguration.getPathComputationStrategy()); List<Path> flowPaths = pathComputer.getNPaths(srcSwitchId, dstSwitchId, MAX_PATH_COUNT, flowEncapsulationType, pathComputationStrategy); return flowPaths.stream().map(PathMapper.INSTANCE::map) .map(path -> PathsInfoData.builder().path(path).build()) .collect(Collectors.toList()); } PathsService(RepositoryFactory repositoryFactory, PathComputerConfig pathComputerConfig); }
PathsService { public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitchId)) { throw new IllegalArgumentException( String.format("Source and destination switch IDs are equal: '%s'", srcSwitchId)); } if (!switchRepository.exists(srcSwitchId)) { throw new SwitchNotFoundException(srcSwitchId); } if (!switchRepository.exists(dstSwitchId)) { throw new SwitchNotFoundException(dstSwitchId); } KildaConfiguration kildaConfiguration = kildaConfigurationRepository.getOrDefault(); FlowEncapsulationType flowEncapsulationType = Optional.ofNullable(requestEncapsulationType) .orElse(kildaConfiguration.getFlowEncapsulationType()); PathComputationStrategy pathComputationStrategy = Optional.ofNullable(requestPathComputationStrategy) .orElse(kildaConfiguration.getPathComputationStrategy()); List<Path> flowPaths = pathComputer.getNPaths(srcSwitchId, dstSwitchId, MAX_PATH_COUNT, flowEncapsulationType, pathComputationStrategy); return flowPaths.stream().map(PathMapper.INSTANCE::map) .map(path -> PathsInfoData.builder().path(path).build()) .collect(Collectors.toList()); } PathsService(RepositoryFactory repositoryFactory, PathComputerConfig pathComputerConfig); List<PathsInfoData> getPaths(
            SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType,
            PathComputationStrategy requestPathComputationStrategy); }
PathsService { public List<PathsInfoData> getPaths( SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType, PathComputationStrategy requestPathComputationStrategy) throws RecoverableException, SwitchNotFoundException, UnroutableFlowException { if (Objects.equals(srcSwitchId, dstSwitchId)) { throw new IllegalArgumentException( String.format("Source and destination switch IDs are equal: '%s'", srcSwitchId)); } if (!switchRepository.exists(srcSwitchId)) { throw new SwitchNotFoundException(srcSwitchId); } if (!switchRepository.exists(dstSwitchId)) { throw new SwitchNotFoundException(dstSwitchId); } KildaConfiguration kildaConfiguration = kildaConfigurationRepository.getOrDefault(); FlowEncapsulationType flowEncapsulationType = Optional.ofNullable(requestEncapsulationType) .orElse(kildaConfiguration.getFlowEncapsulationType()); PathComputationStrategy pathComputationStrategy = Optional.ofNullable(requestPathComputationStrategy) .orElse(kildaConfiguration.getPathComputationStrategy()); List<Path> flowPaths = pathComputer.getNPaths(srcSwitchId, dstSwitchId, MAX_PATH_COUNT, flowEncapsulationType, pathComputationStrategy); return flowPaths.stream().map(PathMapper.INSTANCE::map) .map(path -> PathsInfoData.builder().path(path).build()) .collect(Collectors.toList()); } PathsService(RepositoryFactory repositoryFactory, PathComputerConfig pathComputerConfig); List<PathsInfoData> getPaths(
            SwitchId srcSwitchId, SwitchId dstSwitchId, FlowEncapsulationType requestEncapsulationType,
            PathComputationStrategy requestPathComputationStrategy); static final int MAX_PATH_COUNT; }