SfcProviderRenderedPathAPI { public static RenderedServicePathFirstHop readRspFirstHopBySftList( Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerType, List<SftTypeName> serviceFunctionTypeList) { int i; String serviceTypeName; ServiceFunctionType serviceFunctionType = null; List<SfcServiceFunction> sfcServiceFunctionArrayList = new ArrayList<>(); SfcName sfcName = new SfcName("chain-sfc-gbp"); SfpName pathName = new SfpName("path-sfc-gbp"); ServiceFunctionChain serviceFunctionChain; boolean ret; RenderedServicePathFirstHop firstHop; SfcServiceFunctionSchedulerAPI scheduler; printTraceStart(LOG); scheduler = getServiceFunctionScheduler(serviceFunctionSchedulerType); for (i = 0; i < serviceFunctionTypeList.size(); i++) { serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(serviceFunctionTypeList.get(i)); serviceTypeName = serviceFunctionType.getType().getValue(); if (serviceTypeName == null) { LOG.error("Unknown ServiceFunctionType: {}", serviceFunctionType.getType()); return null; } sfcName = new SfcName(sfcName.getValue() + "-" + serviceTypeName); pathName = new SfpName(pathName.getValue() + "-" + serviceTypeName); SfcServiceFunctionBuilder sfcServiceFunctionBuilder = new SfcServiceFunctionBuilder(); sfcServiceFunctionArrayList.add(sfcServiceFunctionBuilder.setName(serviceTypeName + "-gbp-sfc") .setType(serviceFunctionType.getType()) .build()); } serviceFunctionChain = SfcProviderServiceChainAPI.readServiceFunctionChain(sfcName); if (serviceFunctionChain == null) { ServiceFunctionChainBuilder sfcBuilder = new ServiceFunctionChainBuilder(); sfcBuilder.setName(sfcName).setSfcServiceFunction(sfcServiceFunctionArrayList); serviceFunctionChain = sfcBuilder.build(); ret = SfcProviderServiceChainAPI.putServiceFunctionChain(serviceFunctionChain); if (!ret) { LOG.error("Failed to create ServiceFunctionChain: {}", sfcName); return null; } } ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(pathName); if (serviceFunctionPath == null) { ServiceFunctionPathBuilder sfpBuilder = new ServiceFunctionPathBuilder(); sfpBuilder.setName(pathName).setServiceChainName(sfcName); serviceFunctionPath = sfpBuilder.build(); ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath); if (!ret) { LOG.error("Failed to create ServiceFunctionPath: {}", pathName); return null; } } RenderedServicePath renderedServicePath; RenderedServicePath revRenderedServicePath; CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder(); renderedServicePath = SfcProviderRenderedPathAPI.createRenderedServicePathAndState(serviceFunctionPath, createRenderedPathInputBuilder.build(), scheduler); if (renderedServicePath == null) { LOG.error("Failed to create RenderedServicePath for ServiceFunctionPath: {}", pathName); return null; } if (isChainSymmetric(serviceFunctionPath, renderedServicePath)) { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); if (revRenderedServicePath == null) { LOG.error("Failed to create symmetric RenderedServicePath for ServiceFunctionPath: {}", pathName); } SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId()); } firstHop = SfcProviderRenderedPathAPI.readRenderedServicePathFirstHop(renderedServicePath.getName()); printTraceStop(LOG); return firstHop; }  static RenderedServicePath createRenderedServicePathAndState(ServiceFunctionPath createdServiceFunctionPath,
            CreateRenderedPathInput createRenderedPathInput, SfcServiceFunctionSchedulerAPI scheduler); static RenderedServicePath createRenderedServicePathAndState(ServiceFunctionPath createdServiceFunctionPath,
            CreateRenderedPathInput createRenderedPathInput); static RenderedServicePath createSymmetricRenderedServicePathAndState(
            RenderedServicePath renderedServicePath); static RenderedServicePath createReverseRenderedServicePathEntry(RenderedServicePath renderedServicePath); static RspName generateReversedPathName(RspName rspName); static RspName getReversedRspName(RspName rspName); static RenderedServicePath readRenderedServicePath(RspName rspName); static boolean deleteRenderedServicePaths(List<RspName> servicePaths); static boolean deleteRenderedServicePathsAndStates(List<RspName> rspNames); static boolean deleteRenderedServicePath(RspName renderedServicePathName); static RenderedServicePathFirstHop readRenderedServicePathFirstHop(RspName rspName); static RenderedServicePathFirstHop readRspFirstHopBySftList(
            Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerType,
            List<SftTypeName> serviceFunctionTypeList); static boolean setSymmetricPathId(RenderedServicePath renderedServicePath, long pathId); static boolean isChainSymmetric(ServiceFunctionPath sfp, RenderedServicePath rsp); static String createRenderedIoamPath(String sysName); static boolean deleteRenderedIoamPath(String renderedIoamPathName);  }
@Test public void testReadRspFirstHopBySftList() { init(); RenderedServicePathFirstHop firstHop = null; try { firstHop = SfcProviderRenderedPathAPI.readRspFirstHopBySftList(null, sfTypes); } catch (NullPointerException e) { e.printStackTrace(); } assertNotNull("Must be not null", firstHop); assertNull("Symmetric Path must not be created", firstHop.getSymmetricPathId()); LOG.debug("First hop IP: {}, port: {}", firstHop.getIp().toString(), firstHop.getPort()); assertEquals("Must be equal", firstHop.getIp(), new IpAddress(new Ipv4Address(SFF_LOCATOR_IP.get(0)))); assertEquals("Must be equal", firstHop.getPort(), new PortNumber(PORT.get(0))); }
@Test public void testReadRspFirstHopBySftList_SymmetricRsp() { initWithTypes(true); RenderedServicePathFirstHop firstHop = null; try { firstHop = SfcProviderRenderedPathAPI.readRspFirstHopBySftList(null, sfTypes); } catch (NullPointerException e) { e.printStackTrace(); } assertNotNull("Must not be null", firstHop); assertNotNull("Symmetric Path must be created", firstHop.getSymmetricPathId()); }