SfcOfRspProcessor { public void processRenderedServicePath(RenderedServicePath rsp) { try { sfcSynchronizer.lock(); sfcOfProviderUtils.addRsp(rsp.getPathId()); SffGraph sffGraph = populateSffGraph(rsp); SfcRspTransportProcessorBase transportProcessor = getTransportProcessor(sffGraph, rsp); transportProcessor.processSffDpls(); transportProcessor.setRspTransports(); SffGraph.SffGraphEntry entry = null; Iterator<SffGraph.SffGraphEntry> sffGraphIter = sffGraph.getGraphEntryIterator(); sfcOfFlowProgrammer.setTableIndexMapper( transportProcessor.getTableIndexMapper().isPresent() ? transportProcessor.getTableIndexMapper().get() : null); while (sffGraphIter.hasNext()) { entry = sffGraphIter.next(); LOG.debug("build flows of entry: {}", entry); sfcOfFlowProgrammer.setFlowRspId(OpenflowConstants.SFC_FLOWS); initializeSff(entry, transportProcessor); sfcOfFlowProgrammer.setFlowRspId(rsp.getPathId()); configureTransportIngressFlows(entry, sffGraph, transportProcessor); configurePathMapperFlows(entry, sffGraph, transportProcessor); configureNextHopFlows(entry, sffGraph, transportProcessor); configureTransportEgressFlows(entry, sffGraph, transportProcessor); } this.sfcOfFlowProgrammer.flushFlows(); transportProcessor.updateOperationalDSInfo(sffGraph, rsp); LOG.info("Processing complete for RSP: name [{}] Id [{}]", rsp.getName(), rsp.getPathId()); } catch (SfcRenderingException e) { LOG.error("SfcRenderingException in processRenderedServicePath: ", e.getMessage(), e); } finally { this.sfcOfFlowProgrammer.purgeFlows(); sfcSynchronizer.unlock(); sfcOfProviderUtils.removeRsp(rsp.getPathId()); } } SfcOfRspProcessor(
            SfcOfFlowProgrammerInterface sfcOfFlowProgrammer,
            SfcOfBaseProviderUtils sfcOfProviderUtils,
            SfcSynchronizer sfcSynchronizer,
            RpcProviderRegistry rpcProviderRegistry,
            DataBroker dataBroker); void processRenderedServicePath(RenderedServicePath rsp); void deleteRenderedServicePath(RenderedServicePath rsp); SfcRspTransportProcessorBase getTransportProcessor(SffGraph sffGraph, RenderedServicePath rsp);  }
@Test public void testVlanFlowCreation() { LOG.info("SfcOfRspProcessorTest testVlanFlowCreation"); RenderedServicePath vlanRsp = rspBuilder.createRspFromSfTypes(this.sfTypes, Mac.class, Transport.class); this.sfcOfRspProcessor.processRenderedServicePath(vlanRsp); assertMatchAnyMethodsCalled("SFF_0"); assertMatchAnyMethodsCalled("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).setTableIndexMapper(anyObject()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowRspId(anyLong()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowWriter((SfcOfFlowWriterInterface) anyObject()); verify(this.flowProgrammerTestMoc, times(2)).configureVlanTransportIngressFlow("SFF_0"); verify(this.flowProgrammerTestMoc, times(2)).configureVlanTransportIngressFlow("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow(eq("SFF_0"), anyInt(), eq((long) 0), eq(false)); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow(eq("SFF_1"), anyInt(), eq((long) 0), eq(false)); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow("SFF_0", 2, 0, true); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow("SFF_1", 3, 0, true); verify(this.flowProgrammerTestMoc, times(1)).configureMacNextHopFlow("SFF_0", 0, null, "00:00:00:00:00:00"); verify(this.flowProgrammerTestMoc, times(1)).configureMacNextHopFlow("SFF_0", 0, "00:00:00:00:00:00", "00:00:00:00:00:07"); verify(this.flowProgrammerTestMoc, times(1)).configureMacNextHopFlow("SFF_1", 0, "00:00:00:00:00:04", "00:00:00:00:00:05"); verify(this.flowProgrammerTestMoc, times(2)).configureMacNextHopFlow("SFF_1", 0, "00:00:00:00:00:05", null); verify(this.flowProgrammerTestMoc, times(1)).configureVlanTransportEgressFlow( eq("SFF_0"), eq("00:00:00:00:00:04"), eq("00:00:00:00:00:07"), anyInt(), eq("1"), eq((long) 0)); verify(this.flowProgrammerTestMoc, times(1)).configureVlanLastHopTransportEgressFlow( eq("SFF_1"), eq("00:00:00:00:00:09"), eq((String) null), anyInt(), eq("1"), eq((long) 0)); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow( "SFF_0", "00:00:00:00:00:02", "00:00:00:00:00:00", 2, "1", 0, false); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow( "SFF_1", "00:00:00:00:00:07", "00:00:00:00:00:05", 3, "1", 0, false); verify(this.flowProgrammerTestMoc).flushFlows(); verify(this.flowProgrammerTestMoc).purgeFlows(); verifyNoMoreInteractions(this.flowProgrammerTestMoc); }
@Test public void testMplsFlowCreation() { LOG.info("SfcOfRspProcessorTest testMplsFlowCreation"); RenderedServicePath mplsRsp = rspBuilder.createRspFromSfTypes(this.sfTypes, Mpls.class, Transport.class); this.sfcOfRspProcessor.processRenderedServicePath(mplsRsp); assertMatchAnyMethodsCalled("SFF_0"); assertMatchAnyMethodsCalled("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).setTableIndexMapper(anyObject()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowRspId(anyLong()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowWriter((SfcOfFlowWriterInterface) anyObject()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanTransportIngressFlow("SFF_0"); verify(this.flowProgrammerTestMoc, times(1)).configureVlanTransportIngressFlow("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).configureMplsTransportIngressFlow("SFF_0"); verify(this.flowProgrammerTestMoc, times(1)).configureMplsTransportIngressFlow("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow(eq("SFF_0"), anyInt(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanPathMapperFlow(eq("SFF_1"), anyInt(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(1)).configureMplsPathMapperFlow(eq("SFF_0"), anyLong(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(1)).configureMplsPathMapperFlow(eq("SFF_1"), anyLong(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(2)).configureMacNextHopFlow(eq("SFF_0"), anyLong(), anyString(), anyString()); verify(this.flowProgrammerTestMoc, times(3)).configureMacNextHopFlow(eq("SFF_1"), anyLong(), anyString(), anyString()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow(eq("SFF_0"), anyString(), anyString(), anyInt(), anyString(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow(eq("SFF_1"), anyString(), anyString(), anyInt(), anyString(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(1)).configureMplsTransportEgressFlow(eq("SFF_0"), anyString(), anyString(), anyLong(), anyString(), anyLong()); verify(this.flowProgrammerTestMoc, times(1)).configureMplsLastHopTransportEgressFlow(eq("SFF_1"), anyString(), anyString(), anyLong(), anyString(), anyLong()); verify(this.flowProgrammerTestMoc).flushFlows(); verify(this.flowProgrammerTestMoc).purgeFlows(); verifyNoMoreInteractions(this.flowProgrammerTestMoc); }
@Test public void testNshFlowCreation() { LOG.info("SfcOfRspProcessorTest testNshFlowCreation"); RenderedServicePath nshRsp = rspBuilder.createRspFromSfTypes(this.sfTypes, VxlanGpe.class, Nsh.class); this.sfcOfRspProcessor.processRenderedServicePath(nshRsp); assertMatchAnyMethodsCalled("SFF_0"); assertMatchAnyMethodsCalled("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).setTableIndexMapper(anyObject()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowRspId(anyLong()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowWriter((SfcOfFlowWriterInterface) anyObject()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeTransportIngressFlow(eq("SFF_0"), anyLong(), anyShort()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeTransportIngressFlow(eq("SFF_1"), anyLong(), anyShort()); verify(this.flowProgrammerTestMoc, times(2)).configureNshVxgpeNextHopFlow( eq("SFF_0"), anyString(), anyLong(), anyShort()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeNextHopFlow( eq("SFF_1"), anyString(), anyLong(), anyShort()); verify(this.flowProgrammerTestMoc, times(2)).configureNshVxgpeTransportEgressFlow( eq("SFF_0"), anyLong(), anyShort(), anyString()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeLastHopTransportEgressFlow( eq("SFF_1"), anyLong(), anyShort(), anyString()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeTransportEgressFlow( eq("SFF_1"), anyLong(), anyShort(), anyString()); verify(this.flowProgrammerTestMoc).configureNshNscTransportEgressFlow( "SFF_1", 0, (short) 253, "INPORT"); verify(this.flowProgrammerTestMoc).configureNshNscTransportEgressFlow( eq("SFF_1"), anyLong(), anyShort(), anyString()); verify(this.flowProgrammerTestMoc).configureNshVxgpeAppCoexistTransportEgressFlow( eq("SFF_1"), anyLong(), anyShort(), anyString()); verify(this.flowProgrammerTestMoc).flushFlows(); verify(this.flowProgrammerTestMoc).purgeFlows(); verifyNoMoreInteractions(this.flowProgrammerTestMoc); }
@Test public void testNshOneHopFlowCreation() { LOG.info("SfcOfRspProcessorTest testNshOneHopFlowCreation"); List<SftTypeName> sfOneHopTypes; sfOneHopTypes = new ArrayList<>(); sfOneHopTypes.add(new SftTypeName("firewall")); RenderedServicePath nshRsp = rspBuilder.createRspFromSfTypes(sfOneHopTypes, VxlanGpe.class, Nsh.class); this.sfcOfRspProcessor.processRenderedServicePath(nshRsp); assertMatchAnyMethodsCalled("SFF_0"); verify(this.flowProgrammerTestMoc, times(1)).setTableIndexMapper(anyObject()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowRspId(anyLong()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowWriter((SfcOfFlowWriterInterface) anyObject()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeTransportIngressFlow(eq("SFF_0"), anyLong(), anyShort()); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeNextHopFlow( "SFF_0", "192.168.0.1", 0, (short) 255); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeLastHopTransportEgressFlow( "SFF_0", 0, (short) 254, "INPORT"); verify(this.flowProgrammerTestMoc, times(1)).configureNshVxgpeTransportEgressFlow( "SFF_0", 0, (short) 255, "INPORT"); verify(this.flowProgrammerTestMoc).configureNshNscTransportEgressFlow( "SFF_0", 0, (short) 254, "INPORT"); verify(this.flowProgrammerTestMoc).configureNshVxgpeAppCoexistTransportEgressFlow( "SFF_0", 0, (short) 254, "192.168.0.2"); verify(this.flowProgrammerTestMoc).flushFlows(); verify(this.flowProgrammerTestMoc).purgeFlows(); verifyNoMoreInteractions(this.flowProgrammerTestMoc); }
@Test public void testVlanTcpProxyFlowCreation() { LOG.info("SfcOfRspProcessorTest testVlanTcpProxyFlowCreation"); List<SftTypeName> sfTcpProxyTypes; sfTcpProxyTypes = new ArrayList<>(); sfTcpProxyTypes.add(new SftTypeName("tcp-proxy")); sfTcpProxyTypes.add(new SftTypeName("tcp-proxy")); RenderedServicePath vlanRsp = rspBuilder.createRspFromSfTypes(sfTcpProxyTypes, Mac.class, Transport.class); this.sfcOfRspProcessor.processRenderedServicePath(vlanRsp); assertMatchAnyMethodsCalled("SFF_0"); assertMatchAnyMethodsCalled("SFF_1"); verify(this.flowProgrammerTestMoc, times(1)).setTableIndexMapper(anyObject()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowRspId(anyLong()); verify(this.flowProgrammerTestMoc, atLeastOnce()).setFlowWriter((SfcOfFlowWriterInterface) anyObject()); verify(this.flowProgrammerTestMoc, times(2)).configureVlanTransportIngressFlow(eq("SFF_0")); verify(this.flowProgrammerTestMoc, times(2)).configureVlanTransportIngressFlow(eq("SFF_1")); verify(this.flowProgrammerTestMoc, times(1)).configureArpTransportIngressFlow(eq("SFF_0"), anyString()); verify(this.flowProgrammerTestMoc, times(1)).configureArpTransportIngressFlow(eq("SFF_1"), anyString()); verify(this.flowProgrammerTestMoc, times(2)).configureVlanPathMapperFlow(eq("SFF_0"), anyInt(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(2)).configureVlanPathMapperFlow(eq("SFF_1"), anyInt(), anyLong(), anyBoolean()); verify(this.flowProgrammerTestMoc, times(2)).configureMacNextHopFlow(eq("SFF_0"), anyLong(), anyString(), anyString()); verify(this.flowProgrammerTestMoc, times(3)).configureMacNextHopFlow(eq("SFF_1"), anyLong(), anyString(), anyString()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanTransportEgressFlow( eq("SFF_0"), anyString(), anyString(), anyInt(), anyString(), anyLong()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanLastHopTransportEgressFlow( eq("SFF_1"), anyString(), anyString(), anyInt(), anyString(), anyLong()); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow( eq("SFF_0"), anyString(), anyString(), anyInt(), anyString(), anyLong(), eq(true)); verify(this.flowProgrammerTestMoc, times(1)).configureVlanSfTransportEgressFlow( eq("SFF_1"), anyString(), anyString(), anyInt(), anyString(), anyLong(), eq(true)); verify(this.flowProgrammerTestMoc).flushFlows(); verify(this.flowProgrammerTestMoc).purgeFlows(); verifyNoMoreInteractions(this.flowProgrammerTestMoc); }