SfcProviderRenderedPathAPI { public static RenderedServicePath createRenderedServicePathAndState(ServiceFunctionPath createdServiceFunctionPath, CreateRenderedPathInput createRenderedPathInput, SfcServiceFunctionSchedulerAPI scheduler) { RenderedServicePath renderedServicePath; boolean rspSuccessful = false; boolean addPathToSffStateSuccessful = false; boolean addPathToSfStateSuccessful = false; if (scheduler == null) { SfcProviderRenderedPathAPI.initDefaultServiceFunctionScheduler(); scheduler = defaultScheduler; } if ((renderedServicePath = SfcProviderRenderedPathAPI.createRenderedServicePathEntry(createdServiceFunctionPath, createRenderedPathInput, scheduler)) != null) { rspSuccessful = true; } else { LOG.error("Could not create RSP. System state inconsistent. Deleting and add SFP {} back", createdServiceFunctionPath.getName()); } if (rspSuccessful && SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(renderedServicePath)) { addPathToSffStateSuccessful = true; } else { if (renderedServicePath != null) { SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName()); } } if (addPathToSffStateSuccessful && SfcProviderServiceFunctionAPI.addPathToServiceFunctionState(renderedServicePath)) { addPathToSfStateSuccessful = true; } else { SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(createdServiceFunctionPath); if (renderedServicePath != null) { SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName()); } } if (!(addPathToSfStateSuccessful && SfcProviderServicePathAPI .addRenderedPathToServicePathState(createdServiceFunctionPath.getName(), renderedServicePath.getName()))) { SfcProviderServiceFunctionAPI .deleteServicePathFromServiceFunctionState(createdServiceFunctionPath.getName()); SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(createdServiceFunctionPath); if (renderedServicePath != null) { SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName()); } } if (renderedServicePath == null) { LOG.error("Failed to create RSP for SFP {}", createdServiceFunctionPath.getName()); } else { LOG.info("Create RSP {} for SFP {} successfully", renderedServicePath.getName(), createdServiceFunctionPath.getName()); } return renderedServicePath; }  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 testCreateRenderedServicePathAndState() { init(); ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME); assertNotNull("Must be not null", serviceFunctionPath); CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder(); createRenderedPathInputBuilder.setName(RSP_NAME.getValue()); SfcProviderRenderedPathAPI.createRenderedServicePathAndState(serviceFunctionPath, createRenderedPathInputBuilder.build()); List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(new SffName(SFF_NAMES.get(1))); assertNotNull("Must be not null", sffServicePathList); assertEquals(sffServicePathList.get(0).getName().getValue(), RSP_NAME.getValue()); List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState(new SfName("unittest-fw-1")); assertEquals(sfServicePathList.get(0).getName().getValue(), RSP_NAME.getValue()); List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathState(SFP_NAME); assertEquals(sfpRenderedServicePathList.get(0).getName(), RSP_NAME); }