SfcProviderRenderedPathAPI { public static RenderedServicePathFirstHop readRenderedServicePathFirstHop(RspName rspName) { final String FUNCTION = "function"; final String IP = "ip"; final String LISP = "lisp"; final String MAC = "mac"; final String MPLS = "mpls"; RenderedServicePathFirstHop renderedServicePathFirstHop = null; RenderedServicePath renderedServicePath = readRenderedServicePath(rspName); if (renderedServicePath != null) { RenderedServicePathFirstHopBuilder renderedServicePathFirstHopBuilder = new RenderedServicePathFirstHopBuilder(); renderedServicePathFirstHopBuilder.setPathId(renderedServicePath.getPathId()) .setStartingIndex(renderedServicePath.getStartingIndex()) .setSymmetricPathId(renderedServicePath.getSymmetricPathId()); List<RenderedServicePathHop> renderedServicePathHopList = renderedServicePath.getRenderedServicePathHop(); RenderedServicePathHop renderedServicePathHop = renderedServicePathHopList.get(0); SffName sffName = renderedServicePathHop.getServiceFunctionForwarder(); SffDataPlaneLocatorName sffLocatorName = renderedServicePathHop.getServiceFunctionForwarderLocator(); if (sffLocatorName == null) { return renderedServicePathFirstHopBuilder.build(); } SffDataPlaneLocator sffDataPlaneLocator = SfcProviderServiceForwarderAPI .readServiceFunctionForwarderDataPlaneLocator(sffName, sffLocatorName); if (sffDataPlaneLocator != null && sffDataPlaneLocator.getDataPlaneLocator() != null && sffDataPlaneLocator.getDataPlaneLocator().getLocatorType() != null && sffDataPlaneLocator.getDataPlaneLocator().getLocatorType().getImplementedInterface() != null && sffDataPlaneLocator.getDataPlaneLocator() .getLocatorType() .getImplementedInterface() .getSimpleName() != null) { String type = sffDataPlaneLocator.getDataPlaneLocator() .getLocatorType() .getImplementedInterface() .getSimpleName() .toLowerCase(); switch (type) { case FUNCTION: break; case IP: Ip ipLocator = (Ip) sffDataPlaneLocator.getDataPlaneLocator().getLocatorType(); if (ipLocator.getIp() != null) { renderedServicePathFirstHopBuilder.setIp(ipLocator.getIp()); if (ipLocator.getPort() != null) { renderedServicePathFirstHopBuilder.setPort(ipLocator.getPort()); } } renderedServicePathFirstHopBuilder.setTransportType(VxlanGpe.class); break; case LISP: break; case MAC: break; case MPLS: break; } } else { LOG.error("{}: Failed to read data plane locator {} for SFF {}", Thread.currentThread().getStackTrace()[1], sffLocatorName, sffName); } renderedServicePathFirstHop = renderedServicePathFirstHopBuilder.build(); } return renderedServicePathFirstHop; }  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 testReadRenderedServicePathFirstHop() { super.init(); ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME); assertNotNull("Must be not null", serviceFunctionPath); RenderedServicePath renderedServicePath = null; RenderedServicePath revRenderedServicePath = null; CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder(); createRenderedPathInputBuilder.setName(RSP_NAME.getValue()); try { renderedServicePath = SfcProviderRenderedPathAPI.createRenderedServicePathAndState(serviceFunctionPath, createRenderedPathInputBuilder.build()); } catch (Exception e) { e.printStackTrace(); } assertNotNull("Must be not null", renderedServicePath); try { revRenderedServicePath = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(renderedServicePath); } catch (NullPointerException e) { e.printStackTrace(); } assertNotNull("Must be not null", revRenderedServicePath); RenderedServicePathFirstHop firstHop; RenderedServicePathFirstHop lastHop; firstHop = SfcProviderRenderedPathAPI.readRenderedServicePathFirstHop(renderedServicePath.getName()); assertNotNull("Must be not null", firstHop); lastHop = SfcProviderRenderedPathAPI.readRenderedServicePathFirstHop(revRenderedServicePath.getName()); assertNotNull("Must be not null", lastHop); LOG.debug("First hop IP: {}, port: {}", firstHop.getIp().toString(), firstHop.getPort()); LOG.debug("Last hop IP: {}, port: {}", lastHop.getIp().toString(), lastHop.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))); assertEquals("Must be equal", lastHop.getIp(), new IpAddress(new Ipv4Address(SFF_LOCATOR_IP.get(SFF_LOCATOR_IP.size() - 1)))); assertEquals("Must be equal", lastHop.getPort(), new PortNumber(PORT.get(PORT.size() - 1))); SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName()); SfcProviderRenderedPathAPI.deleteRenderedServicePath(revRenderedServicePath.getName()); }