@Test public void testOnPortChainDeleted() { final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); final TenantId tenantId = TenantId.tenantId("1"); final String name = "PortChain"; final String description = "PortChain"; final List<PortPairGroupId> portPairGroupList = new LinkedList<PortPairGroupId>(); final List<FlowClassifierId> flowClassifierList = new LinkedList<FlowClassifierId>(); DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder(); DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); PortChain portChain = null; SfcService sfcService = new SfcManager(); PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); portPairGroupList.add(portPairGroupId); portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af"); portPairGroupList.add(portPairGroupId); FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); flowClassifierList.add(flowClassifierId); flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af"); flowClassifierList.add(flowClassifierId); portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name).setDescription(description) .setPortPairGroups(portPairGroupList).setFlowClassifiers(flowClassifierList).build(); }
@Override public void onPortChainDeleted(PortChain portChain) { log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI"); } int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId)); nshSpiPortChainMap.remove(portChain.portChainId()); nshSpiIdFreeList.add(nshSpiId); NshServicePathId nshSpi; LoadBalanceId id; List<LoadBalanceId> processedIdList = Lists.newArrayList(); Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys(); for (FiveTuple fiveTuple : fiveTupleSet) { id = portChain.getLoadBalanceId(fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); if (processedIdList.contains(id)) { flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi); continue; } else { processedIdList.add(id); } flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } List<PortPairGroupId> ppgIdlist = portChain.portPairGroups(); ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator(); while (ppgIdListIterator.hasNext()) { PortPairGroupId portPairGroupId = ppgIdListIterator.next(); PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId); ppg.resetLoad(); } }
SfcManager implements SfcService { @Override public void onPortChainDeleted(PortChain portChain) { log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI"); } int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId)); nshSpiPortChainMap.remove(portChain.portChainId()); nshSpiIdFreeList.add(nshSpiId); NshServicePathId nshSpi; LoadBalanceId id; List<LoadBalanceId> processedIdList = Lists.newArrayList(); Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys(); for (FiveTuple fiveTuple : fiveTupleSet) { id = portChain.getLoadBalanceId(fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); if (processedIdList.contains(id)) { flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi); continue; } else { processedIdList.add(id); } flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } List<PortPairGroupId> ppgIdlist = portChain.portPairGroups(); ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator(); while (ppgIdListIterator.hasNext()) { PortPairGroupId portPairGroupId = ppgIdListIterator.next(); PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId); ppg.resetLoad(); } } }
SfcManager implements SfcService { @Override public void onPortChainDeleted(PortChain portChain) { log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI"); } int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId)); nshSpiPortChainMap.remove(portChain.portChainId()); nshSpiIdFreeList.add(nshSpiId); NshServicePathId nshSpi; LoadBalanceId id; List<LoadBalanceId> processedIdList = Lists.newArrayList(); Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys(); for (FiveTuple fiveTuple : fiveTupleSet) { id = portChain.getLoadBalanceId(fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); if (processedIdList.contains(id)) { flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi); continue; } else { processedIdList.add(id); } flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } List<PortPairGroupId> ppgIdlist = portChain.portPairGroups(); ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator(); while (ppgIdListIterator.hasNext()) { PortPairGroupId portPairGroupId = ppgIdListIterator.next(); PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId); ppg.resetLoad(); } }  }
SfcManager implements SfcService { @Override public void onPortChainDeleted(PortChain portChain) { log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI"); } int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId)); nshSpiPortChainMap.remove(portChain.portChainId()); nshSpiIdFreeList.add(nshSpiId); NshServicePathId nshSpi; LoadBalanceId id; List<LoadBalanceId> processedIdList = Lists.newArrayList(); Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys(); for (FiveTuple fiveTuple : fiveTupleSet) { id = portChain.getLoadBalanceId(fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); if (processedIdList.contains(id)) { flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi); continue; } else { processedIdList.add(id); } flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } List<PortPairGroupId> ppgIdlist = portChain.portPairGroups(); ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator(); while (ppgIdListIterator.hasNext()) { PortPairGroupId portPairGroupId = ppgIdListIterator.next(); PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId); ppg.resetLoad(); } }  @Activate void activate(); @Deactivate void deactivate(); @Override void onPortPairCreated(PortPair portPair); @Override void onPortPairDeleted(PortPair portPair); @Override void onPortPairGroupCreated(PortPairGroup portPairGroup); @Override void onPortPairGroupDeleted(PortPairGroup portPairGroup); @Override void onFlowClassifierCreated(FlowClassifier flowClassifier); @Override void onFlowClassifierDeleted(FlowClassifier flowClassifier); @Override void onPortChainCreated(PortChain portChain); @Override void onPortChainDeleted(PortChain portChain); }
SfcManager implements SfcService { @Override public void onPortChainDeleted(PortChain portChain) { log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI"); } int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId)); nshSpiPortChainMap.remove(portChain.portChainId()); nshSpiIdFreeList.add(nshSpiId); NshServicePathId nshSpi; LoadBalanceId id; List<LoadBalanceId> processedIdList = Lists.newArrayList(); Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys(); for (FiveTuple fiveTuple : fiveTupleSet) { id = portChain.getLoadBalanceId(fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); if (processedIdList.contains(id)) { flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi); continue; } else { processedIdList.add(id); } flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } List<PortPairGroupId> ppgIdlist = portChain.portPairGroups(); ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator(); while (ppgIdListIterator.hasNext()) { PortPairGroupId portPairGroupId = ppgIdListIterator.next(); PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId); ppg.resetLoad(); } }  @Activate void activate(); @Deactivate void deactivate(); @Override void onPortPairCreated(PortPair portPair); @Override void onPortPairDeleted(PortPair portPair); @Override void onPortPairGroupCreated(PortPairGroup portPairGroup); @Override void onPortPairGroupDeleted(PortPairGroup portPairGroup); @Override void onFlowClassifierCreated(FlowClassifier flowClassifier); @Override void onFlowClassifierDeleted(FlowClassifier flowClassifier); @Override void onPortChainCreated(PortChain portChain); @Override void onPortChainDeleted(PortChain portChain);  }