@Test public void testOnPortChainCreated() { 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 onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } }
SfcManager implements SfcService { @Override public void onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } } }
SfcManager implements SfcService { @Override public void onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } }  }
SfcManager implements SfcService { @Override public void onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } }  @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 onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } }  @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);  }