@Test public void loadBalance__OverrideAllHops() { Long pathId = 1L; ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder(); serviceFunctionPathBuilder.setKey(new ServiceFunctionPathKey(new SfpName("key"))); serviceFunctionPathBuilder.setPathId(pathId); serviceFunctionPathBuilder.setServiceChainName(sfChain.getName()); List<ServicePathHop> sphs = new ArrayList<>(); sphs.add(buildSFHop(new SffName("SFF2"), new SfName("hop-dpi-0"), (short) 0)); sphs.add(buildSFHop(new SffName("SFF2"), new SfName("hop-dpi-1"), (short) 1)); serviceFunctionPathBuilder.setServicePathHop(sphs); ServiceFunctionPath sfp = serviceFunctionPathBuilder.build(); List<SfName> serviceFunctionNameArrayList = scheduler.scheduleServiceFunctions(sfChain, 1, sfp); LOG.debug("{} => {}", serviceFunctionNameArrayList.get(0).getValue(),serviceFunctionNameArrayList.get(1).getValue()); assertEquals("hop-dpi-0", serviceFunctionNameArrayList.get(0).getValue()); assertEquals("hop-dpi-1", serviceFunctionNameArrayList.get(1).getValue()); }
@Override public List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex, ServiceFunctionPath sfp) { SfName preSfName = null; SfName sfName; List<SfName> sfNameList = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); sfcServiceFunctionList.addAll(chain.getSfcServiceFunction()); SfcProviderGraph sfcProviderGraph = new SfcProviderGraph(); short index = 0; Map<Short, SfName> sfpMapping = getSFPHopSfMapping(sfp); buildTopologyGraph(sfcProviderGraph); for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) { LOG.debug("ServiceFunction name: {}", sfcServiceFunction.getName()); SfName hopSf = sfpMapping.get(index++); if (hopSf != null) { sfNameList.add(hopSf); continue; } ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType()); if (serviceFunctionType != null) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); if (!sftServiceFunctionNameList.isEmpty()) { sfName = getServiceFunctionByType(serviceFunctionType, preSfName, sfcProviderGraph); if (sfName != null) { sfNameList.add(sfName); preSfName = sfName; LOG.debug("Next Service Function: {}", sfName); } else { LOG.error("Couldn't find a reachable SF for ServiceFunctionType: {}", sfcServiceFunction.getType()); return null; } } else { LOG.debug("No {} Service Function instance", sfcServiceFunction.getName()); return null; } } else { LOG.debug("No {} Service Function type", sfcServiceFunction.getName()); return null; } } return sfNameList; }
SfcServiceFunctionLoadPathAwareSchedulerAPI extends SfcServiceFunctionSchedulerAPI { @Override public List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex, ServiceFunctionPath sfp) { SfName preSfName = null; SfName sfName; List<SfName> sfNameList = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); sfcServiceFunctionList.addAll(chain.getSfcServiceFunction()); SfcProviderGraph sfcProviderGraph = new SfcProviderGraph(); short index = 0; Map<Short, SfName> sfpMapping = getSFPHopSfMapping(sfp); buildTopologyGraph(sfcProviderGraph); for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) { LOG.debug("ServiceFunction name: {}", sfcServiceFunction.getName()); SfName hopSf = sfpMapping.get(index++); if (hopSf != null) { sfNameList.add(hopSf); continue; } ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType()); if (serviceFunctionType != null) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); if (!sftServiceFunctionNameList.isEmpty()) { sfName = getServiceFunctionByType(serviceFunctionType, preSfName, sfcProviderGraph); if (sfName != null) { sfNameList.add(sfName); preSfName = sfName; LOG.debug("Next Service Function: {}", sfName); } else { LOG.error("Couldn't find a reachable SF for ServiceFunctionType: {}", sfcServiceFunction.getType()); return null; } } else { LOG.debug("No {} Service Function instance", sfcServiceFunction.getName()); return null; } } else { LOG.debug("No {} Service Function type", sfcServiceFunction.getName()); return null; } } return sfNameList; } }
SfcServiceFunctionLoadPathAwareSchedulerAPI extends SfcServiceFunctionSchedulerAPI { @Override public List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex, ServiceFunctionPath sfp) { SfName preSfName = null; SfName sfName; List<SfName> sfNameList = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); sfcServiceFunctionList.addAll(chain.getSfcServiceFunction()); SfcProviderGraph sfcProviderGraph = new SfcProviderGraph(); short index = 0; Map<Short, SfName> sfpMapping = getSFPHopSfMapping(sfp); buildTopologyGraph(sfcProviderGraph); for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) { LOG.debug("ServiceFunction name: {}", sfcServiceFunction.getName()); SfName hopSf = sfpMapping.get(index++); if (hopSf != null) { sfNameList.add(hopSf); continue; } ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType()); if (serviceFunctionType != null) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); if (!sftServiceFunctionNameList.isEmpty()) { sfName = getServiceFunctionByType(serviceFunctionType, preSfName, sfcProviderGraph); if (sfName != null) { sfNameList.add(sfName); preSfName = sfName; LOG.debug("Next Service Function: {}", sfName); } else { LOG.error("Couldn't find a reachable SF for ServiceFunctionType: {}", sfcServiceFunction.getType()); return null; } } else { LOG.debug("No {} Service Function instance", sfcServiceFunction.getName()); return null; } } else { LOG.debug("No {} Service Function type", sfcServiceFunction.getName()); return null; } } return sfNameList; } SfcServiceFunctionLoadPathAwareSchedulerAPI(); }
SfcServiceFunctionLoadPathAwareSchedulerAPI extends SfcServiceFunctionSchedulerAPI { @Override public List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex, ServiceFunctionPath sfp) { SfName preSfName = null; SfName sfName; List<SfName> sfNameList = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); sfcServiceFunctionList.addAll(chain.getSfcServiceFunction()); SfcProviderGraph sfcProviderGraph = new SfcProviderGraph(); short index = 0; Map<Short, SfName> sfpMapping = getSFPHopSfMapping(sfp); buildTopologyGraph(sfcProviderGraph); for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) { LOG.debug("ServiceFunction name: {}", sfcServiceFunction.getName()); SfName hopSf = sfpMapping.get(index++); if (hopSf != null) { sfNameList.add(hopSf); continue; } ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType()); if (serviceFunctionType != null) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); if (!sftServiceFunctionNameList.isEmpty()) { sfName = getServiceFunctionByType(serviceFunctionType, preSfName, sfcProviderGraph); if (sfName != null) { sfNameList.add(sfName); preSfName = sfName; LOG.debug("Next Service Function: {}", sfName); } else { LOG.error("Couldn't find a reachable SF for ServiceFunctionType: {}", sfcServiceFunction.getType()); return null; } } else { LOG.debug("No {} Service Function instance", sfcServiceFunction.getName()); return null; } } else { LOG.debug("No {} Service Function type", sfcServiceFunction.getName()); return null; } } return sfNameList; } SfcServiceFunctionLoadPathAwareSchedulerAPI(); @Override List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex,
            ServiceFunctionPath sfp); }
SfcServiceFunctionLoadPathAwareSchedulerAPI extends SfcServiceFunctionSchedulerAPI { @Override public List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex, ServiceFunctionPath sfp) { SfName preSfName = null; SfName sfName; List<SfName> sfNameList = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); sfcServiceFunctionList.addAll(chain.getSfcServiceFunction()); SfcProviderGraph sfcProviderGraph = new SfcProviderGraph(); short index = 0; Map<Short, SfName> sfpMapping = getSFPHopSfMapping(sfp); buildTopologyGraph(sfcProviderGraph); for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) { LOG.debug("ServiceFunction name: {}", sfcServiceFunction.getName()); SfName hopSf = sfpMapping.get(index++); if (hopSf != null) { sfNameList.add(hopSf); continue; } ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType()); if (serviceFunctionType != null) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); if (!sftServiceFunctionNameList.isEmpty()) { sfName = getServiceFunctionByType(serviceFunctionType, preSfName, sfcProviderGraph); if (sfName != null) { sfNameList.add(sfName); preSfName = sfName; LOG.debug("Next Service Function: {}", sfName); } else { LOG.error("Couldn't find a reachable SF for ServiceFunctionType: {}", sfcServiceFunction.getType()); return null; } } else { LOG.debug("No {} Service Function instance", sfcServiceFunction.getName()); return null; } } else { LOG.debug("No {} Service Function type", sfcServiceFunction.getName()); return null; } } return sfNameList; } SfcServiceFunctionLoadPathAwareSchedulerAPI(); @Override List<SfName> scheduleServiceFunctions(ServiceFunctionChain chain, int serviceIndex,
            ServiceFunctionPath sfp);  }