diff options
Diffstat (limited to 'ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api')
67 files changed, 7122 insertions, 7092 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/FileController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/FileController.java index c4197e8..905df8a 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/FileController.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/FileController.java @@ -50,42 +50,42 @@ import org.springframework.web.multipart.MultipartFile; @PropertySource(value = "classpath:dumpfileNames.properties") public class FileController { - static Logger log = Logger.getLogger(FileController.class.getName()); + static Logger log = Logger.getLogger(FileController.class.getName()); - private static final String fileBasePath = "/tmp/ransim-install/config/"; + private static final String fileBasePath = "/tmp/ransim-install/config/"; - @Value("${defaultFiles:}") - List<String> fileList = new ArrayList<>(); + @Value("${defaultFiles:}") + List<String> fileList = new ArrayList<>(); - /** - * Method to upload dump file - * - * @param file - * @return - */ - @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity<String> uploadToLocalFileSystem(@RequestParam("file") MultipartFile file) { - String fileName = StringUtils.cleanPath(file.getOriginalFilename()); - Path path = Paths.get(fileBasePath + fileName); - try { - Files.copy(file.getInputStream(), path, StandardCopyOption.REPLACE_EXISTING); - fileList.add(fileName); - log.info("File downloaded in " + fileBasePath + fileName); - } catch (IOException e) { - log.error(e); - } - log.info("Copied in path : " + path); - return ResponseEntity.ok("Uploaded successfully"); - } + /** + * Method to upload dump file + * + * @param file + * @return + */ + @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity<String> uploadToLocalFileSystem(@RequestParam("file") MultipartFile file) { + String fileName = StringUtils.cleanPath(file.getOriginalFilename()); + Path path = Paths.get(fileBasePath + fileName); + try { + Files.copy(file.getInputStream(), path, StandardCopyOption.REPLACE_EXISTING); + fileList.add(fileName); + log.info("File downloaded in " + fileBasePath + fileName); + } catch (IOException e) { + log.error(e); + } + log.info("Copied in path : " + path); + return ResponseEntity.ok("Uploaded successfully"); + } - /** - * Method to retrieve list of available dump files - * - * @return - */ - @GetMapping(value = "/dumpfiles", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity<List<String>> getFiles() { - return ResponseEntity.ok(fileList); - } + /** + * Method to retrieve list of available dump files + * + * @return + */ + @GetMapping(value = "/dumpfiles", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity<List<String>> getFiles() { + return ResponseEntity.ok(fileList); + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RANSliceConfigController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RANSliceConfigController.java index a3eb040..b6a661d 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RANSliceConfigController.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RANSliceConfigController.java @@ -23,20 +23,6 @@ package org.onap.ransim.rest.api.controller; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.onap.ransim.rest.api.models.NSSAIConfig; import org.onap.ransim.rest.api.services.RANSliceConfigService; @@ -48,540 +34,583 @@ import org.onap.ransim.rest.web.mapper.NRCellDUModel; import org.onap.ransim.rest.web.mapper.NearRTRICModel; import org.onap.ransim.rest.web.mapper.RANSliceInfoModel; import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(path = "/api/ransim-db/v4") public class RANSliceConfigController { - private static final Logger logger = LoggerFactory.getLogger(RANSliceConfigController.class); - - @Autowired - private RANSliceConfigService ranSliceConfigService; - - //SDN-R APIs - /** - * This method updates the slice details, config details of CUCP - * - * @param GNBCUCPModel - * @return ResponseEntity<GNBCUCPModel> - */ - @PutMapping(path = "/gNBCUCP") - public ResponseEntity<GNBCUCPModel> updateGNBCUCPFunction(@RequestBody GNBCUCPModel gNBCUCPModel) { - logger.info("Request Received"); - try { - return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.saveGNBCUCP(gNBCUCPModel), HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating GNBCUCP:" + e.getMessage()); - return new ResponseEntity<GNBCUCPModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the CUCP details - * - * @param gNBCUCPName - * @return ResponseEntity<GNBCUCPModel> - */ - @GetMapping(path = "/gNBCUCP/{gNBCUCPName}") - public ResponseEntity<GNBCUCPModel> findGNBCUCPFunction(@PathVariable String gNBCUCPName) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName)!=null) { - return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName), HttpStatus.OK); - }else { - return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching GNBCUCP:" + e.getMessage()); - return new ResponseEntity<GNBCUCPModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * This method updates the slice details, config details of CUUP - * - * @param GNBCUUPModel - * @return ResponseEntity<GNBCUUPModel> - */ - @PutMapping(path = "/gNBCUUP") - public ResponseEntity<GNBCUUPModel> updateGNBCUUPFunction(@RequestBody GNBCUUPModel gNBCUUPModel) { - logger.info("Request Received"); - try { - return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.saveGNBCUUP(gNBCUUPModel), HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating GNBCUUP:" + e.getMessage()); - return new ResponseEntity<GNBCUUPModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the CUCP details - * - * @param gNBCUCPName - * @return ResponseEntity<GNBCUCPModel> - */ - @GetMapping(path = "/gNBCUUP/{gNBCUUPId}") - public ResponseEntity<GNBCUUPModel> findGNBCUUPFunction(@PathVariable Integer gNBCUUPId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId)!=null) { - return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId), HttpStatus.OK); - }else { - return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching GNBCUCP:" + e.getMessage()); - return new ResponseEntity<GNBCUUPModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * This method updates the slice details, config details of gNBDU - * - * @param GNBDUModel - * @return ResponseEntity<GNBDUModel> - */ - @PutMapping(path = "/gNBDU") - public ResponseEntity<GNBDUModel> updateGNBDUFunction(@RequestBody GNBDUModel gNBDUModel) { - logger.info("Request Received"); - try { - return new ResponseEntity<GNBDUModel>(ranSliceConfigService.saveGNBDU(gNBDUModel), HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating GNBDU:" + e.getMessage()); - return new ResponseEntity<GNBDUModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the gNBDU details - * - * @param gNBDUId - * @return ResponseEntity<GNBDUModel> - */ - @GetMapping(path = "/gNBDU/{gNBDUId}") - public ResponseEntity<GNBDUModel> findGNBDUFunction(@PathVariable Integer gNBDUId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchGNBDUData(gNBDUId)!=null) { - return new ResponseEntity<GNBDUModel>(ranSliceConfigService.fetchGNBDUData(gNBDUId), HttpStatus.OK); - }else { - return new ResponseEntity<GNBDUModel>(ranSliceConfigService.fetchGNBDUData(gNBDUId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching GNBDU:" + e.getMessage()); - return new ResponseEntity<GNBDUModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * This method updates the NearRTRIC details - * - * @param nearRTRICModel - * @return ResponseEntity<NearRTRICModel> - */ - @PutMapping(path = "/nearRTRIC") - public ResponseEntity<NearRTRICModel> updateNearRTRIC(@RequestBody NearRTRICModel nearRTRICModel) { - logger.info("Request Received"); - try { - return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.saveNearRTRIC(nearRTRICModel), - HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating nearRTRIC:" + e.getMessage()); - return new ResponseEntity<NearRTRICModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the nearRTRIC details - * - * @param nearRTRICId - * @return ResponseEntity<GNBDUModel> - */ - @GetMapping(path = "/nearRTRIC/{nearRTRICId}") - public ResponseEntity<NearRTRICModel> findNearRTRICFunction(@PathVariable Integer nearRTRICId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchNearRTRICData(nearRTRICId)!=null) { - return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.fetchNearRTRICData(nearRTRICId), - HttpStatus.OK); - }else { - return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.fetchNearRTRICData(nearRTRICId), - HttpStatus.NO_CONTENT); - } - - } catch (Exception e) { - logger.error("Error while fetching nearRTRIC:" + e.getMessage()); - return new ResponseEntity<NearRTRICModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the RRMPolicy of CU/DU - * - * @param resourceType - * @param resourceId - * @return - */ - @GetMapping(path = "/rrmPolicy/{resourceType}/{resourceId}") - public ResponseEntity<RRMPolicyRatioModel> findRRMPolicyOfNE(@PathVariable String resourceType, - @PathVariable String resourceId) { - logger.debug("Request Received"); - try { - if(ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId)!=null) { - return new ResponseEntity<RRMPolicyRatioModel>( - ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId), HttpStatus.OK); - }else { - return new ResponseEntity<RRMPolicyRatioModel>( - ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching RRMPolicy:" + e.getMessage()); - return new ResponseEntity<RRMPolicyRatioModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * This method updates the RRM policy of a network function - * - * @param nearRTRICModel - * @return ResponseEntity<NearRTRICModel> - */ - @PostMapping(path = "/rrmPolicy") - public ResponseEntity<RRMPolicyRatioModel> updateRRMPolicy(@RequestBody RRMPolicyRatioModel rrmPolicy) { - logger.info("Request Received"); - try { - return new ResponseEntity<RRMPolicyRatioModel>(ranSliceConfigService.updateRRMPolicy(rrmPolicy), HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating RRM Policy:" + e.getMessage()); - return new ResponseEntity<RRMPolicyRatioModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - - /** - * To find the list of RICs from tracking area - * 1. Find Cells from TA - * 2. find List of RICs of the cells - * - * @param trackingArea - * @return - */ - @GetMapping(path = "/nearrtric-list/{trackingArea}") - public ResponseEntity<List<NearRTRICModel>> findNearRTRICofCellsFromTA(@PathVariable String trackingArea) { - logger.info("Request Received"); - try { - List<String> cellIds = this.findListOfCells(trackingArea).getBody(); - List<Integer> cellIdList =cellIds.stream().map(Integer::parseInt).collect(Collectors.toList()); - if(ranSliceConfigService.findNearRTRICofCells(cellIdList).size()>0) { - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICofCells(cellIdList), - HttpStatus.OK); - }else { - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICofCells(cellIdList), - HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the RICs:" + e.getMessage()); - return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To find the list of CUs in a tracking area - * - * @param trackingArea - * @return - */ - @GetMapping(path = "/cell-list/{trackingArea}") - public ResponseEntity<List<String>> findListOfCells(@PathVariable String trackingArea) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchCellsofTA(trackingArea).size()>0) { - return new ResponseEntity<List<String>>(ranSliceConfigService.fetchCellsofTA(trackingArea), HttpStatus.OK); - }else { - return new ResponseEntity<List<String>>(ranSliceConfigService.fetchCellsofTA(trackingArea), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the Cells:" + e.getMessage()); - return new ResponseEntity<List<String>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To find the list of CU-Cells - * - * @param nearRTRICId - * @return - */ - @GetMapping(path = "/cu-cell-list/{nearRTRICId}") - public ResponseEntity<List<NRCellCUModel>> findCUCellsofRIC(@PathVariable Integer nearRTRICId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId).size()>0) { - return new ResponseEntity<List<NRCellCUModel>>(ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId), HttpStatus.OK); - }else { - return new ResponseEntity<List<NRCellCUModel>>(ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error while fetching the Cells-CU:" + e.getMessage()); - return new ResponseEntity<List<NRCellCUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - - /** - * To find the nearRTRIC of NSSI - * - * This API can be used in Terminate/activate/deactivate to find the RIC from ranNFNSSIId in SO request - * - * @param ranNFNSSIId - * @return List<NearRTRICModel> - */ - @GetMapping(path = "/nearrtric/{ranNFNSSIId}") - public ResponseEntity<List<NearRTRICModel>> findNearRTRICByNSSI(@PathVariable String ranNFNSSIId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId).size()>0){ - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId), HttpStatus.OK); - }else { - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the nearRTRIC by RANNFNSSI:" + e.getMessage()); - return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To find the list of DU-Cells - * - * @param nearRTRICId - * @return - */ - @GetMapping(path = "/du-cell-list/{sNSSAI}") - public ResponseEntity<Map<Integer, List<NRCellDUModel>>> findDUCellsofRIC(@PathVariable String sNSSAI) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchDUCellsofRIC(sNSSAI).size()>0) { - return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>(ranSliceConfigService.fetchDUCellsofRIC(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>(ranSliceConfigService.fetchDUCellsofRIC(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error while fetching the Cells-DU:" + e.getMessage()); - return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - //Inventory APIs - /** - * This method updates the RAN slice details - * - * @param ranSliceInfoModel - * @return ResponseEntity<RANSliceInfoModel> - */ - @PutMapping(path = "/ranslice-details") - public ResponseEntity<RANSliceInfoModel> updateRANInventory(@RequestBody RANSliceInfoModel ranSliceInfoModel) { - logger.info("Request Received"); - try { - return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.updateRANInventory(ranSliceInfoModel), - HttpStatus.OK); - } catch (Exception e) { - logger.error("Error while updating RAN Inventory:" + e.getMessage()); - return new ResponseEntity<RANSliceInfoModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the RAN slice Details - * - * @param ranNFNSSIId - * @return RANSliceInfoModel - */ - @GetMapping(path = "/ranslice-details/{ranNFNSSIId}") - public ResponseEntity<RANSliceInfoModel> findRANSlice(@PathVariable String ranNFNSSIId) { - logger.info("Request Received"); - try { - if(ranSliceConfigService.fetchRANSlice(ranNFNSSIId)!=null) { - return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.fetchRANSlice(ranNFNSSIId), HttpStatus.OK); - }else { - return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.fetchRANSlice(ranNFNSSIId), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the RAN slice Details:" + e.getMessage()); - return new ResponseEntity<RANSliceInfoModel>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - //Slice Analysis MS APIs - /** - * To fetch The NearRTRICs serving the sNSSAI - * - * @param sNSSAI - * @return List<NearRTRICModel> - */ - @GetMapping(path = "/nearrtric/snssai/{sNSSAI}") - public ResponseEntity<List<NearRTRICModel>> findRICsofNSSAI(@PathVariable String sNSSAI){ - logger.info("Request Received"); - try { - if(ranSliceConfigService.findRICsByNSSAI(sNSSAI).size()>0) { - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findRICsByNSSAI(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findRICsByNSSAI(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the nearRTRIC by sNSSAI:" + e.getMessage()); - return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the configuration requested for a slice - * - * @param sNSSAI - * @return - */ - @GetMapping(path="/profile-config/{sNSSAI}") - public ResponseEntity<Map<String,Integer>> fetchSliceProfileConfiguration(@PathVariable String sNSSAI){ - logger.info("Request Received"); - try { - if(ranSliceConfigService.findSliceProfileconfig(sNSSAI).size()>0) { - return new ResponseEntity<Map<String,Integer>>(ranSliceConfigService.findSliceProfileconfig(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<Map<String,Integer>>(ranSliceConfigService.findSliceProfileconfig(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the Requested Configuration:" + e.getMessage()); - return new ResponseEntity<Map<String,Integer>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the configuration of a slice in RIC - * - * @param sNSSAI - * @return - */ - @GetMapping(path="/slice-config/{sNSSAI}") - public ResponseEntity<Map<Integer,NSSAIConfig>> fetchSliceConfiguration(@PathVariable String sNSSAI){ - logger.info("Request Received"); - try { - if(ranSliceConfigService.findSliceConfig(sNSSAI).size()>0) { - return new ResponseEntity<Map<Integer, NSSAIConfig>>(ranSliceConfigService.findSliceConfig(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<Map<Integer, NSSAIConfig>>(ranSliceConfigService.findSliceConfig(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error while fetching the Configuration of a Slice at RIC:" + e.getMessage()); - return new ResponseEntity<Map<Integer, NSSAIConfig>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the DU details - * - * @param - * @return List<GNBDUModel> - */ - @GetMapping(path="/du-list/{sNSSAI}") - public ResponseEntity<List<GNBDUModel>> fetchDUFunctionsOfNSSAI(@PathVariable String sNSSAI){ - logger.info("Request Received::"+sNSSAI); - try { - if(ranSliceConfigService.findDUsofSNssai(sNSSAI).size()>0) { - return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findDUsofSNssai(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findDUsofSNssai(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - e.printStackTrace(); - logger.error("Error while fetching the DU details of NSSAI:" + e.getMessage()); - return new ResponseEntity<List<GNBDUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the DU details - * - * @param - * @return List<GNBDUModel> - */ - @GetMapping(path="/cucp-list/{sNSSAI}") - public ResponseEntity<List<GNBCUCPModel>> fetchCUFunctionsOfNSSAI(@PathVariable String sNSSAI){ - logger.info("Request Received::"+sNSSAI); - try { - if(ranSliceConfigService.findDUsofSNssai(sNSSAI).size()>0) { - return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findCUsofSNssai(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findCUsofSNssai(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the CU details of NSSAI:" + e.getMessage()); - return new ResponseEntity<List<GNBCUCPModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the Customer Details - * - * @param - * @return Map<String, String> - */ - @GetMapping(path="/subscriber-details/{sNSSAI}") - public ResponseEntity<Map<String, String>> fetchSubsciberDetailsOfNSSAI(@PathVariable String sNSSAI){ - logger.info("Request Received::"+sNSSAI); - try { - if(ranSliceConfigService.getSubscriberDetails(sNSSAI).size()>0) { - return new ResponseEntity<Map<String, String>>(ranSliceConfigService.getSubscriberDetails(sNSSAI), HttpStatus.OK); - }else { - return new ResponseEntity<Map<String, String>>(ranSliceConfigService.getSubscriberDetails(sNSSAI), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the Customer details of NSSAI:" + e.getMessage()); - return new ResponseEntity<Map<String, String>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the cu details - * - * @param - * @return List<GNBCUCPModel> - */ - @GetMapping(path="/cucp-list") - public ResponseEntity<List<GNBCUCPModel>> fetchCUCPFunctions(){ - logger.info("Request Received"); - try { - if(ranSliceConfigService.findAllCUCPFunctions().size()>0) { - return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findAllCUCPFunctions(), HttpStatus.OK); - }else { - return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findAllCUCPFunctions(), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the CU details:" + e.getMessage()); - return new ResponseEntity<List<GNBCUCPModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * To fetch the DU details - * - * @param - * @return List<GNBDUModel> - */ - @GetMapping(path="/du-list") - public ResponseEntity<List<GNBDUModel>> fetchDUFunctions(){ - logger.info("Request Received"); - try { - if(ranSliceConfigService.findAllDUFunctions().size()>0) { - return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findAllDUFunctions(), HttpStatus.OK); - }else { - return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findAllDUFunctions(), HttpStatus.NO_CONTENT); - } - } catch (Exception e) { - logger.error("Error while fetching the DU details:" + e.getMessage()); - return new ResponseEntity<List<GNBDUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } + private static final Logger logger = LoggerFactory.getLogger(RANSliceConfigController.class); + + @Autowired + private RANSliceConfigService ranSliceConfigService; + + // SDN-R APIs + /** + * This method updates the slice details, config details of CUCP + * + * @param GNBCUCPModel + * @return ResponseEntity<GNBCUCPModel> + */ + @PutMapping(path = "/gNBCUCP") + public ResponseEntity<GNBCUCPModel> updateGNBCUCPFunction(@RequestBody GNBCUCPModel gNBCUCPModel) { + logger.info("Request Received"); + try { + return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.saveGNBCUCP(gNBCUCPModel), HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating GNBCUCP:" + e.getMessage()); + return new ResponseEntity<GNBCUCPModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the CUCP details + * + * @param gNBCUCPName + * @return ResponseEntity<GNBCUCPModel> + */ + @GetMapping(path = "/gNBCUCP/{gNBCUCPName}") + public ResponseEntity<GNBCUCPModel> findGNBCUCPFunction(@PathVariable String gNBCUCPName) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName) != null) { + return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName), + HttpStatus.OK); + } else { + return new ResponseEntity<GNBCUCPModel>(ranSliceConfigService.fetchGNBCUCPData(gNBCUCPName), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching GNBCUCP:" + e.getMessage()); + return new ResponseEntity<GNBCUCPModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * This method updates the slice details, config details of CUUP + * + * @param GNBCUUPModel + * @return ResponseEntity<GNBCUUPModel> + */ + @PutMapping(path = "/gNBCUUP") + public ResponseEntity<GNBCUUPModel> updateGNBCUUPFunction(@RequestBody GNBCUUPModel gNBCUUPModel) { + logger.info("Request Received"); + try { + return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.saveGNBCUUP(gNBCUUPModel), HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating GNBCUUP:" + e.getMessage()); + return new ResponseEntity<GNBCUUPModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the CUCP details + * + * @param gNBCUCPName + * @return ResponseEntity<GNBCUCPModel> + */ + @GetMapping(path = "/gNBCUUP/{gNBCUUPId}") + public ResponseEntity<GNBCUUPModel> findGNBCUUPFunction(@PathVariable Integer gNBCUUPId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId) != null) { + return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId), + HttpStatus.OK); + } else { + return new ResponseEntity<GNBCUUPModel>(ranSliceConfigService.fetchGNBCUUPData(gNBCUUPId), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching GNBCUCP:" + e.getMessage()); + return new ResponseEntity<GNBCUUPModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * This method updates the slice details, config details of gNBDU + * + * @param GNBDUModel + * @return ResponseEntity<GNBDUModel> + */ + @PutMapping(path = "/gNBDU") + public ResponseEntity<GNBDUModel> updateGNBDUFunction(@RequestBody GNBDUModel gNBDUModel) { + logger.info("Request Received"); + try { + return new ResponseEntity<GNBDUModel>(ranSliceConfigService.saveGNBDU(gNBDUModel), HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating GNBDU:" + e.getMessage()); + return new ResponseEntity<GNBDUModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the gNBDU details + * + * @param gNBDUId + * @return ResponseEntity<GNBDUModel> + */ + @GetMapping(path = "/gNBDU/{gNBDUId}") + public ResponseEntity<GNBDUModel> findGNBDUFunction(@PathVariable Integer gNBDUId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchGNBDUData(gNBDUId) != null) { + return new ResponseEntity<GNBDUModel>(ranSliceConfigService.fetchGNBDUData(gNBDUId), HttpStatus.OK); + } else { + return new ResponseEntity<GNBDUModel>(ranSliceConfigService.fetchGNBDUData(gNBDUId), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching GNBDU:" + e.getMessage()); + return new ResponseEntity<GNBDUModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * This method updates the NearRTRIC details + * + * @param nearRTRICModel + * @return ResponseEntity<NearRTRICModel> + */ + @PutMapping(path = "/nearRTRIC") + public ResponseEntity<NearRTRICModel> updateNearRTRIC(@RequestBody NearRTRICModel nearRTRICModel) { + logger.info("Request Received"); + try { + return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.saveNearRTRIC(nearRTRICModel), + HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating nearRTRIC:" + e.getMessage()); + return new ResponseEntity<NearRTRICModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the nearRTRIC details + * + * @param nearRTRICId + * @return ResponseEntity<GNBDUModel> + */ + @GetMapping(path = "/nearRTRIC/{nearRTRICId}") + public ResponseEntity<NearRTRICModel> findNearRTRICFunction(@PathVariable Integer nearRTRICId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchNearRTRICData(nearRTRICId) != null) { + return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.fetchNearRTRICData(nearRTRICId), + HttpStatus.OK); + } else { + return new ResponseEntity<NearRTRICModel>(ranSliceConfigService.fetchNearRTRICData(nearRTRICId), + HttpStatus.NO_CONTENT); + } + + } catch (Exception e) { + logger.error("Error while fetching nearRTRIC:" + e.getMessage()); + return new ResponseEntity<NearRTRICModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the RRMPolicy of CU/DU + * + * @param resourceType + * @param resourceId + * @return + */ + @GetMapping(path = "/rrmPolicy/{resourceType}/{resourceId}") + public ResponseEntity<RRMPolicyRatioModel> findRRMPolicyOfNE(@PathVariable String resourceType, + @PathVariable String resourceId) { + logger.debug("Request Received"); + try { + if (ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId) != null) { + return new ResponseEntity<RRMPolicyRatioModel>( + ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId), HttpStatus.OK); + } else { + return new ResponseEntity<RRMPolicyRatioModel>( + ranSliceConfigService.fetchRRMPolicyOfNE(resourceType, resourceId), HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching RRMPolicy:" + e.getMessage()); + return new ResponseEntity<RRMPolicyRatioModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * This method updates the RRM policy of a network function + * + * @param nearRTRICModel + * @return ResponseEntity<NearRTRICModel> + */ + @PostMapping(path = "/rrmPolicy") + public ResponseEntity<RRMPolicyRatioModel> updateRRMPolicy(@RequestBody RRMPolicyRatioModel rrmPolicy) { + logger.info("Request Received"); + try { + return new ResponseEntity<RRMPolicyRatioModel>(ranSliceConfigService.updateRRMPolicy(rrmPolicy), + HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating RRM Policy:" + e.getMessage()); + return new ResponseEntity<RRMPolicyRatioModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To find the list of RICs from tracking area + * 1. Find Cells from TA + * 2. find List of RICs of the cells + * + * @param trackingArea + * @return + */ + @GetMapping(path = "/nearrtric-list/{trackingArea}") + public ResponseEntity<List<NearRTRICModel>> findNearRTRICofCellsFromTA(@PathVariable String trackingArea) { + logger.info("Request Received"); + try { + List<String> cellIds = this.findListOfCells(trackingArea).getBody(); + List<Integer> cellIdList = cellIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + if (ranSliceConfigService.findNearRTRICofCells(cellIdList).size() > 0) { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICofCells(cellIdList), + HttpStatus.OK); + } else { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICofCells(cellIdList), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the RICs:" + e.getMessage()); + return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To find the list of CUs in a tracking area + * + * @param trackingArea + * @return + */ + @GetMapping(path = "/cell-list/{trackingArea}") + public ResponseEntity<List<String>> findListOfCells(@PathVariable String trackingArea) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchCellsofTA(trackingArea).size() > 0) { + return new ResponseEntity<List<String>>(ranSliceConfigService.fetchCellsofTA(trackingArea), + HttpStatus.OK); + } else { + return new ResponseEntity<List<String>>(ranSliceConfigService.fetchCellsofTA(trackingArea), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the Cells:" + e.getMessage()); + return new ResponseEntity<List<String>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To find the list of CU-Cells + * + * @param nearRTRICId + * @return + */ + @GetMapping(path = "/cu-cell-list/{nearRTRICId}") + public ResponseEntity<List<NRCellCUModel>> findCUCellsofRIC(@PathVariable Integer nearRTRICId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId).size() > 0) { + return new ResponseEntity<List<NRCellCUModel>>(ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId), + HttpStatus.OK); + } else { + return new ResponseEntity<List<NRCellCUModel>>(ranSliceConfigService.fetchCUCellsofRIC(nearRTRICId), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("Error while fetching the Cells-CU:" + e.getMessage()); + return new ResponseEntity<List<NRCellCUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To find the nearRTRIC of NSSI + * + * This API can be used in Terminate/activate/deactivate to find the RIC from ranNFNSSIId in SO request + * + * @param ranNFNSSIId + * @return List<NearRTRICModel> + */ + @GetMapping(path = "/nearrtric/{ranNFNSSIId}") + public ResponseEntity<List<NearRTRICModel>> findNearRTRICByNSSI(@PathVariable String ranNFNSSIId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId).size() > 0) { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId), + HttpStatus.OK); + } else { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findNearRTRICByNSSI(ranNFNSSIId), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the nearRTRIC by RANNFNSSI:" + e.getMessage()); + return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To find the list of DU-Cells + * + * @param nearRTRICId + * @return + */ + @GetMapping(path = "/du-cell-list/{sNSSAI}") + public ResponseEntity<Map<Integer, List<NRCellDUModel>>> findDUCellsofRIC(@PathVariable String sNSSAI) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchDUCellsofRIC(sNSSAI).size() > 0) { + return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>( + ranSliceConfigService.fetchDUCellsofRIC(sNSSAI), HttpStatus.OK); + } else { + return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>( + ranSliceConfigService.fetchDUCellsofRIC(sNSSAI), HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("Error while fetching the Cells-DU:" + e.getMessage()); + return new ResponseEntity<Map<Integer, List<NRCellDUModel>>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + // Inventory APIs + /** + * This method updates the RAN slice details + * + * @param ranSliceInfoModel + * @return ResponseEntity<RANSliceInfoModel> + */ + @PutMapping(path = "/ranslice-details") + public ResponseEntity<RANSliceInfoModel> updateRANInventory(@RequestBody RANSliceInfoModel ranSliceInfoModel) { + logger.info("Request Received"); + try { + return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.updateRANInventory(ranSliceInfoModel), + HttpStatus.OK); + } catch (Exception e) { + logger.error("Error while updating RAN Inventory:" + e.getMessage()); + return new ResponseEntity<RANSliceInfoModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the RAN slice Details + * + * @param ranNFNSSIId + * @return RANSliceInfoModel + */ + @GetMapping(path = "/ranslice-details/{ranNFNSSIId}") + public ResponseEntity<RANSliceInfoModel> findRANSlice(@PathVariable String ranNFNSSIId) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.fetchRANSlice(ranNFNSSIId) != null) { + return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.fetchRANSlice(ranNFNSSIId), + HttpStatus.OK); + } else { + return new ResponseEntity<RANSliceInfoModel>(ranSliceConfigService.fetchRANSlice(ranNFNSSIId), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the RAN slice Details:" + e.getMessage()); + return new ResponseEntity<RANSliceInfoModel>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + // Slice Analysis MS APIs + /** + * To fetch The NearRTRICs serving the sNSSAI + * + * @param sNSSAI + * @return List<NearRTRICModel> + */ + @GetMapping(path = "/nearrtric/snssai/{sNSSAI}") + public ResponseEntity<List<NearRTRICModel>> findRICsofNSSAI(@PathVariable String sNSSAI) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findRICsByNSSAI(sNSSAI).size() > 0) { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findRICsByNSSAI(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<List<NearRTRICModel>>(ranSliceConfigService.findRICsByNSSAI(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the nearRTRIC by sNSSAI:" + e.getMessage()); + return new ResponseEntity<List<NearRTRICModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the configuration requested for a slice + * + * @param sNSSAI + * @return + */ + @GetMapping(path = "/profile-config/{sNSSAI}") + public ResponseEntity<Map<String, Integer>> fetchSliceProfileConfiguration(@PathVariable String sNSSAI) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findSliceProfileconfig(sNSSAI).size() > 0) { + return new ResponseEntity<Map<String, Integer>>(ranSliceConfigService.findSliceProfileconfig(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<Map<String, Integer>>(ranSliceConfigService.findSliceProfileconfig(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the Requested Configuration:" + e.getMessage()); + return new ResponseEntity<Map<String, Integer>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the configuration of a slice in RIC + * + * @param sNSSAI + * @return + */ + @GetMapping(path = "/slice-config/{sNSSAI}") + public ResponseEntity<Map<Integer, NSSAIConfig>> fetchSliceConfiguration(@PathVariable String sNSSAI) { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findSliceConfig(sNSSAI).size() > 0) { + return new ResponseEntity<Map<Integer, NSSAIConfig>>(ranSliceConfigService.findSliceConfig(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<Map<Integer, NSSAIConfig>>(ranSliceConfigService.findSliceConfig(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("Error while fetching the Configuration of a Slice at RIC:" + e.getMessage()); + return new ResponseEntity<Map<Integer, NSSAIConfig>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the DU details + * + * @param + * @return List<GNBDUModel> + */ + @GetMapping(path = "/du-list/{sNSSAI}") + public ResponseEntity<List<GNBDUModel>> fetchDUFunctionsOfNSSAI(@PathVariable String sNSSAI) { + logger.info("Request Received::" + sNSSAI); + try { + if (ranSliceConfigService.findDUsofSNssai(sNSSAI).size() > 0) { + return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findDUsofSNssai(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findDUsofSNssai(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("Error while fetching the DU details of NSSAI:" + e.getMessage()); + return new ResponseEntity<List<GNBDUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the DU details + * + * @param + * @return List<GNBDUModel> + */ + @GetMapping(path = "/cucp-list/{sNSSAI}") + public ResponseEntity<List<GNBCUCPModel>> fetchCUFunctionsOfNSSAI(@PathVariable String sNSSAI) { + logger.info("Request Received::" + sNSSAI); + try { + if (ranSliceConfigService.findDUsofSNssai(sNSSAI).size() > 0) { + return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findCUsofSNssai(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findCUsofSNssai(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the CU details of NSSAI:" + e.getMessage()); + return new ResponseEntity<List<GNBCUCPModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the Customer Details + * + * @param + * @return Map<String, String> + */ + @GetMapping(path = "/subscriber-details/{sNSSAI}") + public ResponseEntity<Map<String, String>> fetchSubsciberDetailsOfNSSAI(@PathVariable String sNSSAI) { + logger.info("Request Received::" + sNSSAI); + try { + if (ranSliceConfigService.getSubscriberDetails(sNSSAI).size() > 0) { + return new ResponseEntity<Map<String, String>>(ranSliceConfigService.getSubscriberDetails(sNSSAI), + HttpStatus.OK); + } else { + return new ResponseEntity<Map<String, String>>(ranSliceConfigService.getSubscriberDetails(sNSSAI), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the Customer details of NSSAI:" + e.getMessage()); + return new ResponseEntity<Map<String, String>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the cu details + * + * @param + * @return List<GNBCUCPModel> + */ + @GetMapping(path = "/cucp-list") + public ResponseEntity<List<GNBCUCPModel>> fetchCUCPFunctions() { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findAllCUCPFunctions().size() > 0) { + return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findAllCUCPFunctions(), + HttpStatus.OK); + } else { + return new ResponseEntity<List<GNBCUCPModel>>(ranSliceConfigService.findAllCUCPFunctions(), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the CU details:" + e.getMessage()); + return new ResponseEntity<List<GNBCUCPModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * To fetch the DU details + * + * @param + * @return List<GNBDUModel> + */ + @GetMapping(path = "/du-list") + public ResponseEntity<List<GNBDUModel>> fetchDUFunctions() { + logger.info("Request Received"); + try { + if (ranSliceConfigService.findAllDUFunctions().size() > 0) { + return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findAllDUFunctions(), HttpStatus.OK); + } else { + return new ResponseEntity<List<GNBDUModel>>(ranSliceConfigService.findAllDUFunctions(), + HttpStatus.NO_CONTENT); + } + } catch (Exception e) { + logger.error("Error while fetching the DU details:" + e.getMessage()); + return new ResponseEntity<List<GNBDUModel>>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java index 5d15e58..5a26336 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java @@ -20,17 +20,28 @@ package org.onap.ransim.rest.api.controller; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; +import org.onap.ransim.rest.api.controller.RANSliceConfigController; +import org.onap.ransim.rest.api.handler.RansimPciHandler; +import org.onap.ransim.rest.api.handler.RansimSlicingHandler; import org.onap.ransim.rest.api.models.CellDetails; import org.onap.ransim.rest.api.models.CellNeighbor; import org.onap.ransim.rest.api.models.DeleteACellReq; @@ -44,14 +55,12 @@ import org.onap.ransim.rest.api.models.NeighborDetails; import org.onap.ransim.rest.api.models.NeihborId; import org.onap.ransim.rest.api.models.NetconfServers; import org.onap.ransim.rest.api.models.OperationLog; -import org.onap.ransim.rest.api.models.Topology; import org.onap.ransim.rest.api.models.TACells; -import org.onap.ransim.rest.api.services.RansimControllerServices; +import org.onap.ransim.rest.api.models.Topology; import org.onap.ransim.rest.api.services.RANSliceConfigService; +import org.onap.ransim.rest.api.services.RansimControllerServices; import org.onap.ransim.rest.api.services.RansimRepositoryService; -import org.onap.ransim.rest.api.controller.RANSliceConfigController; -import org.onap.ransim.rest.api.handler.RansimPciHandler; -import org.onap.ransim.rest.api.handler.RansimSlicingHandler; +import org.onap.ransim.rest.api.services.SlicingPMDataGenerator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -63,699 +72,709 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.onap.ransim.rest.api.services.SlicingPMDataGenerator; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - @RestController @Api(value = "Ran Simulator Controller Services") @RequestMapping("/api") @CrossOrigin(origins = "*") public class RansimController { - static Logger log = Logger.getLogger(RansimController.class.getName()); - - private static boolean isPmDataGenerating = false; - private static boolean isIntelligentSlicingPmDataGenerating = false; - - ScheduledExecutorService execService = Executors.newScheduledThreadPool(5); - ScheduledExecutorService execServiceForIntelligentSlicing = Executors.newScheduledThreadPool(5); - ScheduledExecutorService closedLoopExecService; - - @Autowired - RansimRepositoryService ransimRepo; - @Autowired - RansimControllerServices rscServices; - @Autowired - RansimPciHandler rsPciHdlr; - @Autowired - RANSliceConfigController ranSliceConfigController; - @Autowired - RANSliceConfigService ranSliceConfigService; - @Autowired - RansimSlicingHandler ranSliceHandler; - @Autowired - SlicingPMDataGenerator pmDataGenerator; - - /** - * Start the RAN network simulation. - * - * @param req gets the necessary details as a request of class type - * StartSimulationReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Starts the RAN network simulation") - @RequestMapping(value = "/StartSimulation", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) - public ResponseEntity<String> startSimulation(@RequestBody Map<String,String> dumpfile) throws Exception { - - List<CellDetails> cellList = ransimRepo.getCellDetailsList(); - if (!cellList.isEmpty()) { - return new ResponseEntity<>("Already simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); - } - try { - rscServices.loadProperties(); - RansimControllerServices.dumpFileName = dumpfile.containsKey("dumpfile") ? dumpfile.get("dumpfile"):null; - long startTimeStartSimulation = System.currentTimeMillis(); - rscServices.generateClusterFromFile(); - rscServices.sendInitialConfigAll(); - long endTimeStartSimulation = System.currentTimeMillis(); - log.info("Time taken for start simulation : " + (endTimeStartSimulation - startTimeStartSimulation)); - - return new ResponseEntity<String>(HttpStatus.OK); - - } catch (Exception eu) { - log.info("/StartSimulation ", eu); - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - @ApiOperation("Starts the RAN network slice simulation") - @RequestMapping(value = "/StartRanSliceSimulation", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) - public ResponseEntity<String> startRanSliceSimulation() throws Exception { - try { - rscServices.loadGNBFunctionProperties(); - long startTimeStartSimulation = System.currentTimeMillis(); - rscServices.sendRanInitialConfigAll(); - long endTimeStartSimulation = System.currentTimeMillis(); - log.info("Time taken for start ran slice simulation : " + (endTimeStartSimulation - startTimeStartSimulation)); - return new ResponseEntity<>("Simulation started.", HttpStatus.OK); - - } catch (Exception eu) { - log.info("/StartRanSliceSimulation ", eu); - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The performance Management Data of each cell will be sent to its netconf - * agent at a regular interval. - * - * @param req Contains the details of node ids which will have bad and poor pm - * values - * @return return HTTP status. - * - */ - @ApiOperation("Generate PM data") - @RequestMapping(value = "/GeneratePmData", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) - public ResponseEntity<String> generatePmData(@RequestBody GetPmDataReq req) throws Exception { - - log.info("Generate PM Data - nodeId_bad: " + req.getNodeIdBad() + ", nodeId_poor: " + req.getNodeIdPoor()); - try { - rsPciHdlr.readPmParameters(); - execService = Executors.newScheduledThreadPool(5); - execService.scheduleAtFixedRate(() -> { - - rsPciHdlr.generatePmData(req.getNodeIdBad(), req.getNodeIdPoor()); - log.info("execService.isTerminated(): " + execService.isTerminated()); - - }, 0, 300, TimeUnit.SECONDS); - - isPmDataGenerating = true; - - return new ResponseEntity<>("Request generated.", HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception: ", eu); - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - - } - - } - - /** - * Terminates the ScheduledExecutorService which sends the PM data at regular - * interval. - * - * @return returns HTTP status - * - */ - @ApiOperation("stop PM data") - @RequestMapping(value = "/stopPmData", method = RequestMethod.GET) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) - public ResponseEntity<String> stopPmData() throws Exception { - - try { - log.info("1. execService.isTerminated(): " + execService.isTerminated()); - if (!execService.isTerminated()) { - execService.shutdown(); - log.info("2. execService.isTerminated(): " + execService.isTerminated()); - - } - isPmDataGenerating = false; - return new ResponseEntity<>("PM data generated.", HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception: ", eu); - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - /** - * Get the status of ScheduledExecutorService, whether active or terminated. - * - * @return return the status - * - */ - @ApiOperation("get PM data status") - @RequestMapping(value = "/GetPmDataStatus", method = RequestMethod.GET) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot get information") }) - public boolean getPmDataStatus() throws Exception { - - try { - return isPmDataGenerating; - } catch (Exception eu) { - log.error("Exception: ", eu); - return false; - } - - } - - /** - * The function retrieves RAN simulation network topology. - * - * @return returns Http status - * @throws Exception throws exceptions in the functions - * - */ - @ApiOperation("Retrieves RAN simulation network topology") - @RequestMapping(value = "/GetTopology", method = RequestMethod.GET) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot retrieve the RAN simulation network topology details") }) - public ResponseEntity<String> getTopology() throws Exception { - log.debug("Inside getTopology..."); - try { - rsPciHdlr.checkCollisionAfterModify(); - List<CellDetails> cds = ransimRepo.getCellDetailsList(); - - Topology top = new Topology(); - - if (cds != null && cds.size() > 0) { - top.setMinScreenX(cds.get(0).getScreenX()); - top.setMaxScreenX(cds.get(0).getScreenX()); - top.setMinScreenY(cds.get(0).getScreenY()); - top.setMaxScreenY(cds.get(0).getScreenY()); - - for (int i = 0; i < cds.size(); i++) { - if (cds.get(i).getScreenX() < top.getMinScreenX()) { - top.setMinScreenX(cds.get(i).getScreenX()); - } - if (cds.get(i).getScreenY() < top.getMinScreenY()) { - top.setMinScreenY(cds.get(i).getScreenY()); - } - - if (cds.get(i).getScreenX() > top.getMaxScreenX()) { - top.setMaxScreenX(cds.get(i).getScreenX()); - } - if (cds.get(i).getScreenY() > top.getMaxScreenY()) { - top.setMaxScreenY(cds.get(i).getScreenY()); - } - } - top.setCellTopology(cds); - } - top.setGridSize(rscServices.gridSize); - - Gson gson = new Gson(); - String jsonStr = gson.toJson(top); - - return new ResponseEntity<>(jsonStr, HttpStatus.OK); - - } catch (Exception eu) { - log.error("GetTopology", eu); - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The function retrieves the neighbor list details for the cell with the - * mentioned nodeId. - * - * @param req gets the necessary details as a request of class type - * GetNeighborListReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId") - @RequestMapping(value = "/GetNeighborList", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot Insert the given parameters") }) - public ResponseEntity<String> getNeighborList(@RequestBody GetNeighborListReq req) throws Exception { - log.debug("Inside getNeighborList..."); - - try { - String jsonStr = ""; - - GetNeighborList message = rsPciHdlr.generateNeighborList(req.getNodeId()); - - if (message != null) { - - log.info("message.getNodeId(): " + message.getNodeId()); - - Gson gson = new Gson(); - jsonStr = gson.toJson(message); - } - return new ResponseEntity<>(jsonStr, HttpStatus.OK); - - } catch (Exception eu) { - log.info("/getNeighborList", eu); - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The function retrieves the neighbor list for the cell with the mentioned - * nodeId. - * - * @param req gets the necessary details as a request of class type - * GetNeighborListReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId") - @RequestMapping(value = "/GetNeighborBlacklistDetails", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot Insert the given parameters") }) - public ResponseEntity<String> getNeighborBlacklistDetails(@RequestBody GetNeighborListReq req) throws Exception { - log.debug("Inside getNeighborList..."); - - try { - String jsonStr = ""; - - CellNeighbor neighborList = ransimRepo.getCellNeighbor(req.getNodeId()); - - Map<String, String> result = new ConcurrentHashMap<String, String>(); - - for (NeighborDetails nd : neighborList.getNeighborList()) { - - result.put(nd.getNeigbor().getNeighborCell(), "" + nd.isBlacklisted()); - } - - if (result != null) { - Gson gson = new Gson(); - jsonStr = gson.toJson(result); - } - return new ResponseEntity<>(jsonStr, HttpStatus.OK); - - } catch (Exception eu) { - log.error("/getNeighborList", eu); - - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * Changes the pci number or nbr list for the given cell. - * - * @param req gets the necessary details as a request of class type - * ModifyACellReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Changes the pci number or nbr list for the given cell") - @RequestMapping(value = "/ModifyACell", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot update the PCI for the given cell") }) - public ResponseEntity<String> modifyACell(@RequestBody ModifyACellReq req) throws Exception { - log.debug("Inside ModifyCell..."); - - try { - long startTimemodifyCell = System.currentTimeMillis(); - - String nbrsStr = req.getNewNbrs(); - if (req.getNewNbrs() == null) { - nbrsStr = ""; - } - String source = "GUI"; - List<NeighborDetails> nbrsList = new ArrayList<NeighborDetails>(); - String[] newNbrsArr = nbrsStr.split(","); - - for (int i = 0; i < newNbrsArr.length; i++) { - NeighborDetails cell = new NeighborDetails(new NeihborId(req.getNodeId(), newNbrsArr[i].trim()), false); - nbrsList.add(cell); - } - - int result = rsPciHdlr.modifyCellFunction(req.getNodeId(), req.getNewPhysicalCellId(), nbrsList, source); - rscServices.handleModifyPciFromGui(req.getNodeId(), req.getNewPhysicalCellId()); - long endTimemodifyCell = System.currentTimeMillis(); - log.info("Time taken to modify cell : " + (endTimemodifyCell - startTimemodifyCell)); - - if (result == 200) { - return new ResponseEntity<String>(HttpStatus.OK); - } else if (result == 400) { - return new ResponseEntity<String>(HttpStatus.BAD_REQUEST); - } else { - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - } catch (Exception eu) { - log.error("Exception in modifyACell", eu); - return new ResponseEntity<>("Cannot update the PCI for the given cell", HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - /** - * The function changes the PCI number of the cell for the the mentioned nodeId. - * - * @param req gets the necessary details as a request of class type - * GetACellDetailReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Changes the pci number of the cell for the the mentioned nodeId") - @PostMapping(value = "/GetACellDetail") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot retrive the cell details for the given cell") }) - public ResponseEntity<String> getACellDetail(@RequestBody GetACellDetailReq req) throws Exception { - - log.debug("Inside GetACellDetailReq..."); - try { - String jsonStr = null; - - CellDetails cd = ransimRepo.getCellDetail(req.getNodeId()); - if (cd != null) { - Gson gson = new Gson(); - jsonStr = gson.toJson(cd); - } - return new ResponseEntity<>(jsonStr, HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception in getACellDetail : {} ", eu); - return new ResponseEntity<>("Cannot update the PCI for the given cell", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The function deletes a cell with the mentioned nodeId. - * - * @param req gets the necessary details as a request of class type - * DeleteACellReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Deletes a cell with the mentioned nodeId") - @RequestMapping(value = "/DeleteACell", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot delete the given cell") }) - public ResponseEntity<String> deleteACell(@RequestBody DeleteACellReq req) throws Exception { - log.debug("Inside delete cell..."); - - try { - long startTimeDeleteCell = System.currentTimeMillis(); - String result = rscServices.deleteCellFunction(req.getNodeId()); - long endTimeDeleteCell = System.currentTimeMillis(); - log.info("Time taken to delete cell : " + (endTimeDeleteCell - startTimeDeleteCell)); - return new ResponseEntity<String>(HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception in deleteACell", eu); - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The function stops RAN network simulation and deletes all the cell data from - * the database. - * - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Stops RAN network simulation and deletes all the cell data from the database") - @RequestMapping(value = "/StopSimulation", method = RequestMethod.DELETE) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot stop simulation") }) - public ResponseEntity<String> stopSimulation() throws Exception { - log.debug("Inside stopSimulation..."); - - if (ransimRepo.getCellDetailsList().isEmpty()) { - return new ResponseEntity<>("No simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); - } - - try { - long startTimStopSimulation = System.currentTimeMillis(); - ransimRepo.deleteNetconfServers(); - ransimRepo.deleteCellNeighbors(); - log.info("Stop simulation : " + (startTimStopSimulation)); - ransimRepo.deleteAllCellDetails(); - String result = rscServices.stopAllSimulation(); - log.info("All cell simulation are stopped...." + result); - long endTimStopSimulation = System.currentTimeMillis(); - log.info("Time taken for stopping simulation : " + (endTimStopSimulation - startTimStopSimulation)); - return new ResponseEntity<>("Success", HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception in stopSimulation", eu); - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - @ApiOperation("Stops RAN Slicing network simulation and deletes all the data from the database") - @RequestMapping(value = "/StopRanSliceSimulation", method = RequestMethod.DELETE) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot stop simulation") }) - public ResponseEntity<String> stopRanSliceSimulation() throws Exception { - log.debug("Inside stopSimulation..."); - if (ransimRepo.getCellDetailsList().isEmpty()) { - return new ResponseEntity<>("No simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); - } - - try { - long startTimStopSimulation = System.currentTimeMillis(); - ransimRepo.deleteNetconfServers(); - log.info("Stop simulation : " + (startTimStopSimulation)); - String result = rscServices.stopAllSimulation(); - log.info("All cell simulation are stopped...." + result); - long endTimStopSimulation = System.currentTimeMillis(); - log.info("Time taken for stopping simulation : " + (endTimStopSimulation - startTimStopSimulation)); - return new ResponseEntity<>("Simulation stopped", HttpStatus.OK); - - } catch (Exception eu) { - log.error("Exception in stopRanSliceSimulation", eu); - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - /** - * The function returns the details of a Netconf server for the mentioned server - * id. - * - * @param req gets the necessary details as a request of class type - * GetNetconfServerDetailsReq - * @return returns Http status - * @throws Exception throws exceptions in the functions - */ - @ApiOperation("Returns the details of a Netconf server for the mentioned server id") - @RequestMapping(value = "/GetNetconfServerDetails", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API") }) - public ResponseEntity<String> getNetconfServerDetails(@RequestBody GetNetconfServerDetailsReq req) - throws Exception { - - try { - log.debug("Inside GetNetconfServerDetails API..."); - String result = ""; - String input = req.getServerId(); - if (input.startsWith("Chn")) { - CellDetails cds = ransimRepo.getCellDetail(input); - if (cds != null) { - Gson gson = new Gson(); - String jsonStr = gson.toJson(cds); - result = "{\"serverId\":\"any\",\"cells\":[" + jsonStr + "]}"; - } else { - result = ("Cell Id does not exist"); - } - } else { - NetconfServers ns = ransimRepo.getNetconfServer(input); - if (ns != null) { - Gson gson = new Gson(); - String jsonStr = gson.toJson(ns); - result = jsonStr; - } else { - result = ("Server Id does not exist"); - } - } - return new ResponseEntity<>(result, HttpStatus.OK); - - } catch (Exception eu) { - log.error("/GetNetconfServers", eu); - return new ResponseEntity<>("Failure in GetNetconfServerDetails API", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - @ApiOperation("Returns the connection status of all netconf servers") - @RequestMapping(value = "/GetNetconfStatus", method = RequestMethod.GET) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API") }) - public ResponseEntity<String> GetNetconfStatus() throws Exception { - - try { - log.debug("Inside GetNetconfServerDetails API..."); - String result = ""; - - List<NetconfServers> ns = ransimRepo.getNetconfServersList(); - if (ns != null) { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); - Gson gson = gsonBuilder.create(); - String jsonStr = gson.toJson(ns); - result = jsonStr; - } else { - result = ("Server Id does not exist"); - } - - return new ResponseEntity<>(result, HttpStatus.OK); - - } catch (Exception eu) { - log.error("/GetNetconfServers", eu); - return new ResponseEntity<>("Failure in GetNetconfServerDetails API", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - /** - * The function retrieves RAN simulation network topology. - * - * @return returns Http status - * @throws Exception throws exceptions in the functions - * - */ - @ApiOperation("Retrieves operations log - Modify/Delete operations performed") - @GetMapping(value = "/GetOperationLog") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot retrieve the Operation Logs") }) - public ResponseEntity<String> getOperationLog() throws Exception { - log.debug("Inside getOperationLog..."); - try { - List<OperationLog> ols = ransimRepo.getOperationLogList(); - if (ols != null && ols.size() > 0) { - Gson gson = new Gson(); - String jsonStr = gson.toJson(ols); - return new ResponseEntity<>(jsonStr, HttpStatus.OK); - } else { - return new ResponseEntity<>("", HttpStatus.OK); - } - } catch (Exception eu) { - log.error("/GetOperationLog", eu); - return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - - @ApiOperation("Generate IntelligentSlicing PM data") + static Logger log = Logger.getLogger(RansimController.class.getName()); + + private static boolean isPmDataGenerating = false; + private static boolean isIntelligentSlicingPmDataGenerating = false; + + ScheduledExecutorService execService = Executors.newScheduledThreadPool(5); + ScheduledExecutorService execServiceForIntelligentSlicing = Executors.newScheduledThreadPool(5); + ScheduledExecutorService closedLoopExecService; + + @Autowired + RansimRepositoryService ransimRepo; + @Autowired + RansimControllerServices rscServices; + @Autowired + RansimPciHandler rsPciHdlr; + @Autowired + RANSliceConfigController ranSliceConfigController; + @Autowired + RANSliceConfigService ranSliceConfigService; + @Autowired + RansimSlicingHandler ranSliceHandler; + @Autowired + SlicingPMDataGenerator pmDataGenerator; + + /** + * Start the RAN network simulation. + * + * @param req gets the necessary details as a request of class type + * StartSimulationReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Starts the RAN network simulation") + @RequestMapping(value = "/StartSimulation", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) + public ResponseEntity<String> startSimulation(@RequestBody Map<String, String> dumpfile) throws Exception { + + List<CellDetails> cellList = ransimRepo.getCellDetailsList(); + if (!cellList.isEmpty()) { + return new ResponseEntity<>("Already simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); + } + try { + rscServices.loadProperties(); + RansimControllerServices.dumpFileName = dumpfile.containsKey("dumpfile") ? dumpfile.get("dumpfile") : null; + long startTimeStartSimulation = System.currentTimeMillis(); + rscServices.generateClusterFromFile(); + rscServices.sendInitialConfigAll(); + long endTimeStartSimulation = System.currentTimeMillis(); + log.info("Time taken for start simulation : " + (endTimeStartSimulation - startTimeStartSimulation)); + + return new ResponseEntity<String>(HttpStatus.OK); + + } catch (Exception eu) { + log.info("/StartSimulation ", eu); + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + @ApiOperation("Starts the RAN network slice simulation") + @RequestMapping(value = "/StartRanSliceSimulation", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) + public ResponseEntity<String> startRanSliceSimulation() throws Exception { + try { + rscServices.loadGNBFunctionProperties(); + long startTimeStartSimulation = System.currentTimeMillis(); + rscServices.sendRanInitialConfigAll(); + long endTimeStartSimulation = System.currentTimeMillis(); + log.info("Time taken for start ran slice simulation : " + + (endTimeStartSimulation - startTimeStartSimulation)); + return new ResponseEntity<>("Simulation started.", HttpStatus.OK); + + } catch (Exception eu) { + log.info("/StartRanSliceSimulation ", eu); + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The performance Management Data of each cell will be sent to its netconf + * agent at a regular interval. + * + * @param req Contains the details of node ids which will have bad and poor pm + * values + * @return return HTTP status. + * + */ + @ApiOperation("Generate PM data") + @RequestMapping(value = "/GeneratePmData", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) + public ResponseEntity<String> generatePmData(@RequestBody GetPmDataReq req) throws Exception { + + log.info("Generate PM Data - nodeId_bad: " + req.getNodeIdBad() + ", nodeId_poor: " + req.getNodeIdPoor()); + try { + rsPciHdlr.readPmParameters(); + execService = Executors.newScheduledThreadPool(5); + execService.scheduleAtFixedRate(() -> { + + rsPciHdlr.generatePmData(req.getNodeIdBad(), req.getNodeIdPoor()); + log.info("execService.isTerminated(): " + execService.isTerminated()); + + }, 0, 300, TimeUnit.SECONDS); + + isPmDataGenerating = true; + + return new ResponseEntity<>("Request generated.", HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception: ", eu); + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + + } + + } + + /** + * Terminates the ScheduledExecutorService which sends the PM data at regular + * interval. + * + * @return returns HTTP status + * + */ + @ApiOperation("stop PM data") + @RequestMapping(value = "/stopPmData", method = RequestMethod.GET) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) + public ResponseEntity<String> stopPmData() throws Exception { + + try { + log.info("1. execService.isTerminated(): " + execService.isTerminated()); + if (!execService.isTerminated()) { + execService.shutdown(); + log.info("2. execService.isTerminated(): " + execService.isTerminated()); + + } + isPmDataGenerating = false; + return new ResponseEntity<>("PM data generated.", HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception: ", eu); + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + /** + * Get the status of ScheduledExecutorService, whether active or terminated. + * + * @return return the status + * + */ + @ApiOperation("get PM data status") + @RequestMapping(value = "/GetPmDataStatus", method = RequestMethod.GET) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot get information")}) + public boolean getPmDataStatus() throws Exception { + + try { + return isPmDataGenerating; + } catch (Exception eu) { + log.error("Exception: ", eu); + return false; + } + + } + + /** + * The function retrieves RAN simulation network topology. + * + * @return returns Http status + * @throws Exception throws exceptions in the functions + * + */ + @ApiOperation("Retrieves RAN simulation network topology") + @RequestMapping(value = "/GetTopology", method = RequestMethod.GET) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot retrieve the RAN simulation network topology details")}) + public ResponseEntity<String> getTopology() throws Exception { + log.debug("Inside getTopology..."); + try { + rsPciHdlr.checkCollisionAfterModify(); + List<CellDetails> cds = ransimRepo.getCellDetailsList(); + + Topology top = new Topology(); + + if (cds != null && cds.size() > 0) { + top.setMinScreenX(cds.get(0).getScreenX()); + top.setMaxScreenX(cds.get(0).getScreenX()); + top.setMinScreenY(cds.get(0).getScreenY()); + top.setMaxScreenY(cds.get(0).getScreenY()); + + for (int i = 0; i < cds.size(); i++) { + if (cds.get(i).getScreenX() < top.getMinScreenX()) { + top.setMinScreenX(cds.get(i).getScreenX()); + } + if (cds.get(i).getScreenY() < top.getMinScreenY()) { + top.setMinScreenY(cds.get(i).getScreenY()); + } + + if (cds.get(i).getScreenX() > top.getMaxScreenX()) { + top.setMaxScreenX(cds.get(i).getScreenX()); + } + if (cds.get(i).getScreenY() > top.getMaxScreenY()) { + top.setMaxScreenY(cds.get(i).getScreenY()); + } + } + top.setCellTopology(cds); + } + top.setGridSize(rscServices.gridSize); + + Gson gson = new Gson(); + String jsonStr = gson.toJson(top); + + return new ResponseEntity<>(jsonStr, HttpStatus.OK); + + } catch (Exception eu) { + log.error("GetTopology", eu); + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The function retrieves the neighbor list details for the cell with the + * mentioned nodeId. + * + * @param req gets the necessary details as a request of class type + * GetNeighborListReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId") + @RequestMapping(value = "/GetNeighborList", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot Insert the given parameters")}) + public ResponseEntity<String> getNeighborList(@RequestBody GetNeighborListReq req) throws Exception { + log.debug("Inside getNeighborList..."); + + try { + String jsonStr = ""; + + GetNeighborList message = rsPciHdlr.generateNeighborList(req.getNodeId()); + + if (message != null) { + + log.info("message.getNodeId(): " + message.getNodeId()); + + Gson gson = new Gson(); + jsonStr = gson.toJson(message); + } + return new ResponseEntity<>(jsonStr, HttpStatus.OK); + + } catch (Exception eu) { + log.info("/getNeighborList", eu); + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The function retrieves the neighbor list for the cell with the mentioned + * nodeId. + * + * @param req gets the necessary details as a request of class type + * GetNeighborListReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId") + @RequestMapping(value = "/GetNeighborBlacklistDetails", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot Insert the given parameters")}) + public ResponseEntity<String> getNeighborBlacklistDetails(@RequestBody GetNeighborListReq req) throws Exception { + log.debug("Inside getNeighborList..."); + + try { + String jsonStr = ""; + + CellNeighbor neighborList = ransimRepo.getCellNeighbor(req.getNodeId()); + + Map<String, String> result = new ConcurrentHashMap<String, String>(); + + for (NeighborDetails nd : neighborList.getNeighborList()) { + + result.put(nd.getNeigbor().getNeighborCell(), "" + nd.isBlacklisted()); + } + + if (result != null) { + Gson gson = new Gson(); + jsonStr = gson.toJson(result); + } + return new ResponseEntity<>(jsonStr, HttpStatus.OK); + + } catch (Exception eu) { + log.error("/getNeighborList", eu); + + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * Changes the pci number or nbr list for the given cell. + * + * @param req gets the necessary details as a request of class type + * ModifyACellReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Changes the pci number or nbr list for the given cell") + @RequestMapping(value = "/ModifyACell", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot update the PCI for the given cell")}) + public ResponseEntity<String> modifyACell(@RequestBody ModifyACellReq req) throws Exception { + log.debug("Inside ModifyCell..."); + + try { + long startTimemodifyCell = System.currentTimeMillis(); + + String nbrsStr = req.getNewNbrs(); + if (req.getNewNbrs() == null) { + nbrsStr = ""; + } + String source = "GUI"; + List<NeighborDetails> nbrsList = new ArrayList<NeighborDetails>(); + String[] newNbrsArr = nbrsStr.split(","); + + for (int i = 0; i < newNbrsArr.length; i++) { + NeighborDetails cell = new NeighborDetails(new NeihborId(req.getNodeId(), newNbrsArr[i].trim()), false); + nbrsList.add(cell); + } + + int result = rsPciHdlr.modifyCellFunction(req.getNodeId(), req.getNewPhysicalCellId(), nbrsList, source); + rscServices.handleModifyPciFromGui(req.getNodeId(), req.getNewPhysicalCellId()); + long endTimemodifyCell = System.currentTimeMillis(); + log.info("Time taken to modify cell : " + (endTimemodifyCell - startTimemodifyCell)); + + if (result == 200) { + return new ResponseEntity<String>(HttpStatus.OK); + } else if (result == 400) { + return new ResponseEntity<String>(HttpStatus.BAD_REQUEST); + } else { + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } catch (Exception eu) { + log.error("Exception in modifyACell", eu); + return new ResponseEntity<>("Cannot update the PCI for the given cell", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + /** + * The function changes the PCI number of the cell for the the mentioned nodeId. + * + * @param req gets the necessary details as a request of class type + * GetACellDetailReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Changes the pci number of the cell for the the mentioned nodeId") + @PostMapping(value = "/GetACellDetail") + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot retrive the cell details for the given cell")}) + public ResponseEntity<String> getACellDetail(@RequestBody GetACellDetailReq req) throws Exception { + + log.debug("Inside GetACellDetailReq..."); + try { + String jsonStr = null; + + CellDetails cd = ransimRepo.getCellDetail(req.getNodeId()); + if (cd != null) { + Gson gson = new Gson(); + jsonStr = gson.toJson(cd); + } + return new ResponseEntity<>(jsonStr, HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception in getACellDetail : {} ", eu); + return new ResponseEntity<>("Cannot update the PCI for the given cell", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The function deletes a cell with the mentioned nodeId. + * + * @param req gets the necessary details as a request of class type + * DeleteACellReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Deletes a cell with the mentioned nodeId") + @RequestMapping(value = "/DeleteACell", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot delete the given cell")}) + public ResponseEntity<String> deleteACell(@RequestBody DeleteACellReq req) throws Exception { + log.debug("Inside delete cell..."); + + try { + long startTimeDeleteCell = System.currentTimeMillis(); + String result = rscServices.deleteCellFunction(req.getNodeId()); + long endTimeDeleteCell = System.currentTimeMillis(); + log.info("Time taken to delete cell : " + (endTimeDeleteCell - startTimeDeleteCell)); + return new ResponseEntity<String>(HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception in deleteACell", eu); + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The function stops RAN network simulation and deletes all the cell data from + * the database. + * + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Stops RAN network simulation and deletes all the cell data from the database") + @RequestMapping(value = "/StopSimulation", method = RequestMethod.DELETE) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot stop simulation")}) + public ResponseEntity<String> stopSimulation() throws Exception { + log.debug("Inside stopSimulation..."); + + if (ransimRepo.getCellDetailsList().isEmpty()) { + return new ResponseEntity<>("No simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); + } + + try { + long startTimStopSimulation = System.currentTimeMillis(); + ransimRepo.deleteNetconfServers(); + ransimRepo.deleteCellNeighbors(); + log.info("Stop simulation : " + (startTimStopSimulation)); + ransimRepo.deleteAllCellDetails(); + String result = rscServices.stopAllSimulation(); + log.info("All cell simulation are stopped...." + result); + long endTimStopSimulation = System.currentTimeMillis(); + log.info("Time taken for stopping simulation : " + (endTimStopSimulation - startTimStopSimulation)); + return new ResponseEntity<>("Success", HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception in stopSimulation", eu); + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + @ApiOperation("Stops RAN Slicing network simulation and deletes all the data from the database") + @RequestMapping(value = "/StopRanSliceSimulation", method = RequestMethod.DELETE) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot stop simulation")}) + public ResponseEntity<String> stopRanSliceSimulation() throws Exception { + log.debug("Inside stopSimulation..."); + if (ransimRepo.getCellDetailsList().isEmpty()) { + return new ResponseEntity<>("No simulation is running.", HttpStatus.INTERNAL_SERVER_ERROR); + } + + try { + long startTimStopSimulation = System.currentTimeMillis(); + ransimRepo.deleteNetconfServers(); + log.info("Stop simulation : " + (startTimStopSimulation)); + String result = rscServices.stopAllSimulation(); + log.info("All cell simulation are stopped...." + result); + long endTimStopSimulation = System.currentTimeMillis(); + log.info("Time taken for stopping simulation : " + (endTimStopSimulation - startTimStopSimulation)); + return new ResponseEntity<>("Simulation stopped", HttpStatus.OK); + + } catch (Exception eu) { + log.error("Exception in stopRanSliceSimulation", eu); + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + /** + * The function returns the details of a Netconf server for the mentioned server + * id. + * + * @param req gets the necessary details as a request of class type + * GetNetconfServerDetailsReq + * @return returns Http status + * @throws Exception throws exceptions in the functions + */ + @ApiOperation("Returns the details of a Netconf server for the mentioned server id") + @RequestMapping(value = "/GetNetconfServerDetails", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API")}) + public ResponseEntity<String> getNetconfServerDetails(@RequestBody GetNetconfServerDetailsReq req) + throws Exception { + + try { + log.debug("Inside GetNetconfServerDetails API..."); + String result = ""; + String input = req.getServerId(); + if (input.startsWith("Chn")) { + CellDetails cds = ransimRepo.getCellDetail(input); + if (cds != null) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(cds); + result = "{\"serverId\":\"any\",\"cells\":[" + jsonStr + "]}"; + } else { + result = ("Cell Id does not exist"); + } + } else { + NetconfServers ns = ransimRepo.getNetconfServer(input); + if (ns != null) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(ns); + result = jsonStr; + } else { + result = ("Server Id does not exist"); + } + } + return new ResponseEntity<>(result, HttpStatus.OK); + + } catch (Exception eu) { + log.error("/GetNetconfServers", eu); + return new ResponseEntity<>("Failure in GetNetconfServerDetails API", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @ApiOperation("Returns the connection status of all netconf servers") + @RequestMapping(value = "/GetNetconfStatus", method = RequestMethod.GET) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API")}) + public ResponseEntity<String> GetNetconfStatus() throws Exception { + + try { + log.debug("Inside GetNetconfServerDetails API..."); + String result = ""; + + List<NetconfServers> ns = ransimRepo.getNetconfServersList(); + if (ns != null) { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); + Gson gson = gsonBuilder.create(); + String jsonStr = gson.toJson(ns); + result = jsonStr; + } else { + result = ("Server Id does not exist"); + } + + return new ResponseEntity<>(result, HttpStatus.OK); + + } catch (Exception eu) { + log.error("/GetNetconfServers", eu); + return new ResponseEntity<>("Failure in GetNetconfServerDetails API", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + /** + * The function retrieves RAN simulation network topology. + * + * @return returns Http status + * @throws Exception throws exceptions in the functions + * + */ + @ApiOperation("Retrieves operations log - Modify/Delete operations performed") + @GetMapping(value = "/GetOperationLog") + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot retrieve the Operation Logs")}) + public ResponseEntity<String> getOperationLog() throws Exception { + log.debug("Inside getOperationLog..."); + try { + List<OperationLog> ols = ransimRepo.getOperationLogList(); + if (ols != null && ols.size() > 0) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(ols); + return new ResponseEntity<>(jsonStr, HttpStatus.OK); + } else { + return new ResponseEntity<>("", HttpStatus.OK); + } + } catch (Exception eu) { + log.error("/GetOperationLog", eu); + return new ResponseEntity<>("Failure", HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @ApiOperation("Generate IntelligentSlicing PM data") @RequestMapping(value = "/GenerateIntelligentSlicingPmData", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot t the simulation") }) - public ResponseEntity<String> generateIntelligentSlicingPmData(){ - log.info("******************Request to generate***************************"); - + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot t the simulation")}) + public ResponseEntity<String> generateIntelligentSlicingPmData() { + log.info("******************Request to generate***************************"); + try { long startTime = (System.currentTimeMillis()); Iterable<TACells> tacellList = ranSliceConfigService.fetchAllTA(); - HashMap<String,List<String>> taCells = new HashMap<>(); - for(TACells ta : tacellList) - { - String[] cells = ta.getCellsList().split(","); - List<String> cellList = new ArrayList<String>(Arrays.asList(cells)); - taCells.put(ta.getTrackingArea(),cellList); + HashMap<String, List<String>> taCells = new HashMap<>(); + for (TACells ta : tacellList) { + String[] cells = ta.getCellsList().split(","); + List<String> cellList = new ArrayList<String>(Arrays.asList(cells)); + taCells.put(ta.getTrackingArea(), cellList); } execServiceForIntelligentSlicing = Executors.newScheduledThreadPool(5); - execServiceForIntelligentSlicing.scheduleAtFixedRate( - () -> { - - ranSliceHandler.generateIntelligentSlicingPmData(startTime,taCells); - log.info("execServiceforIntelligentSlicing.isTerminated(): " + execServiceForIntelligentSlicing.isTerminated()); - - }, 0, 10, TimeUnit.SECONDS); - + execServiceForIntelligentSlicing.scheduleAtFixedRate(() -> { + + ranSliceHandler.generateIntelligentSlicingPmData(startTime, taCells); + log.info("execServiceforIntelligentSlicing.isTerminated(): " + + execServiceForIntelligentSlicing.isTerminated()); + + }, 0, 10, TimeUnit.SECONDS); + isIntelligentSlicingPmDataGenerating = true; - - } catch (Exception eu) { log.info("Exception: ", eu); return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - + } return new ResponseEntity<>("IntelligentSlicing PM data generated.", HttpStatus.OK); } - + @ApiOperation("Stop IntelligentSlicing PM data") @RequestMapping(value = "/stopIntelligentSlicingPmData", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) public ResponseEntity<String> stopIntelligentSlicingPmData() throws Exception { - + try { - log.info("1. execServiceForIntelligentSlicing.isTerminated(): " + execServiceForIntelligentSlicing.isTerminated()); + log.info("1. execServiceForIntelligentSlicing.isTerminated(): " + + execServiceForIntelligentSlicing.isTerminated()); if (!execServiceForIntelligentSlicing.isTerminated()) { - execServiceForIntelligentSlicing.shutdown(); - log.info("2. execServiceForIntelligentSlicing.isTerminated(): " + execServiceForIntelligentSlicing.isTerminated()); - + execServiceForIntelligentSlicing.shutdown(); + log.info("2. execServiceForIntelligentSlicing.isTerminated(): " + + execServiceForIntelligentSlicing.isTerminated()); + } isIntelligentSlicingPmDataGenerating = false; return new ResponseEntity<>("Stopped PM data generation.", HttpStatus.OK); - + } catch (Exception eu) { return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); } - - } + } - /* - *Generate closed loopPM data for DUs - * - */ - @ApiOperation("Generate Closed loop PM data") - @RequestMapping(value = "/generateClosedLoopPmData", method = RequestMethod.POST) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Problem generating closed loop PM data") }) - public ResponseEntity<String> generateClosedLoopPmData() { - long startTime = (System.currentTimeMillis()); - log.info("Closed loop PM Data generation started at " + startTime); - closedLoopExecService = Executors.newScheduledThreadPool(5); - closedLoopExecService.scheduleAtFixedRate(() -> { - pmDataGenerator.generateClosedLoopPmData(startTime); - log.info("closedLoopexecService.isTerminated(): " + execServiceForIntelligentSlicing.isTerminated()); - - }, 0, 10, TimeUnit.SECONDS); - - return new ResponseEntity<>("Generating Closed loop PM data.", HttpStatus.OK); - } + /* + * Generate closed loopPM data for DUs + * + */ + @ApiOperation("Generate Closed loop PM data") + @RequestMapping(value = "/generateClosedLoopPmData", method = RequestMethod.POST) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Problem generating closed loop PM data")}) + public ResponseEntity<String> generateClosedLoopPmData() { + long startTime = (System.currentTimeMillis()); + log.info("Closed loop PM Data generation started at " + startTime); + closedLoopExecService = Executors.newScheduledThreadPool(5); + closedLoopExecService.scheduleAtFixedRate(() -> { + pmDataGenerator.generateClosedLoopPmData(startTime); + log.info("closedLoopexecService.isTerminated(): " + execServiceForIntelligentSlicing.isTerminated()); + + }, 0, 10, TimeUnit.SECONDS); + + return new ResponseEntity<>("Generating Closed loop PM data.", HttpStatus.OK); + } - @ApiOperation("Stop Closed loop PM data") - @RequestMapping(value = "/stopClosedLoopPmData", method = RequestMethod.GET) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"), - @ApiResponse(code = 500, message = "Cannot start the simulation") }) - public ResponseEntity<String> stopClosedLoopPmData() throws Exception { + @ApiOperation("Stop Closed loop PM data") + @RequestMapping(value = "/stopClosedLoopPmData", method = RequestMethod.GET) + @ApiResponses( + value = {@ApiResponse(code = 200, message = "Successful"), + @ApiResponse(code = 500, message = "Cannot start the simulation")}) + public ResponseEntity<String> stopClosedLoopPmData() throws Exception { - try { - log.info("1. closedLoopexecService.isTerminated(): " + closedLoopExecService.isTerminated()); - if (!closedLoopExecService.isTerminated()) { - closedLoopExecService.shutdown(); - log.info("2. closedLoopexecService.isTerminated(): " + closedLoopExecService.isTerminated()); + try { + log.info("1. closedLoopexecService.isTerminated(): " + closedLoopExecService.isTerminated()); + if (!closedLoopExecService.isTerminated()) { + closedLoopExecService.shutdown(); + log.info("2. closedLoopexecService.isTerminated(): " + closedLoopExecService.isTerminated()); - } - return new ResponseEntity<>("Closed loop PM data generated.", HttpStatus.OK); + } + return new ResponseEntity<>("Closed loop PM data generated.", HttpStatus.OK); - } catch (Exception eu) { - return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); - } + } catch (Exception eu) { + return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); + } - } + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/exceptions/RansimException.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/exceptions/RansimException.java index e72b528..a9aaf2f 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/exceptions/RansimException.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/exceptions/RansimException.java @@ -22,26 +22,24 @@ package org.onap.ransim.rest.api.exceptions; public class RansimException extends Throwable { - public RansimException() { - super(); - } - - public RansimException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - - public RansimException(String message, Throwable cause) { - super(message, cause); - } - - public RansimException(String message) { - super(message); - } - - public RansimException(Throwable cause) { - super(cause); - } - - + public RansimException() { + super(); + } + + public RansimException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public RansimException(String message, Throwable cause) { + super(message, cause); + } + + public RansimException(String message) { + super(message); + } + + public RansimException(Throwable cause) { + super(cause); + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java index e185108..881d19b 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java @@ -20,6 +20,8 @@ package org.onap.ransim.rest.api.handler; +import com.google.gson.Gson; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -32,6 +34,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; + import javax.websocket.Session; import org.apache.log4j.Logger; @@ -60,392 +63,355 @@ import org.onap.ransim.websocket.server.RansimWebSocketServer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.google.gson.Gson; @Service public class RansimPciHandler { - - static Logger log = Logger.getLogger(RansimPciHandler.class - .getName()); - - @Autowired - RansimRepositoryService ransimRepo ; - - @Autowired - RansimControllerServices rscServices; - - @Autowired - RANSliceConfigService ranSliceConfigService; - - static Map<String, String> globalFmCellIdUuidMap = new ConcurrentHashMap<String, String>(); - static Map<String, String> globalPmCellIdUuidMap = new ConcurrentHashMap<String, String>(); - - Set<String> cellsWithIssues = new HashSet<>(); - - List<PmParameters> pmParameters = new ArrayList<PmParameters>(); - int next = 0; - - - - public FmAlarmInfo setCollisionConfusionFromFile(String cellNodeId) { - - FmAlarmInfo result = new FmAlarmInfo(); - - try { - - boolean collisionDetected = false; - boolean confusionDetected = false; - List<Long> nbrPcis = new ArrayList<Long>(); - List<Long> ConfusionPcis = new ArrayList<Long>(); - int collisionCount = 0; - int confusionCount = 0; - CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId); - log.info("Setting confusion/collision for Cell :" + cellNodeId); - - GetNeighborList cellNbrDetails = generateNeighborList(cellNodeId); - - for (CellDetails firstLevelNbr : cellNbrDetails.getCellsWithHo()) { - if (nbrPcis - .contains((Long)firstLevelNbr.getPhysicalCellId())) { - confusionDetected = true; - if (ConfusionPcis.contains(firstLevelNbr - .getPhysicalCellId())) { - confusionCount++; - } else { - ConfusionPcis.add(firstLevelNbr.getPhysicalCellId()); - confusionCount = confusionCount + 2; - } - - } else { - nbrPcis.add((Long)firstLevelNbr.getPhysicalCellId()); - } - - if (currentCell.getPhysicalCellId() == firstLevelNbr - .getPhysicalCellId()) { - collisionDetected = true; - collisionCount++; - } - } - - currentCell.setPciCollisionDetected(collisionDetected); - currentCell.setPciConfusionDetected(confusionDetected); - - if (!currentCell.isPciCollisionDetected() - && !currentCell.isPciConfusionDetected()) { - currentCell.setColor("#BFBFBF"); // GREY - No Issues - result.setProblem("No Issues"); - } else if (currentCell.isPciCollisionDetected() - && currentCell.isPciConfusionDetected()) { - currentCell.setColor("#C30000"); // BROWN - Cell has both - // collision & confusion - result.setProblem("CollisionAndConfusion"); - - } else if (currentCell.isPciCollisionDetected()) { - currentCell.setColor("#FF0000"); // RED - Cell has collision - result.setProblem("Collision"); - - } else if (currentCell.isPciConfusionDetected()) { - currentCell.setColor("#E88B00"); // ORANGE - Cell has confusion - result.setProblem("Confusion"); - - } else { - currentCell.setColor("#BFBFBF"); // GREY - No Issues - result.setProblem("No Issues"); - } - - result.setCollisionCount("" + collisionCount); - result.setConfusionCount("" + confusionCount); - - ransimRepo.mergeCellDetails(currentCell); - - return result; - - } catch (Exception e2) { - log.info("setCollisionConfusionFromFile :", e2); - - return null; - } - - } - - /** - * Generates separate list of neighbors with and without hand-off for a - * cell. - * - * @param nodeId - * Node Id of cell for which the neighbor list is generated - * @return Returns GetNeighborList object - */ - public GetNeighborList generateNeighborList(String nodeId) { - - - try { - log.info("inside generateNeighborList for: " + nodeId); - CellNeighbor neighborList = ransimRepo.getCellNeighbor(nodeId); - GetNeighborList result = new GetNeighborList(); - neighborList.display(); - List<CellDetails> cellsWithNoHO = new ArrayList<CellDetails>(); - List<CellDetails> cellsWithHO = new ArrayList<CellDetails>(); - - List<NeighborDetails> nbrList = new ArrayList<>(); - if(neighborList != null) { - nbrList.addAll( - neighborList.getNeighborList()); - } - - for (int i = 0; i < nbrList.size(); i++) { - - CellDetails nbr = ransimRepo.getCellDetail(nbrList - .get(i).getNeigbor().getNeighborCell()); - - if (nbrList.get(i).isBlacklisted()) { - cellsWithNoHO.add(nbr); - } else { - cellsWithHO.add(nbr); - } - - } - - result.setNodeId(nodeId); - result.setCellsWithHo(cellsWithHO); - result.setCellsWithNoHo(cellsWithNoHO); - return result; - - } catch (Exception eu) { - log.info("/getNeighborList", eu); - return null; - } - } - - public void checkCollisionAfterModify() { - try { - List<CellDetails> checkCollisionConfusion = ransimRepo.getCellsWithCollisionOrConfusion(); - - for (int i = 0; i < checkCollisionConfusion.size(); i++) { - log.info(checkCollisionConfusion.get(i).getNodeId()); - setCollisionConfusionFromFile(checkCollisionConfusion.get(i) - .getNodeId()); - } - } catch (Exception eu) { - log.info("checkCollisionAfterModify", eu); - } - } - - /** - * It updates the cell with its new neighbor list and PCI and updates the - * change in a database. - * - * @param nodeId - * node Id of the cell - * @param physicalCellId - * PCI number of the cell - * @param newNbrs - * List of new neighbors for the cell - * @param source - * The source from which cell modification has been triggered - * @return returns success or failure message - */ - public int modifyCellFunction(String nodeId, long physicalCellId, - List<NeighborDetails> newNbrs, String source) { - - int result = 111; - - log.info("modifyCellFunction nodeId:" + nodeId + ", physicalCellId:" - + physicalCellId); - CellDetails modifyCell = ransimRepo.getCellDetail(nodeId); - - if (modifyCell != null) { - if (physicalCellId < 0 - || physicalCellId > RansimControllerServices.maxPciValueAllowed) { - log.info("NewPhysicalCellId is empty or invalid"); - result = 400; - } else { - long oldPciId = modifyCell.getPhysicalCellId(); - if (physicalCellId != oldPciId) { - updatePciOperationsTable(nodeId, source, physicalCellId, - oldPciId); - - modifyCell.setPhysicalCellId(physicalCellId); - ransimRepo.mergeCellDetails(modifyCell); - } - - CellNeighbor neighbors = ransimRepo.getCellNeighbor(nodeId); - List<NeighborDetails> oldNbrList = new ArrayList<NeighborDetails>( - neighbors.getNeighborList()); - List<NeighborDetails> oldNbrListWithHo = new ArrayList<NeighborDetails>(); - - for (NeighborDetails cell : oldNbrList) { - if (!cell.isBlacklisted()) { - oldNbrListWithHo.add(cell); - } - } - - boolean flag = false; - - List<NeighborDetails> addedNbrs = new ArrayList<NeighborDetails>(); - List<NeighborDetails> deletedNbrs = new ArrayList<NeighborDetails>(); - - String nbrsDel = ""; - - List<String> oldNbrsArr = new ArrayList<String>(); - for (NeighborDetails cell : oldNbrListWithHo) { - oldNbrsArr.add(cell.getNeigbor().getNeighborCell()); - } - - List<String> newNbrsArr = new ArrayList<String>(); - for (NeighborDetails cell : newNbrs) { - newNbrsArr.add(cell.getNeigbor().getNeighborCell()); - } - - for (NeighborDetails cell : oldNbrListWithHo) { - - if (!newNbrsArr.contains(cell.getNeigbor() - .getNeighborCell())) { - if (!flag) { - flag = true; - } - deletedNbrs.add(cell); - if (nbrsDel == "") { - nbrsDel = cell.getNeigbor().getNeighborCell(); - } else { - nbrsDel += "," - + cell.getNeigbor().getNeighborCell(); - } - log.info("deleted cell: " - + cell.getNeigbor().getNeighborCell() - + cell.isBlacklisted()); - - } - } - - String nbrsAdd = ""; - - for (NeighborDetails cell : newNbrs) { - if (cell.isBlacklisted()) { - addedNbrs.add(cell); - } else { - if (!oldNbrsArr.contains(cell.getNeigbor() - .getNeighborCell())) { - addedNbrs.add(cell); - if (nbrsAdd == "") { - nbrsAdd = cell.getNeigbor().getNeighborCell(); - } else { - nbrsAdd += "," - + cell.getNeigbor().getNeighborCell(); - } - log.info("added cell: " - + cell.getNeigbor().getNeighborCell() - + cell.isBlacklisted()); - } - } - - } - List<NeighborDetails> newNeighborList = new ArrayList<NeighborDetails>( - oldNbrList); - for (NeighborDetails cell : deletedNbrs) { - NeighborDetails removeHo = new NeighborDetails( - cell.getNeigbor(), true); - ransimRepo.mergeNeighborDetails(removeHo); - newNeighborList.add(removeHo); - } - - for (NeighborDetails cell : addedNbrs) { - ransimRepo.mergeNeighborDetails(cell); - newNeighborList.add(cell); - } - - if (!flag) { - if (newNbrs.size() != oldNbrList.size()) { - flag = true; - } - } - - if (flag) { - updateNbrsOperationsTable(nodeId, source, nbrsAdd, nbrsDel); - } - - if (newNbrs != null) { - neighbors.getNeighborList().clear(); - Set<NeighborDetails> updatedNbrList = new HashSet<NeighborDetails>( - newNeighborList); - neighbors.setNeighborList(updatedNbrList); - ransimRepo.mergeCellNeighbor(neighbors); - } - - generateFmData(source, modifyCell, newNeighborList); - - result = 200; - } - - - } else { - result = 400; - } - - return result; - } - - public void checkCellsWithIssue() { - - - try { - - for (String id : cellsWithIssues) { - CellDetails currentCell = ransimRepo.getCellDetail(id); - FmMessage fmDataMessage = new FmMessage(); - List<EventFm> data = new ArrayList<EventFm>(); - - if (!currentCell.isPciCollisionDetected()) { - if (!currentCell.isPciConfusionDetected()) { - - cellsWithIssues.remove(id); - CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm(); - FaultFields faultFields = new FaultFields(); - - commonEventHeader.setStartEpochMicrosec(System - .currentTimeMillis() * 1000); - commonEventHeader - .setSourceName(currentCell.getNodeId()); - commonEventHeader.setReportingEntityName(currentCell - .getServerId()); - String uuid = globalFmCellIdUuidMap.get(currentCell - .getNodeId()); - commonEventHeader.setSourceUuid(uuid); - - faultFields - .setAlarmCondition("RanPciCollisionConfusionOccurred"); - faultFields.setEventSeverity("NORMAL"); - faultFields.setEventSourceType("other"); - faultFields.setSpecificProblem("Problem Solved"); - - commonEventHeader.setLastEpochMicrosec(System - .currentTimeMillis() * 1000); - - EventFm event = new EventFm(); - event.setCommonEventHeader(commonEventHeader); - event.setFaultFields(faultFields); - - data.add(event); - } - } - - fmDataMessage.setFmEventList(data); - - if (!data.isEmpty()) { - sendFmData(currentCell.getServerId(), fmDataMessage); - } - - } - - } catch (Exception eu) { - log.error("Exception:", eu); - } - } - - public void updatePciOperationsTable(String nodeId, String source, long physicalCellId, long oldPciId) { - + + static Logger log = Logger.getLogger(RansimPciHandler.class.getName()); + + @Autowired + RansimRepositoryService ransimRepo; + + @Autowired + RansimControllerServices rscServices; + + @Autowired + RANSliceConfigService ranSliceConfigService; + + static Map<String, String> globalFmCellIdUuidMap = new ConcurrentHashMap<String, String>(); + static Map<String, String> globalPmCellIdUuidMap = new ConcurrentHashMap<String, String>(); + + Set<String> cellsWithIssues = new HashSet<>(); + + List<PmParameters> pmParameters = new ArrayList<PmParameters>(); + int next = 0; + + public FmAlarmInfo setCollisionConfusionFromFile(String cellNodeId) { + + FmAlarmInfo result = new FmAlarmInfo(); + + try { + + boolean collisionDetected = false; + boolean confusionDetected = false; + List<Long> nbrPcis = new ArrayList<Long>(); + List<Long> ConfusionPcis = new ArrayList<Long>(); + int collisionCount = 0; + int confusionCount = 0; + CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId); + log.info("Setting confusion/collision for Cell :" + cellNodeId); + + GetNeighborList cellNbrDetails = generateNeighborList(cellNodeId); + + for (CellDetails firstLevelNbr : cellNbrDetails.getCellsWithHo()) { + if (nbrPcis.contains((Long) firstLevelNbr.getPhysicalCellId())) { + confusionDetected = true; + if (ConfusionPcis.contains(firstLevelNbr.getPhysicalCellId())) { + confusionCount++; + } else { + ConfusionPcis.add(firstLevelNbr.getPhysicalCellId()); + confusionCount = confusionCount + 2; + } + + } else { + nbrPcis.add((Long) firstLevelNbr.getPhysicalCellId()); + } + + if (currentCell.getPhysicalCellId() == firstLevelNbr.getPhysicalCellId()) { + collisionDetected = true; + collisionCount++; + } + } + + currentCell.setPciCollisionDetected(collisionDetected); + currentCell.setPciConfusionDetected(confusionDetected); + + if (!currentCell.isPciCollisionDetected() && !currentCell.isPciConfusionDetected()) { + currentCell.setColor("#BFBFBF"); // GREY - No Issues + result.setProblem("No Issues"); + } else if (currentCell.isPciCollisionDetected() && currentCell.isPciConfusionDetected()) { + currentCell.setColor("#C30000"); // BROWN - Cell has both + // collision & confusion + result.setProblem("CollisionAndConfusion"); + + } else if (currentCell.isPciCollisionDetected()) { + currentCell.setColor("#FF0000"); // RED - Cell has collision + result.setProblem("Collision"); + + } else if (currentCell.isPciConfusionDetected()) { + currentCell.setColor("#E88B00"); // ORANGE - Cell has confusion + result.setProblem("Confusion"); + + } else { + currentCell.setColor("#BFBFBF"); // GREY - No Issues + result.setProblem("No Issues"); + } + + result.setCollisionCount("" + collisionCount); + result.setConfusionCount("" + confusionCount); + + ransimRepo.mergeCellDetails(currentCell); + + return result; + + } catch (Exception e2) { + log.info("setCollisionConfusionFromFile :", e2); + + return null; + } + + } + + /** + * Generates separate list of neighbors with and without hand-off for a + * cell. + * + * @param nodeId + * Node Id of cell for which the neighbor list is generated + * @return Returns GetNeighborList object + */ + public GetNeighborList generateNeighborList(String nodeId) { + + try { + log.info("inside generateNeighborList for: " + nodeId); + CellNeighbor neighborList = ransimRepo.getCellNeighbor(nodeId); + GetNeighborList result = new GetNeighborList(); + neighborList.display(); + List<CellDetails> cellsWithNoHO = new ArrayList<CellDetails>(); + List<CellDetails> cellsWithHO = new ArrayList<CellDetails>(); + + List<NeighborDetails> nbrList = new ArrayList<>(); + if (neighborList != null) { + nbrList.addAll(neighborList.getNeighborList()); + } + + for (int i = 0; i < nbrList.size(); i++) { + + CellDetails nbr = ransimRepo.getCellDetail(nbrList.get(i).getNeigbor().getNeighborCell()); + + if (nbrList.get(i).isBlacklisted()) { + cellsWithNoHO.add(nbr); + } else { + cellsWithHO.add(nbr); + } + + } + + result.setNodeId(nodeId); + result.setCellsWithHo(cellsWithHO); + result.setCellsWithNoHo(cellsWithNoHO); + return result; + + } catch (Exception eu) { + log.info("/getNeighborList", eu); + return null; + } + } + + public void checkCollisionAfterModify() { + try { + List<CellDetails> checkCollisionConfusion = ransimRepo.getCellsWithCollisionOrConfusion(); + + for (int i = 0; i < checkCollisionConfusion.size(); i++) { + log.info(checkCollisionConfusion.get(i).getNodeId()); + setCollisionConfusionFromFile(checkCollisionConfusion.get(i).getNodeId()); + } + } catch (Exception eu) { + log.info("checkCollisionAfterModify", eu); + } + } + + /** + * It updates the cell with its new neighbor list and PCI and updates the + * change in a database. + * + * @param nodeId + * node Id of the cell + * @param physicalCellId + * PCI number of the cell + * @param newNbrs + * List of new neighbors for the cell + * @param source + * The source from which cell modification has been triggered + * @return returns success or failure message + */ + public int modifyCellFunction(String nodeId, long physicalCellId, List<NeighborDetails> newNbrs, String source) { + + int result = 111; + + log.info("modifyCellFunction nodeId:" + nodeId + ", physicalCellId:" + physicalCellId); + CellDetails modifyCell = ransimRepo.getCellDetail(nodeId); + + if (modifyCell != null) { + if (physicalCellId < 0 || physicalCellId > RansimControllerServices.maxPciValueAllowed) { + log.info("NewPhysicalCellId is empty or invalid"); + result = 400; + } else { + long oldPciId = modifyCell.getPhysicalCellId(); + if (physicalCellId != oldPciId) { + updatePciOperationsTable(nodeId, source, physicalCellId, oldPciId); + + modifyCell.setPhysicalCellId(physicalCellId); + ransimRepo.mergeCellDetails(modifyCell); + } + + CellNeighbor neighbors = ransimRepo.getCellNeighbor(nodeId); + List<NeighborDetails> oldNbrList = new ArrayList<NeighborDetails>(neighbors.getNeighborList()); + List<NeighborDetails> oldNbrListWithHo = new ArrayList<NeighborDetails>(); + + for (NeighborDetails cell : oldNbrList) { + if (!cell.isBlacklisted()) { + oldNbrListWithHo.add(cell); + } + } + + boolean flag = false; + + List<NeighborDetails> addedNbrs = new ArrayList<NeighborDetails>(); + List<NeighborDetails> deletedNbrs = new ArrayList<NeighborDetails>(); + + String nbrsDel = ""; + + List<String> oldNbrsArr = new ArrayList<String>(); + for (NeighborDetails cell : oldNbrListWithHo) { + oldNbrsArr.add(cell.getNeigbor().getNeighborCell()); + } + + List<String> newNbrsArr = new ArrayList<String>(); + for (NeighborDetails cell : newNbrs) { + newNbrsArr.add(cell.getNeigbor().getNeighborCell()); + } + + for (NeighborDetails cell : oldNbrListWithHo) { + + if (!newNbrsArr.contains(cell.getNeigbor().getNeighborCell())) { + if (!flag) { + flag = true; + } + deletedNbrs.add(cell); + if (nbrsDel == "") { + nbrsDel = cell.getNeigbor().getNeighborCell(); + } else { + nbrsDel += "," + cell.getNeigbor().getNeighborCell(); + } + log.info("deleted cell: " + cell.getNeigbor().getNeighborCell() + cell.isBlacklisted()); + + } + } + + String nbrsAdd = ""; + + for (NeighborDetails cell : newNbrs) { + if (cell.isBlacklisted()) { + addedNbrs.add(cell); + } else { + if (!oldNbrsArr.contains(cell.getNeigbor().getNeighborCell())) { + addedNbrs.add(cell); + if (nbrsAdd == "") { + nbrsAdd = cell.getNeigbor().getNeighborCell(); + } else { + nbrsAdd += "," + cell.getNeigbor().getNeighborCell(); + } + log.info("added cell: " + cell.getNeigbor().getNeighborCell() + cell.isBlacklisted()); + } + } + + } + List<NeighborDetails> newNeighborList = new ArrayList<NeighborDetails>(oldNbrList); + for (NeighborDetails cell : deletedNbrs) { + NeighborDetails removeHo = new NeighborDetails(cell.getNeigbor(), true); + ransimRepo.mergeNeighborDetails(removeHo); + newNeighborList.add(removeHo); + } + + for (NeighborDetails cell : addedNbrs) { + ransimRepo.mergeNeighborDetails(cell); + newNeighborList.add(cell); + } + + if (!flag) { + if (newNbrs.size() != oldNbrList.size()) { + flag = true; + } + } + + if (flag) { + updateNbrsOperationsTable(nodeId, source, nbrsAdd, nbrsDel); + } + + if (newNbrs != null) { + neighbors.getNeighborList().clear(); + Set<NeighborDetails> updatedNbrList = new HashSet<NeighborDetails>(newNeighborList); + neighbors.setNeighborList(updatedNbrList); + ransimRepo.mergeCellNeighbor(neighbors); + } + + generateFmData(source, modifyCell, newNeighborList); + + result = 200; + } + + } else { + result = 400; + } + + return result; + } + + public void checkCellsWithIssue() { + + try { + + for (String id : cellsWithIssues) { + CellDetails currentCell = ransimRepo.getCellDetail(id); + FmMessage fmDataMessage = new FmMessage(); + List<EventFm> data = new ArrayList<EventFm>(); + + if (!currentCell.isPciCollisionDetected()) { + if (!currentCell.isPciConfusionDetected()) { + + cellsWithIssues.remove(id); + CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm(); + FaultFields faultFields = new FaultFields(); + + commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + commonEventHeader.setSourceName(currentCell.getNodeId()); + commonEventHeader.setReportingEntityName(currentCell.getServerId()); + String uuid = globalFmCellIdUuidMap.get(currentCell.getNodeId()); + commonEventHeader.setSourceUuid(uuid); + + faultFields.setAlarmCondition("RanPciCollisionConfusionOccurred"); + faultFields.setEventSeverity("NORMAL"); + faultFields.setEventSourceType("other"); + faultFields.setSpecificProblem("Problem Solved"); + + commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + + EventFm event = new EventFm(); + event.setCommonEventHeader(commonEventHeader); + event.setFaultFields(faultFields); + + data.add(event); + } + } + + fmDataMessage.setFmEventList(data); + + if (!data.isEmpty()) { + sendFmData(currentCell.getServerId(), fmDataMessage); + } + + } + + } catch (Exception eu) { + log.error("Exception:", eu); + } + } + + public void updatePciOperationsTable(String nodeId, String source, long physicalCellId, long oldPciId) { + OperationLog operationLog = new OperationLog(); - + operationLog.setNodeId(nodeId); operationLog.setFieldName("PCID"); operationLog.setOperation("Modify"); @@ -454,510 +420,481 @@ public class RansimPciHandler { operationLog.setMessage("PCID value changed from " + oldPciId + " to " + physicalCellId); ransimRepo.mergeOperationLog(operationLog); } - + public void updateNbrsOperationsTable(String nodeId, String source, String addedNbrs, String deletedNbrs) { - + OperationLog operationLogNbrChng = new OperationLog(); operationLogNbrChng.setNodeId(nodeId); operationLogNbrChng.setFieldName("Neighbors"); operationLogNbrChng.setOperation("Modify"); operationLogNbrChng.setSource(source); - + log.info(" Neighbors added " + addedNbrs + "."); log.info(" Neighbors removed " + deletedNbrs + "."); String message = ""; - if(!addedNbrs.equals("")){ - message += " Neighbors added " + addedNbrs + "." ; + if (!addedNbrs.equals("")) { + message += " Neighbors added " + addedNbrs + "."; } - - if(!deletedNbrs.equals("")){ - message += " Neighbors removed " + deletedNbrs + "." ; + + if (!deletedNbrs.equals("")) { + message += " Neighbors removed " + deletedNbrs + "."; } - + operationLogNbrChng.setMessage(message); operationLogNbrChng.setTime(System.currentTimeMillis()); ransimRepo.mergeOperationLog(operationLogNbrChng); } - - /** - * Sends PM message to the netconf agent through the websocket server. - * - * @param serverId - * Netconf agent - Server ID to which the message is sent. - * @param pmMessage - * PM message to be sent. - */ - void sendPmdata(String serverId, String pmMessage) { - - log.info("Sending PM message to netconf agent"); - - String ipPort = RansimControllerServices.serverIdIpPortMapping.get(serverId); - - if (ipPort != null && !ipPort.trim().equals("")) { - - if (ipPort != null && !ipPort.trim().equals("")) { - - Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); - log.info("PM message. Netconf agent IP:" + ipPort); - if (clSess != null) { - RansimWebSocketServer.sendPmMessage(pmMessage, clSess); - log.info("Pm Data jsonStr: " + pmMessage); - log.info("PM message sent to netconf agent"); - } else { - log.info("No client session for " + ipPort); - } - } else { - log.info("Pm message not sent, ipPort is null"); - } - } else { - - log.info("Pm message not sent, ipPort is null. Server Id: " - + serverId); - } - - } - - /** - * - * Reads the values PM parameter values from a dump file. - * - */ - public void readPmParameters() { - - File dumpFile = null; - PmDataDump pmDump = null; - String jsonString = ""; - dumpFile = new File("PM_Kpi_Data.json"); - - BufferedReader br = null; - - try { - log.info("Reading dump file"); - br = new BufferedReader(new FileReader(dumpFile)); - - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - - while (line != null) { - sb.append(line); - sb.append("\n"); - line = br.readLine(); - } - jsonString = sb.toString(); - - pmDump = new Gson().fromJson(jsonString, PmDataDump.class); - log.info("Dump value: " - + pmDump.getKpiDump().get(0).getParameter1()); - pmParameters = new ArrayList<PmParameters>(pmDump.getKpiDump()); - - } catch (Exception eu) { - log.info("Exception: ", eu); - } - } - - private static String getUuid() { - return UUID.randomUUID().toString(); - } - - /** - * Sets values for all the parameters in the PM message - * - * @param nodeIdBad - * List of node Ids with bad performance values - * @param nodeIdPoor - * List of node Ids with poor performance values - * @return It returns the pm message - */ - @Transactional - public List<String> generatePmData(String nodeIdBad, String nodeIdPoor) { - - List<String> result = new ArrayList<>(); - - String parameter1 = ""; - String successValue1 = ""; - String badValue1 = ""; - String poorValue1 = ""; - String parameter2 = ""; - String successValue2 = ""; - String badValue2 = ""; - String poorValue2 = ""; - - try { - - if (next >= pmParameters.size()) { - next = 0; - log.info("next : " + next); - } - try { - log.info("next : " + next); - parameter1 = pmParameters.get(next).getParameter1(); - successValue1 = pmParameters.get(next).getSuccessValue1(); - badValue1 = pmParameters.get(next).getBadValue1(); - poorValue1 = pmParameters.get(next).getPoorValue1(); - parameter2 = pmParameters.get(next).getParameter2(); - successValue2 = pmParameters.get(next).getSuccessValue2(); - badValue2 = pmParameters.get(next).getBadValue2(); - poorValue2 = pmParameters.get(next).getPoorValue2(); - next++; - } catch (Exception e) { - log.info("Exception: ", e); - } - - List<NetconfServers> cnl = ransimRepo.getNetconfServersList(); - log.debug("obtained data from db"); - String[] cellIdsBad = null; - String[] cellIdsPoor = null; - Set<String> nodeIdsBad = new HashSet<String>(); - Set<String> nodeIdsPoor = new HashSet<String>(); - - if (nodeIdBad != null) { - cellIdsBad = nodeIdBad.split(","); - for (int a = 0; a < cellIdsBad.length; a++) { - nodeIdsBad.add(cellIdsBad[a].trim()); - } - } - if (nodeIdPoor != null) { - cellIdsPoor = nodeIdPoor.split(","); - for (int a = 0; a < cellIdsPoor.length; a++) { - nodeIdsPoor.add(cellIdsPoor[a].trim()); - } - } - - for (int i = 0; i < cnl.size(); i++) { - - long startTime = System.currentTimeMillis(); - List<CellDetails> cellList = new ArrayList<CellDetails>(cnl - .get(i).getCells()); - List<EventPm> data = new ArrayList<EventPm>(); - - for (int j = 0; j < cellList.size(); j++) { - - long startTimeCell = System.currentTimeMillis(); - String nodeId = cellList.get(j).getNodeId(); - EventPm event = new EventPm(); - CommonEventHeaderPm commonEventHeader = new CommonEventHeaderPm(); - commonEventHeader.setSourceName(nodeId); - commonEventHeader.setStartEpochMicrosec(System - .currentTimeMillis() * 1000); - String uuid = globalPmCellIdUuidMap.get(nodeId); - if (uuid == null) { - uuid = getUuid(); - globalPmCellIdUuidMap.put(nodeId, uuid); - } - commonEventHeader.setSourceUuid(uuid); - - Measurement measurement = new Measurement(); - measurement.setMeasurementInterval(180); - - GetNeighborList cellNbrList = generateNeighborList(nodeId); - - long startTimeCheckBadPoor = System.currentTimeMillis(); - - boolean checkBad = false; - boolean checkPoor = false; - int countBad = 0; - int countPoor = 0; - - if (nodeIdsBad.contains(nodeId)) { - checkBad = true; - countBad = (int) (cellNbrList.getCellsWithHo().size() * 0.2); - } - if (nodeIdsPoor.contains(nodeId)) { - checkPoor = true; - countPoor = (int) (cellNbrList.getCellsWithHo().size() * 0.2); - } - - long endTimeCheckBadPoor = System.currentTimeMillis(); - log.debug("Time taken CheckBadPoor : " + (endTimeCheckBadPoor - startTimeCheckBadPoor)); - List<AdditionalMeasurements> additionalMeasurements = new ArrayList<AdditionalMeasurements>(); - if (checkPoor || checkBad) { - - Collections.sort(cellNbrList.getCellsWithHo()); - - for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) { - AdditionalMeasurements addMsmnt = new AdditionalMeasurements(); - addMsmnt.setName(cellNbrList.getCellsWithHo() - .get(k).getNodeId()); - Map<String, String> hashMap = new HashMap<String, String>(); - hashMap.put("networkId", cellNbrList - .getCellsWithHo().get(k).getNetworkId()); - - hashMap.put(parameter1, successValue1); - - if (checkBad == true) { - - if (countBad > 0) { - log.info("countBad: " + countBad); - hashMap.put(parameter2, badValue2); - countBad--; - } else { - hashMap.put(parameter2, successValue2); - } - - } else if (checkPoor == true) { - if (countPoor > 0) { - log.info("countBad: " + countPoor); - hashMap.put(parameter2, poorValue2); - countPoor--; - } else { - hashMap.put(parameter2, successValue2); - } - - } - - addMsmnt.setHashMap(hashMap); - - additionalMeasurements.add(addMsmnt); - - } - } else { - for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) { - AdditionalMeasurements addMsmnt = new AdditionalMeasurements(); - addMsmnt.setName(cellNbrList.getCellsWithHo() - .get(k).getNodeId()); - Map<String, String> hashMap = new HashMap<String, String>(); - - hashMap.put("networkId", cellNbrList - .getCellsWithHo().get(k).getNetworkId()); - - hashMap.put(parameter1, successValue1); - - hashMap.put(parameter2, successValue2); - - addMsmnt.setHashMap(hashMap); - additionalMeasurements.add(addMsmnt); - } - } - - commonEventHeader.setLastEpochMicrosec(System - .currentTimeMillis() * 1000); - measurement - .setAdditionalMeasurements(additionalMeasurements); - - event.setCommonEventHeader(commonEventHeader); - event.setMeasurement(measurement); - - data.add(event); - long endTimeCell = System.currentTimeMillis(); - log.debug("Time taken to Process Cell list : " + (endTimeCell - startTimeCell)); - } - - long endTime = System.currentTimeMillis(); - log.info("Time taken for generating PM data for " - + cnl.get(i).getServerId() + " : " - + (endTime - startTime)); - PmMessage msg = new PmMessage(); - - if (data.size() > 0) { - msg.setEventPmList(data); - Gson gson = new Gson(); - String jsonStr = gson.toJson(msg); - sendPmdata(cnl.get(i).getServerId(), jsonStr); - - result.add(jsonStr); - } - - } - } catch (Exception e) { - log.info("Exception in string builder", e); - } - - return result; - } - - /** - * Sets the value for all fields in the FM data for individual cell. - * - * @param networkId - * Network Id of the cell - * @param ncServer - * Server Id of the cell - * @param cellId - * Node Id of the cell - * @param issue - * Contains the collision/confusion details of the cess - * @return returns EventFm object, with all the necessary parameters. - */ - public static EventFm setEventFm(String networkId, String ncServer, - String cellId, FmAlarmInfo issue) { - - log.info("Inside generate FmData"); - EventFm event = new EventFm(); - - try { - - CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm(); - FaultFields faultFields = new FaultFields(); - - commonEventHeader - .setStartEpochMicrosec(System.currentTimeMillis() * 1000); - commonEventHeader.setSourceName(cellId); - commonEventHeader.setReportingEntityName(ncServer); - - String uuid = globalFmCellIdUuidMap.get(cellId); - if (uuid == null) { - uuid = getUuid(); - globalFmCellIdUuidMap.put(cellId, uuid); - } - commonEventHeader.setSourceUuid(uuid); - - if (issue.getProblem().equals("Collision") - || issue.getProblem().equals("Confusion") - || issue.getProblem().equals("CollisionAndConfusion")) { - faultFields - .setAlarmCondition("RanPciCollisionConfusionOccurred"); - faultFields.setEventSeverity("CRITICAL"); - faultFields.setEventSourceType("other"); - faultFields.setSpecificProblem(issue.getProblem()); - - Map<String, String> alarmAdditionalInformation = new HashMap<String, String>(); - alarmAdditionalInformation.put("networkId", networkId); - alarmAdditionalInformation.put("collisions", - issue.getCollisionCount()); - alarmAdditionalInformation.put("confusions", - issue.getConfusionCount()); - - faultFields - .setAlarmAdditionalInformation(alarmAdditionalInformation); - - } - commonEventHeader - .setLastEpochMicrosec(System.currentTimeMillis() * 1000); - - event.setCommonEventHeader(commonEventHeader); - event.setFaultFields(faultFields); - - } catch (Exception e) { - log.info("Exception: ", e); - } - - return event; - - } - - /** - * It checks if the cell or any of its neighbors have collision/confusion - * issue. If there are any issues it generates the FM data for the entire - * cluster - * - * @param source - * The source from which the cell modification has been - * triggered. - * @param cell - * Details of the given cell. - * @param newNeighborList - * Neighbor list of the given cell. - */ - public void generateFmData(String source, CellDetails cell, - List<NeighborDetails> newNeighborList) { - - List<EventFm> listCellIssue = new ArrayList<EventFm>(); - Set<String> ncs = new HashSet<>(); - log.info("Generating Fm data"); - FmAlarmInfo op1 = setCollisionConfusionFromFile(cell.getNodeId()); - - if (source.equals("GUI")) { - if (op1.getProblem().equals("CollisionAndConfusion") - || op1.getProblem().equals("Collision") - || op1.getProblem().equals("Confusion")) { - log.info("op1: " + op1); - EventFm lci = setEventFm(cell.getNetworkId(), - cell.getServerId(), cell.getNodeId(), op1); - listCellIssue.add(lci); - ncs.add(cell.getServerId()); - log.info("Generating Fm data for: " + cell.getNodeId()); - } - } - - for (NeighborDetails cd : newNeighborList) { - FmAlarmInfo op2 = setCollisionConfusionFromFile(cd.getNeigbor() - .getNeighborCell()); - CellDetails nbrCell = ransimRepo.getCellDetail(cd.getNeigbor() - .getNeighborCell()); - - if (source.equals("GUI")) { - if (op2.getProblem().equals("CollisionAndConfusion") - || op2.getProblem().equals("Collision") - || op2.getProblem().equals("Confusion")) { - EventFm lci = setEventFm(nbrCell.getNetworkId(), - nbrCell.getServerId(), nbrCell.getNodeId(), op2); - log.info("FmData added:" + nbrCell.getNodeId()); - listCellIssue.add(lci); - ncs.add(nbrCell.getServerId()); - log.info("Generating Fm data for: " + nbrCell.getNodeId()); - } - } - - } - - if (source.equals("GUI")) { - for (String nc : ncs) { - - FmMessage fmDataMessage = new FmMessage(); - List<EventFm> data = new ArrayList<EventFm>(); - log.info("listCellIssue.size(): " + listCellIssue.size()); - for (EventFm cellIssue : listCellIssue) { - if (cellIssue.getCommonEventHeader() - .getReportingEntityName().equals(nc)) { - data.add(cellIssue); - if (!cellsWithIssues.contains(cellIssue - .getCommonEventHeader().getSourceName())) { - cellsWithIssues.add(cellIssue - .getCommonEventHeader().getSourceName()); - } - - } - } - log.info("data.size(): " + data.size()); - - if (data.size() > 0) { - fmDataMessage.setFmEventList(data); - log.info("Sending FM message: "); - sendFmData(nc, fmDataMessage); - } - - } - } - - } - - /** - * Sends the FM data message to the netconf agent through the ransim - * websocket server. - * - * @param serverId - * server id of the netconf agent - * @param fmDataMessage - * FM message to be sent - */ - public void sendFmData(String serverId, FmMessage fmDataMessage) { - - log.info("inside sendFmData"); - Gson gson = new Gson(); - String jsonStr = gson.toJson(fmDataMessage); - - log.info("Fm Data jsonStr: " + jsonStr); - - String ipPort = RansimControllerServices.serverIdIpPortMapping.get(serverId); - - if (ipPort != null && !ipPort.trim().equals("")) { - - log.info("Connection estabilished with ip: " + ipPort); - if (ipPort != null && !ipPort.trim().equals("")) { - Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); - if (clSess != null) { - log.info("FM message sent."); - RansimWebSocketServer.sendFmMessage(jsonStr, clSess); - } else { - log.info("No client session for " + ipPort); - } - } else { - log.info("No client for " + serverId); - } - } else { - log.info("No client for "); - } - - } + + /** + * Sends PM message to the netconf agent through the websocket server. + * + * @param serverId + * Netconf agent - Server ID to which the message is sent. + * @param pmMessage + * PM message to be sent. + */ + void sendPmdata(String serverId, String pmMessage) { + + log.info("Sending PM message to netconf agent"); + + String ipPort = RansimControllerServices.serverIdIpPortMapping.get(serverId); + + if (ipPort != null && !ipPort.trim().equals("")) { + + if (ipPort != null && !ipPort.trim().equals("")) { + + Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); + log.info("PM message. Netconf agent IP:" + ipPort); + if (clSess != null) { + RansimWebSocketServer.sendPmMessage(pmMessage, clSess); + log.info("Pm Data jsonStr: " + pmMessage); + log.info("PM message sent to netconf agent"); + } else { + log.info("No client session for " + ipPort); + } + } else { + log.info("Pm message not sent, ipPort is null"); + } + } else { + + log.info("Pm message not sent, ipPort is null. Server Id: " + serverId); + } + + } + + /** + * + * Reads the values PM parameter values from a dump file. + * + */ + public void readPmParameters() { + + File dumpFile = null; + PmDataDump pmDump = null; + String jsonString = ""; + dumpFile = new File("PM_Kpi_Data.json"); + + BufferedReader br = null; + + try { + log.info("Reading dump file"); + br = new BufferedReader(new FileReader(dumpFile)); + + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + jsonString = sb.toString(); + + pmDump = new Gson().fromJson(jsonString, PmDataDump.class); + log.info("Dump value: " + pmDump.getKpiDump().get(0).getParameter1()); + pmParameters = new ArrayList<PmParameters>(pmDump.getKpiDump()); + + } catch (Exception eu) { + log.info("Exception: ", eu); + } + } + + private static String getUuid() { + return UUID.randomUUID().toString(); + } + + /** + * Sets values for all the parameters in the PM message + * + * @param nodeIdBad + * List of node Ids with bad performance values + * @param nodeIdPoor + * List of node Ids with poor performance values + * @return It returns the pm message + */ + @Transactional + public List<String> generatePmData(String nodeIdBad, String nodeIdPoor) { + + List<String> result = new ArrayList<>(); + + String parameter1 = ""; + String successValue1 = ""; + String badValue1 = ""; + String poorValue1 = ""; + String parameter2 = ""; + String successValue2 = ""; + String badValue2 = ""; + String poorValue2 = ""; + + try { + + if (next >= pmParameters.size()) { + next = 0; + log.info("next : " + next); + } + try { + log.info("next : " + next); + parameter1 = pmParameters.get(next).getParameter1(); + successValue1 = pmParameters.get(next).getSuccessValue1(); + badValue1 = pmParameters.get(next).getBadValue1(); + poorValue1 = pmParameters.get(next).getPoorValue1(); + parameter2 = pmParameters.get(next).getParameter2(); + successValue2 = pmParameters.get(next).getSuccessValue2(); + badValue2 = pmParameters.get(next).getBadValue2(); + poorValue2 = pmParameters.get(next).getPoorValue2(); + next++; + } catch (Exception e) { + log.info("Exception: ", e); + } + + List<NetconfServers> cnl = ransimRepo.getNetconfServersList(); + log.debug("obtained data from db"); + String[] cellIdsBad = null; + String[] cellIdsPoor = null; + Set<String> nodeIdsBad = new HashSet<String>(); + Set<String> nodeIdsPoor = new HashSet<String>(); + + if (nodeIdBad != null) { + cellIdsBad = nodeIdBad.split(","); + for (int a = 0; a < cellIdsBad.length; a++) { + nodeIdsBad.add(cellIdsBad[a].trim()); + } + } + if (nodeIdPoor != null) { + cellIdsPoor = nodeIdPoor.split(","); + for (int a = 0; a < cellIdsPoor.length; a++) { + nodeIdsPoor.add(cellIdsPoor[a].trim()); + } + } + + for (int i = 0; i < cnl.size(); i++) { + + long startTime = System.currentTimeMillis(); + List<CellDetails> cellList = new ArrayList<CellDetails>(cnl.get(i).getCells()); + List<EventPm> data = new ArrayList<EventPm>(); + + for (int j = 0; j < cellList.size(); j++) { + + long startTimeCell = System.currentTimeMillis(); + String nodeId = cellList.get(j).getNodeId(); + EventPm event = new EventPm(); + CommonEventHeaderPm commonEventHeader = new CommonEventHeaderPm(); + commonEventHeader.setSourceName(nodeId); + commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + String uuid = globalPmCellIdUuidMap.get(nodeId); + if (uuid == null) { + uuid = getUuid(); + globalPmCellIdUuidMap.put(nodeId, uuid); + } + commonEventHeader.setSourceUuid(uuid); + + Measurement measurement = new Measurement(); + measurement.setMeasurementInterval(180); + + GetNeighborList cellNbrList = generateNeighborList(nodeId); + + long startTimeCheckBadPoor = System.currentTimeMillis(); + + boolean checkBad = false; + boolean checkPoor = false; + int countBad = 0; + int countPoor = 0; + + if (nodeIdsBad.contains(nodeId)) { + checkBad = true; + countBad = (int) (cellNbrList.getCellsWithHo().size() * 0.2); + } + if (nodeIdsPoor.contains(nodeId)) { + checkPoor = true; + countPoor = (int) (cellNbrList.getCellsWithHo().size() * 0.2); + } + + long endTimeCheckBadPoor = System.currentTimeMillis(); + log.debug("Time taken CheckBadPoor : " + (endTimeCheckBadPoor - startTimeCheckBadPoor)); + List<AdditionalMeasurements> additionalMeasurements = new ArrayList<AdditionalMeasurements>(); + if (checkPoor || checkBad) { + + Collections.sort(cellNbrList.getCellsWithHo()); + + for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) { + AdditionalMeasurements addMsmnt = new AdditionalMeasurements(); + addMsmnt.setName(cellNbrList.getCellsWithHo().get(k).getNodeId()); + Map<String, String> hashMap = new HashMap<String, String>(); + hashMap.put("networkId", cellNbrList.getCellsWithHo().get(k).getNetworkId()); + + hashMap.put(parameter1, successValue1); + + if (checkBad == true) { + + if (countBad > 0) { + log.info("countBad: " + countBad); + hashMap.put(parameter2, badValue2); + countBad--; + } else { + hashMap.put(parameter2, successValue2); + } + + } else if (checkPoor == true) { + if (countPoor > 0) { + log.info("countBad: " + countPoor); + hashMap.put(parameter2, poorValue2); + countPoor--; + } else { + hashMap.put(parameter2, successValue2); + } + + } + + addMsmnt.setHashMap(hashMap); + + additionalMeasurements.add(addMsmnt); + + } + } else { + for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) { + AdditionalMeasurements addMsmnt = new AdditionalMeasurements(); + addMsmnt.setName(cellNbrList.getCellsWithHo().get(k).getNodeId()); + Map<String, String> hashMap = new HashMap<String, String>(); + + hashMap.put("networkId", cellNbrList.getCellsWithHo().get(k).getNetworkId()); + + hashMap.put(parameter1, successValue1); + + hashMap.put(parameter2, successValue2); + + addMsmnt.setHashMap(hashMap); + additionalMeasurements.add(addMsmnt); + } + } + + commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + measurement.setAdditionalMeasurements(additionalMeasurements); + + event.setCommonEventHeader(commonEventHeader); + event.setMeasurement(measurement); + + data.add(event); + long endTimeCell = System.currentTimeMillis(); + log.debug("Time taken to Process Cell list : " + (endTimeCell - startTimeCell)); + } + + long endTime = System.currentTimeMillis(); + log.info("Time taken for generating PM data for " + cnl.get(i).getServerId() + " : " + + (endTime - startTime)); + PmMessage msg = new PmMessage(); + + if (data.size() > 0) { + msg.setEventPmList(data); + Gson gson = new Gson(); + String jsonStr = gson.toJson(msg); + sendPmdata(cnl.get(i).getServerId(), jsonStr); + + result.add(jsonStr); + } + + } + } catch (Exception e) { + log.info("Exception in string builder", e); + } + + return result; + } + + /** + * Sets the value for all fields in the FM data for individual cell. + * + * @param networkId + * Network Id of the cell + * @param ncServer + * Server Id of the cell + * @param cellId + * Node Id of the cell + * @param issue + * Contains the collision/confusion details of the cess + * @return returns EventFm object, with all the necessary parameters. + */ + public static EventFm setEventFm(String networkId, String ncServer, String cellId, FmAlarmInfo issue) { + + log.info("Inside generate FmData"); + EventFm event = new EventFm(); + + try { + + CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm(); + FaultFields faultFields = new FaultFields(); + + commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + commonEventHeader.setSourceName(cellId); + commonEventHeader.setReportingEntityName(ncServer); + + String uuid = globalFmCellIdUuidMap.get(cellId); + if (uuid == null) { + uuid = getUuid(); + globalFmCellIdUuidMap.put(cellId, uuid); + } + commonEventHeader.setSourceUuid(uuid); + + if (issue.getProblem().equals("Collision") || issue.getProblem().equals("Confusion") + || issue.getProblem().equals("CollisionAndConfusion")) { + faultFields.setAlarmCondition("RanPciCollisionConfusionOccurred"); + faultFields.setEventSeverity("CRITICAL"); + faultFields.setEventSourceType("other"); + faultFields.setSpecificProblem(issue.getProblem()); + + Map<String, String> alarmAdditionalInformation = new HashMap<String, String>(); + alarmAdditionalInformation.put("networkId", networkId); + alarmAdditionalInformation.put("collisions", issue.getCollisionCount()); + alarmAdditionalInformation.put("confusions", issue.getConfusionCount()); + + faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation); + + } + commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + + event.setCommonEventHeader(commonEventHeader); + event.setFaultFields(faultFields); + + } catch (Exception e) { + log.info("Exception: ", e); + } + + return event; + + } + + /** + * It checks if the cell or any of its neighbors have collision/confusion + * issue. If there are any issues it generates the FM data for the entire + * cluster + * + * @param source + * The source from which the cell modification has been + * triggered. + * @param cell + * Details of the given cell. + * @param newNeighborList + * Neighbor list of the given cell. + */ + public void generateFmData(String source, CellDetails cell, List<NeighborDetails> newNeighborList) { + + List<EventFm> listCellIssue = new ArrayList<EventFm>(); + Set<String> ncs = new HashSet<>(); + log.info("Generating Fm data"); + FmAlarmInfo op1 = setCollisionConfusionFromFile(cell.getNodeId()); + + if (source.equals("GUI")) { + if (op1.getProblem().equals("CollisionAndConfusion") || op1.getProblem().equals("Collision") + || op1.getProblem().equals("Confusion")) { + log.info("op1: " + op1); + EventFm lci = setEventFm(cell.getNetworkId(), cell.getServerId(), cell.getNodeId(), op1); + listCellIssue.add(lci); + ncs.add(cell.getServerId()); + log.info("Generating Fm data for: " + cell.getNodeId()); + } + } + + for (NeighborDetails cd : newNeighborList) { + FmAlarmInfo op2 = setCollisionConfusionFromFile(cd.getNeigbor().getNeighborCell()); + CellDetails nbrCell = ransimRepo.getCellDetail(cd.getNeigbor().getNeighborCell()); + + if (source.equals("GUI")) { + if (op2.getProblem().equals("CollisionAndConfusion") || op2.getProblem().equals("Collision") + || op2.getProblem().equals("Confusion")) { + EventFm lci = setEventFm(nbrCell.getNetworkId(), nbrCell.getServerId(), nbrCell.getNodeId(), op2); + log.info("FmData added:" + nbrCell.getNodeId()); + listCellIssue.add(lci); + ncs.add(nbrCell.getServerId()); + log.info("Generating Fm data for: " + nbrCell.getNodeId()); + } + } + + } + + if (source.equals("GUI")) { + for (String nc : ncs) { + + FmMessage fmDataMessage = new FmMessage(); + List<EventFm> data = new ArrayList<EventFm>(); + log.info("listCellIssue.size(): " + listCellIssue.size()); + for (EventFm cellIssue : listCellIssue) { + if (cellIssue.getCommonEventHeader().getReportingEntityName().equals(nc)) { + data.add(cellIssue); + if (!cellsWithIssues.contains(cellIssue.getCommonEventHeader().getSourceName())) { + cellsWithIssues.add(cellIssue.getCommonEventHeader().getSourceName()); + } + + } + } + log.info("data.size(): " + data.size()); + + if (data.size() > 0) { + fmDataMessage.setFmEventList(data); + log.info("Sending FM message: "); + sendFmData(nc, fmDataMessage); + } + + } + } + + } + + /** + * Sends the FM data message to the netconf agent through the ransim + * websocket server. + * + * @param serverId + * server id of the netconf agent + * @param fmDataMessage + * FM message to be sent + */ + public void sendFmData(String serverId, FmMessage fmDataMessage) { + + log.info("inside sendFmData"); + Gson gson = new Gson(); + String jsonStr = gson.toJson(fmDataMessage); + + log.info("Fm Data jsonStr: " + jsonStr); + + String ipPort = RansimControllerServices.serverIdIpPortMapping.get(serverId); + + if (ipPort != null && !ipPort.trim().equals("")) { + + log.info("Connection estabilished with ip: " + ipPort); + if (ipPort != null && !ipPort.trim().equals("")) { + Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); + if (clSess != null) { + log.info("FM message sent."); + RansimWebSocketServer.sendFmMessage(jsonStr, clSess); + } else { + log.info("No client session for " + ipPort); + } + } else { + log.info("No client for " + serverId); + } + } else { + log.info("No client for "); + } + + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimSlicingHandler.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimSlicingHandler.java index c435541..4629fc6 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimSlicingHandler.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimSlicingHandler.java @@ -20,6 +20,8 @@ package org.onap.ransim.rest.api.handler; +import com.google.gson.Gson; + import java.io.File; import java.time.LocalDateTime; import java.util.ArrayList; @@ -27,9 +29,10 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Random; + +import javax.websocket.Session; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; -import javax.websocket.Session; import org.apache.log4j.Logger; import org.onap.ransim.rest.api.services.RANSliceConfigService; @@ -39,9 +42,9 @@ import org.onap.ransim.rest.web.mapper.GNBCUCPModel; import org.onap.ransim.rest.web.mapper.NRCellCUModel; import org.onap.ransim.rest.web.mapper.PLMNInfoModel; import org.onap.ransim.rest.xml.models.*; -import org.onap.ransim.websocket.server.RansimWebSocketServer; import org.onap.ransim.websocket.model.SlicingPmMessage; - +import org.onap.ransim.websocket.server.RansimWebSocketServer; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -49,217 +52,208 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import com.google.gson.Gson; import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.client.RestTemplate; @Service public class RansimSlicingHandler { - - static Logger log = Logger.getLogger(RansimSlicingHandler.class - .getName()); - - @Autowired - RansimRepositoryService ransimRepo ; - - @Autowired - RansimControllerServices rscServices; - - @Autowired - RANSliceConfigService ranSliceConfigService; + static Logger log = Logger.getLogger(RansimSlicingHandler.class.getName()); - public List<String> generateIntelligentSlicingPmData(long startTime, HashMap<String,List<String>> taCells) { - List<String> result = new ArrayList<String>(); - try { - String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/cucp-list"; - List<GNBCUCPModel> gnbcucpModelList = sendGetRequestToConfigDb(requestUrl).getBody(); - long peakEndTime = System.currentTimeMillis() + 360000; - for (int i = 0; i < gnbcucpModelList.size(); i++) { - String gNBName = gnbcucpModelList.get(i).getgNBCUName(); - LocalDateTime beginTime = LocalDateTime.now(); - String beginTimeString = beginTime.toString(); - SlicingPmMessage pmMessage = new SlicingPmMessage(); - pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000); - pmMessage.setSourceName(gNBName); - MeasCollec measCollec = new MeasCollec(beginTimeString); - FileSender fileSender = new FileSender(gNBName); - FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender); - Random r = new Random(); - int jobId = r.nextInt((9999 - 1000) + 1) + 1000; - Job job = new Job(String.valueOf(jobId)); - ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S"); - List<MeasType> measTypeList = new ArrayList<MeasType>(); - int numberOfNssaiType = 1; - HashMap<String, Integer> nssaiInfoMap = new HashMap<String, Integer>(); - for (NRCellCUModel nRCellCUModel : gnbcucpModelList.get(i).getCellCUList()) { - for (PLMNInfoModel pLMNInfoModel : nRCellCUModel.getpLMNInfoList()) { - if (pLMNInfoModel.getsNSSAI().getStatus().equalsIgnoreCase("active")) { - nssaiInfoMap.put(pLMNInfoModel.getsNSSAI().getsNSSAI(), - pLMNInfoModel.getsNSSAI().getConfigData().getMaxNumberOfConns()); - } - } - } - HashMap<String, Integer> nSSAINo = new HashMap<String, Integer>(); - for (java.util.Map.Entry<String, Integer> map : nssaiInfoMap.entrySet()) { - String nssai = map.getKey(); - MeasType mesType1 = new MeasType("SM.PDUSessionSetupReq." + nssai, numberOfNssaiType++); - MeasType mesType2 = new MeasType("SM.PDUSessionSetupSucc." + nssai, numberOfNssaiType++); - measTypeList.add(mesType1); - measTypeList.add(mesType2); - if (numberOfNssaiType == 3) { - MeasType mesTypeFail = new MeasType("SM.PDUSessionSetupFail." + "0", 3); - measTypeList.add(mesTypeFail); - numberOfNssaiType++; - } - nSSAINo.put(nssai,mesType1.getP()); - } - - List<MeasValue> measValueList = new ArrayList<MeasValue>(); - - for (NRCellCUModel nRCellCUModel : gnbcucpModelList.get(i).getCellCUList()) { - List<Result> resultList = new ArrayList<Result>(); - int noOfRequestedSessions = 0; - int successfulSessions = 0; - int failedSessions = 0; - int configData = 0; - double rNumForTotalReq = 0; - int numberOfNssaiValue = 1; //change - for (PLMNInfoModel pLMNInfoModel : nRCellCUModel.getpLMNInfoList()) { - for (java.util.Map.Entry<String, Integer> nssaiMap : nSSAINo.entrySet()) { - if(nssaiMap.getKey().equals(pLMNInfoModel.getsNSSAI().getsNSSAI())) { - configData = pLMNInfoModel.getsNSSAI().getConfigData().getMaxNumberOfConns(); - noOfRequestedSessions = 0; - successfulSessions = 0; - for (java.util.Map.Entry<String, List<String>> taCellMap : taCells.entrySet()) { - for(String cell : taCellMap.getValue()) { - if(Integer.parseInt(cell) == nRCellCUModel.getCellLocalId().intValue()) { - long end = (System.currentTimeMillis()); - if(peakEndTime>end) { - if(taCellMap.getKey().equalsIgnoreCase("TA1") || taCellMap.getKey().equalsIgnoreCase("TA3")) { - rNumForTotalReq = 1.4 + (new Random().nextDouble() * (1.0 - 1.4)); - } else { - rNumForTotalReq = 0.6 + (new Random().nextDouble() * (0.3 - 0.6)); - } - } - else { - rNumForTotalReq = 0.7 + (new Random().nextDouble() * (0.3 - 0.7)); - } - } - } - } + @Autowired + RansimRepositoryService ransimRepo; - double rNumForFs = 0.10 + (new Random().nextDouble() * (0.05 - 0.10)); - double rNumForSs = 0.75 + (new Random().nextDouble()* (0.75 - 0.90)); - noOfRequestedSessions = (int) (configData * rNumForTotalReq); - successfulSessions = (int) (noOfRequestedSessions * rNumForSs); - failedSessions += noOfRequestedSessions - successfulSessions; - numberOfNssaiValue = nssaiMap.getValue(); - Result result1 = new Result(numberOfNssaiValue++, noOfRequestedSessions); - Result result2 = new Result(numberOfNssaiValue++, successfulSessions); - resultList.add(result1); - resultList.add(result2); - if (numberOfNssaiValue == 3) { - numberOfNssaiValue++; - } - if(nRCellCUModel.getpLMNInfoList().indexOf(pLMNInfoModel)+1 == nRCellCUModel.getpLMNInfoList().size()) - { - failedSessions -= failedSessions * rNumForFs; - Result result3 = new Result(3, failedSessions); - resultList.add(result3); - } - } - } - - } + @Autowired + RansimControllerServices rscServices; - MeasValue measValue = new MeasValue(nRCellCUModel.getCellLocalId(), - resultList, false); - measValueList.add(measValue); - } - - ManagedElement managedElement = new ManagedElement("r0.1", gNBName); - LocalDateTime grabularityEndTime = LocalDateTime.now(); - String grabularityEndTimeString = grabularityEndTime.toString(); - GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S"); - MeasInfo measInfo = new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList, - measValueList); - List<MeasInfo> measInfoList = new ArrayList<MeasInfo>(); - measInfoList.add(measInfo); - MeasData measData = new MeasData(managedElement, measInfoList); - List<MeasData> measDataList = new ArrayList<MeasData>(); - measDataList.add(measData); - LocalDateTime endTime = LocalDateTime.now(); - String endTimeString = endTime.toString(); - pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000); - MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString); - FileFooter fileFooter = new FileFooter(measCollecEnd); - MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter, - "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"); - String startDate = beginTimeString.replace(':', '-'); - String endDate = endTimeString.replace(':', '-'); - String fileName = "A" + startDate + "-"+ endDate + "-" + String.valueOf(jobId) + "-" + gNBName+ ".xml"; - pmMessage.setFileName(fileName); - Gson gson = new Gson(); - String pmData = gson.toJson(measCollecFile); - pmMessage.setPmData(pmData); - sendIntelligentSlicingPmData(pmMessage); - } - } - catch (Exception e) { - System.out.println("Exception: " + e); - } - return result; -} + @Autowired + RANSliceConfigService ranSliceConfigService; -public static <T> ResponseEntity<List<GNBCUCPModel>> sendGetRequestToConfigDb(String requestUrl) { - - HttpHeaders headers = new HttpHeaders(); - log.info("sending..."); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - HttpEntity<Void> requestEntity = new HttpEntity<>(headers); - try { - RestTemplate restTemplate = new RestTemplate(); - return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, - new ParameterizedTypeReference<List<GNBCUCPModel>>() { - }); - } - catch (Exception e) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } -} + public List<String> generateIntelligentSlicingPmData(long startTime, HashMap<String, List<String>> taCells) { + List<String> result = new ArrayList<String>(); + try { + String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/cucp-list"; + List<GNBCUCPModel> gnbcucpModelList = sendGetRequestToConfigDb(requestUrl).getBody(); + long peakEndTime = System.currentTimeMillis() + 360000; + for (int i = 0; i < gnbcucpModelList.size(); i++) { + String gNBName = gnbcucpModelList.get(i).getgNBCUName(); + LocalDateTime beginTime = LocalDateTime.now(); + String beginTimeString = beginTime.toString(); + SlicingPmMessage pmMessage = new SlicingPmMessage(); + pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + pmMessage.setSourceName(gNBName); + MeasCollec measCollec = new MeasCollec(beginTimeString); + FileSender fileSender = new FileSender(gNBName); + FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender); + Random r = new Random(); + int jobId = r.nextInt((9999 - 1000) + 1) + 1000; + Job job = new Job(String.valueOf(jobId)); + ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S"); + List<MeasType> measTypeList = new ArrayList<MeasType>(); + int numberOfNssaiType = 1; + HashMap<String, Integer> nssaiInfoMap = new HashMap<String, Integer>(); + for (NRCellCUModel nRCellCUModel : gnbcucpModelList.get(i).getCellCUList()) { + for (PLMNInfoModel pLMNInfoModel : nRCellCUModel.getpLMNInfoList()) { + if (pLMNInfoModel.getsNSSAI().getStatus().equalsIgnoreCase("active")) { + nssaiInfoMap.put(pLMNInfoModel.getsNSSAI().getsNSSAI(), + pLMNInfoModel.getsNSSAI().getConfigData().getMaxNumberOfConns()); + } + } + } + HashMap<String, Integer> nSSAINo = new HashMap<String, Integer>(); + for (java.util.Map.Entry<String, Integer> map : nssaiInfoMap.entrySet()) { + String nssai = map.getKey(); + MeasType mesType1 = new MeasType("SM.PDUSessionSetupReq." + nssai, numberOfNssaiType++); + MeasType mesType2 = new MeasType("SM.PDUSessionSetupSucc." + nssai, numberOfNssaiType++); + measTypeList.add(mesType1); + measTypeList.add(mesType2); + if (numberOfNssaiType == 3) { + MeasType mesTypeFail = new MeasType("SM.PDUSessionSetupFail." + "0", 3); + measTypeList.add(mesTypeFail); + numberOfNssaiType++; + } + nSSAINo.put(nssai, mesType1.getP()); + } + List<MeasValue> measValueList = new ArrayList<MeasValue>(); -public void sendIntelligentSlicingPmData( SlicingPmMessage pmMessage) { + for (NRCellCUModel nRCellCUModel : gnbcucpModelList.get(i).getCellCUList()) { + List<Result> resultList = new ArrayList<Result>(); + int noOfRequestedSessions = 0; + int successfulSessions = 0; + int failedSessions = 0; + int configData = 0; + double rNumForTotalReq = 0; + int numberOfNssaiValue = 1; // change + for (PLMNInfoModel pLMNInfoModel : nRCellCUModel.getpLMNInfoList()) { + for (java.util.Map.Entry<String, Integer> nssaiMap : nSSAINo.entrySet()) { + if (nssaiMap.getKey().equals(pLMNInfoModel.getsNSSAI().getsNSSAI())) { + configData = pLMNInfoModel.getsNSSAI().getConfigData().getMaxNumberOfConns(); + noOfRequestedSessions = 0; + successfulSessions = 0; + for (java.util.Map.Entry<String, List<String>> taCellMap : taCells.entrySet()) { + for (String cell : taCellMap.getValue()) { + if (Integer.parseInt(cell) == nRCellCUModel.getCellLocalId().intValue()) { + long end = (System.currentTimeMillis()); + if (peakEndTime > end) { + if (taCellMap.getKey().equalsIgnoreCase("TA1") + || taCellMap.getKey().equalsIgnoreCase("TA3")) { + rNumForTotalReq = 1.4 + (new Random().nextDouble() * (1.0 - 1.4)); + } else { + rNumForTotalReq = 0.6 + (new Random().nextDouble() * (0.3 - 0.6)); + } + } else { + rNumForTotalReq = 0.7 + (new Random().nextDouble() * (0.3 - 0.7)); + } + } + } + } - log.info("inside sendIntelligentSlicingPmData"); - - Gson gson = new Gson(); - String jsonStr = gson.toJson(pmMessage); + double rNumForFs = 0.10 + (new Random().nextDouble() * (0.05 - 0.10)); + double rNumForSs = 0.75 + (new Random().nextDouble() * (0.75 - 0.90)); + noOfRequestedSessions = (int) (configData * rNumForTotalReq); + successfulSessions = (int) (noOfRequestedSessions * rNumForSs); + failedSessions += noOfRequestedSessions - successfulSessions; + numberOfNssaiValue = nssaiMap.getValue(); + Result result1 = new Result(numberOfNssaiValue++, noOfRequestedSessions); + Result result2 = new Result(numberOfNssaiValue++, successfulSessions); + resultList.add(result1); + resultList.add(result2); + if (numberOfNssaiValue == 3) { + numberOfNssaiValue++; + } + if (nRCellCUModel.getpLMNInfoList().indexOf(pLMNInfoModel) + 1 == nRCellCUModel + .getpLMNInfoList().size()) { + failedSessions -= failedSessions * rNumForFs; + Result result3 = new Result(3, failedSessions); + resultList.add(result3); + } + } + } - log.info("IntelligentSlicingPmData " + jsonStr); + } - String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName()); + MeasValue measValue = new MeasValue(nRCellCUModel.getCellLocalId(), resultList, false); + measValueList.add(measValue); + } - if (ipPort != null && !ipPort.trim().equals("")) { + ManagedElement managedElement = new ManagedElement("r0.1", gNBName); + LocalDateTime grabularityEndTime = LocalDateTime.now(); + String grabularityEndTimeString = grabularityEndTime.toString(); + GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S"); + MeasInfo measInfo = new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList, + measValueList); + List<MeasInfo> measInfoList = new ArrayList<MeasInfo>(); + measInfoList.add(measInfo); + MeasData measData = new MeasData(managedElement, measInfoList); + List<MeasData> measDataList = new ArrayList<MeasData>(); + measDataList.add(measData); + LocalDateTime endTime = LocalDateTime.now(); + String endTimeString = endTime.toString(); + pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString); + FileFooter fileFooter = new FileFooter(measCollecEnd); + MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter, + "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"); + String startDate = beginTimeString.replace(':', '-'); + String endDate = endTimeString.replace(':', '-'); + String fileName = + "A" + startDate + "-" + endDate + "-" + String.valueOf(jobId) + "-" + gNBName + ".xml"; + pmMessage.setFileName(fileName); + Gson gson = new Gson(); + String pmData = gson.toJson(measCollecFile); + pmMessage.setPmData(pmData); + sendIntelligentSlicingPmData(pmMessage); + } + } catch (Exception e) { + System.out.println("Exception: " + e); + } + return result; + } - log.info("Connection estabilished with ip: " + ipPort); - if (ipPort != null && !ipPort.trim().equals("")) { - Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); - if (clSess != null) { - log.info("PM Data message sent."); - RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess); - } else { - log.info("No client session for " + ipPort); - } - } else { - log.info("No client for this serverId"); - } - } else { - log.info("No client for "); - } - - } -} + public static <T> ResponseEntity<List<GNBCUCPModel>> sendGetRequestToConfigDb(String requestUrl) { + + HttpHeaders headers = new HttpHeaders(); + log.info("sending..."); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity<Void> requestEntity = new HttpEntity<>(headers); + try { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, + new ParameterizedTypeReference<List<GNBCUCPModel>>() {}); + } catch (Exception e) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + public void sendIntelligentSlicingPmData(SlicingPmMessage pmMessage) { + + log.info("inside sendIntelligentSlicingPmData"); + Gson gson = new Gson(); + String jsonStr = gson.toJson(pmMessage); + + log.info("IntelligentSlicingPmData " + jsonStr); + + String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName()); + + if (ipPort != null && !ipPort.trim().equals("")) { + + log.info("Connection estabilished with ip: " + ipPort); + if (ipPort != null && !ipPort.trim().equals("")) { + Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); + if (clSess != null) { + log.info("PM Data message sent."); + RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess); + } else { + log.info("No client session for " + ipPort); + } + } else { + log.info("No client for this serverId"); + } + } else { + log.info("No client for "); + } + + } +} diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java index 046d64a..f6c7401 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java @@ -24,39 +24,39 @@ import java.util.List; public class CellData { - private CellInfo Cell; - private List<NbrDump> neighbor; - - public CellData() { - super(); - } - - /** - * Constructor with all parameters - * - * @param cell Contains cell details. - * @param neighbor Contains list of neighbor details. - */ - public CellData(CellInfo cell, List<NbrDump> neighbor) { - super(); - Cell = cell; - this.neighbor = neighbor; - } - - public CellInfo getCell() { - return Cell; - } - - public void setCell(CellInfo cell) { - Cell = cell; - } - - public List<NbrDump> getNeighbor() { - return neighbor; - } - - public void setNeighbor(List<NbrDump> neighbor) { - this.neighbor = neighbor; - } + private CellInfo Cell; + private List<NbrDump> neighbor; + + public CellData() { + super(); + } + + /** + * Constructor with all parameters + * + * @param cell Contains cell details. + * @param neighbor Contains list of neighbor details. + */ + public CellData(CellInfo cell, List<NbrDump> neighbor) { + super(); + Cell = cell; + this.neighbor = neighbor; + } + + public CellInfo getCell() { + return Cell; + } + + public void setCell(CellInfo cell) { + Cell = cell; + } + + public List<NbrDump> getNeighbor() { + return neighbor; + } + + public void setNeighbor(List<NbrDump> neighbor) { + this.neighbor = neighbor; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java index 1c393d4..c50a097 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java @@ -29,224 +29,224 @@ import javax.persistence.Table; @Table(name = "CellDetails") public class CellDetails implements Comparable<CellDetails> { - private String networkId; - private String nodeId; - private long physicalCellId; - private String nodeName; - private String nodeType; - private boolean pciCollisionDetected; - private boolean pciConfusionDetected; - private float gridX; - private float gridY; - private float screenX; - private float screenY; - private String latitude; - private String longitude; - private String serverId; - private int sectorNumber = 0; - private String color; - - /** - * Constructor with cell Id, pci and server Id for test cases. - * - * @param nodeId Node Id of Cell - * @param physicalCellId Pci value of the cell. - * @param serverId Server Id of the cell. - */ - public CellDetails(String nodeId, long physicalCellId, String serverId) { - super(); - this.nodeId = nodeId; - this.physicalCellId = physicalCellId; - this.serverId = serverId; - } - - /** - * A constructor for CellDetails( Database to store cell details). - * - * @param networkId network Id of the cell - * @param nodeId node Id of the cell - * @param physicalCellId PCI number of the cell - * @param nodeName node name - * @param nodeType node type based on the cluster - * @param pciCollisionDetected Checks if the cell has collision - * @param pciConfusionDetected Checks if the cell has confusion - * - * @param gridX -- - * @param gridY -- - * @param screenX x coordinate of the cell in the GUI - * @param screenY y coordinate of the cell in the GUI - * @param latitude latitude of the cell node - * @param longitude longitude of the cell node - * @param serverId server Id of the netconf server it belongs to - * @param sectorNumber sector number of the cell - * @param color color of the cell in the GUI - */ - public CellDetails(String networkId, String nodeId, long physicalCellId, String nodeName, String nodeType, - boolean pciCollisionDetected, boolean pciConfusionDetected, float gridX, float gridY, float screenX, - float screenY, String latitude, String longitude, String serverId, int sectorNumber, String color) { - super(); - this.networkId = networkId; - this.nodeId = nodeId; - this.physicalCellId = physicalCellId; - this.nodeName = nodeName; - this.nodeType = nodeType; - this.pciCollisionDetected = pciCollisionDetected; - this.pciConfusionDetected = pciConfusionDetected; - - this.gridX = gridX; - this.gridY = gridY; - this.screenX = screenX; - this.screenY = screenY; - this.latitude = latitude; - this.longitude = longitude; - this.serverId = serverId; - this.sectorNumber = sectorNumber; - this.color = color; - } - - public CellDetails() { - super(); - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - @Id - @Column(name = "nodeId", unique = true, nullable = false, length = 50) - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public long getPhysicalCellId() { - return physicalCellId; - } - - public void setPhysicalCellId(long physicalCellId) { - this.physicalCellId = physicalCellId; - } - - public String getNodeName() { - return nodeName; - } - - public void setNodeName(String nodeName) { - this.nodeName = nodeName; - } - - public String getNodeType() { - return nodeType; - } - - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public boolean isPciCollisionDetected() { - return pciCollisionDetected; - } - - public void setPciCollisionDetected(boolean pciCollisionDetected) { - this.pciCollisionDetected = pciCollisionDetected; - } - - public boolean isPciConfusionDetected() { - return pciConfusionDetected; - } - - public void setPciConfusionDetected(boolean pciConfusionDetected) { - this.pciConfusionDetected = pciConfusionDetected; - } - - public float getGridX() { - return gridX; - } - - public void setGridX(float gridX) { - this.gridX = gridX; - } - - public float getGridY() { - return gridY; - } - - public void setGridY(float gridY) { - this.gridY = gridY; - } - - public float getScreenX() { - return screenX; - } - - public void setScreenX(float screenX) { - this.screenX = screenX; - } - - public float getScreenY() { - return screenY; - } - - public void setScreenY(float screenY) { - this.screenY = screenY; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public int getSectorNumber() { - return sectorNumber; - } - - public void setSectorNumber(int sectorNumber) { - this.sectorNumber = sectorNumber; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - public String getLatitude() { - return latitude; - } - - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - public String getLongitude() { - return longitude; - } - - public void setLongitude(String longitude) { - this.longitude = longitude; - } - - @Override - public String toString() { - return "Cell Details [networkId=" + networkId + ", nodeId=" + nodeId + ", physicalCellId=" + physicalCellId - + ", nodeName=" + nodeName + ", nodeType=" + nodeType + ", pciCollisionDetected=" + pciCollisionDetected - + ", pciConfusionDetected=" + pciConfusionDetected + "]"; - } - - @Override - public int compareTo(CellDetails cd) { - return this.getNodeId().compareTo(cd.getNodeId()); - } + private String networkId; + private String nodeId; + private long physicalCellId; + private String nodeName; + private String nodeType; + private boolean pciCollisionDetected; + private boolean pciConfusionDetected; + private float gridX; + private float gridY; + private float screenX; + private float screenY; + private String latitude; + private String longitude; + private String serverId; + private int sectorNumber = 0; + private String color; + + /** + * Constructor with cell Id, pci and server Id for test cases. + * + * @param nodeId Node Id of Cell + * @param physicalCellId Pci value of the cell. + * @param serverId Server Id of the cell. + */ + public CellDetails(String nodeId, long physicalCellId, String serverId) { + super(); + this.nodeId = nodeId; + this.physicalCellId = physicalCellId; + this.serverId = serverId; + } + + /** + * A constructor for CellDetails( Database to store cell details). + * + * @param networkId network Id of the cell + * @param nodeId node Id of the cell + * @param physicalCellId PCI number of the cell + * @param nodeName node name + * @param nodeType node type based on the cluster + * @param pciCollisionDetected Checks if the cell has collision + * @param pciConfusionDetected Checks if the cell has confusion + * + * @param gridX -- + * @param gridY -- + * @param screenX x coordinate of the cell in the GUI + * @param screenY y coordinate of the cell in the GUI + * @param latitude latitude of the cell node + * @param longitude longitude of the cell node + * @param serverId server Id of the netconf server it belongs to + * @param sectorNumber sector number of the cell + * @param color color of the cell in the GUI + */ + public CellDetails(String networkId, String nodeId, long physicalCellId, String nodeName, String nodeType, + boolean pciCollisionDetected, boolean pciConfusionDetected, float gridX, float gridY, float screenX, + float screenY, String latitude, String longitude, String serverId, int sectorNumber, String color) { + super(); + this.networkId = networkId; + this.nodeId = nodeId; + this.physicalCellId = physicalCellId; + this.nodeName = nodeName; + this.nodeType = nodeType; + this.pciCollisionDetected = pciCollisionDetected; + this.pciConfusionDetected = pciConfusionDetected; + + this.gridX = gridX; + this.gridY = gridY; + this.screenX = screenX; + this.screenY = screenY; + this.latitude = latitude; + this.longitude = longitude; + this.serverId = serverId; + this.sectorNumber = sectorNumber; + this.color = color; + } + + public CellDetails() { + super(); + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + @Id + @Column(name = "nodeId", unique = true, nullable = false, length = 50) + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public long getPhysicalCellId() { + return physicalCellId; + } + + public void setPhysicalCellId(long physicalCellId) { + this.physicalCellId = physicalCellId; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getNodeType() { + return nodeType; + } + + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public boolean isPciCollisionDetected() { + return pciCollisionDetected; + } + + public void setPciCollisionDetected(boolean pciCollisionDetected) { + this.pciCollisionDetected = pciCollisionDetected; + } + + public boolean isPciConfusionDetected() { + return pciConfusionDetected; + } + + public void setPciConfusionDetected(boolean pciConfusionDetected) { + this.pciConfusionDetected = pciConfusionDetected; + } + + public float getGridX() { + return gridX; + } + + public void setGridX(float gridX) { + this.gridX = gridX; + } + + public float getGridY() { + return gridY; + } + + public void setGridY(float gridY) { + this.gridY = gridY; + } + + public float getScreenX() { + return screenX; + } + + public void setScreenX(float screenX) { + this.screenX = screenX; + } + + public float getScreenY() { + return screenY; + } + + public void setScreenY(float screenY) { + this.screenY = screenY; + } + + public String getServerId() { + return serverId; + } + + public void setServerId(String serverId) { + this.serverId = serverId; + } + + public int getSectorNumber() { + return sectorNumber; + } + + public void setSectorNumber(int sectorNumber) { + this.sectorNumber = sectorNumber; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + @Override + public String toString() { + return "Cell Details [networkId=" + networkId + ", nodeId=" + nodeId + ", physicalCellId=" + physicalCellId + + ", nodeName=" + nodeName + ", nodeType=" + nodeType + ", pciCollisionDetected=" + pciCollisionDetected + + ", pciConfusionDetected=" + pciConfusionDetected + "]"; + } + + @Override + public int compareTo(CellDetails cd) { + return this.getNodeId().compareTo(cd.getNodeId()); + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java index 9a1b8da..4a18987 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java @@ -22,95 +22,95 @@ package org.onap.ransim.rest.api.models; public class CellInfo { - private String networkId; - private String nodeId; - private long physicalCellId; - private String pnfName; - private int sectorNumber; - private String latitude; - private String longitude; - - /** - * A constructor for CellInfo. - * - * @param networkId network Id of the cell - * @param nodeId node Id of the cell - * @param physicalCellId PCI number of the cell - * @param pnfName netconf server id - * @param sectorNumber sector number for the cell - * @param latitude latitude of the node - * @param longitude longitude of the node - */ - public CellInfo(String networkId, String nodeId, long physicalCellId, String pnfName, int sectorNumber, - String latitude, String longitude) { - super(); - this.networkId = networkId; - this.nodeId = nodeId; - this.physicalCellId = physicalCellId; - this.pnfName = pnfName; - this.sectorNumber = sectorNumber; - this.latitude = latitude; - this.longitude = longitude; - } - - public CellInfo() { - - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public long getPhysicalCellId() { - return physicalCellId; - } - - public void setPhysicalCellId(long physicalCellId) { - this.physicalCellId = physicalCellId; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - - public int getSectorNumber() { - return sectorNumber; - } - - public void setSectorNumber(int sectorNumber) { - this.sectorNumber = sectorNumber; - } - - public String getLatitude() { - return latitude; - } - - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - public String getLongitude() { - return longitude; - } - - public void setLongitude(String longitude) { - this.longitude = longitude; - } + private String networkId; + private String nodeId; + private long physicalCellId; + private String pnfName; + private int sectorNumber; + private String latitude; + private String longitude; + + /** + * A constructor for CellInfo. + * + * @param networkId network Id of the cell + * @param nodeId node Id of the cell + * @param physicalCellId PCI number of the cell + * @param pnfName netconf server id + * @param sectorNumber sector number for the cell + * @param latitude latitude of the node + * @param longitude longitude of the node + */ + public CellInfo(String networkId, String nodeId, long physicalCellId, String pnfName, int sectorNumber, + String latitude, String longitude) { + super(); + this.networkId = networkId; + this.nodeId = nodeId; + this.physicalCellId = physicalCellId; + this.pnfName = pnfName; + this.sectorNumber = sectorNumber; + this.latitude = latitude; + this.longitude = longitude; + } + + public CellInfo() { + + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public long getPhysicalCellId() { + return physicalCellId; + } + + public void setPhysicalCellId(long physicalCellId) { + this.physicalCellId = physicalCellId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public int getSectorNumber() { + return sectorNumber; + } + + public void setSectorNumber(int sectorNumber) { + this.sectorNumber = sectorNumber; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java index f0b9872..6c05f26 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java @@ -27,8 +27,8 @@ import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; @@ -39,48 +39,48 @@ import org.onap.ransim.rest.api.controller.RansimController; @Table(name = "CellNeighbor") public class CellNeighbor { - @Id - @Column(name = "nodeId", unique = true, nullable = false, length = 52) - private String nodeId; + @Id + @Column(name = "nodeId", unique = true, nullable = false, length = 52) + private String nodeId; - @OneToMany(targetEntity = NeighborDetails.class,fetch = FetchType.EAGER, cascade = CascadeType.ALL) - private Set<NeighborDetails> neighborList; + @OneToMany(targetEntity = NeighborDetails.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) + private Set<NeighborDetails> neighborList; - public CellNeighbor() { - super(); - } + public CellNeighbor() { + super(); + } - public CellNeighbor(String nodeId, Set<NeighborDetails> neighborList) { - super(); - this.nodeId = nodeId; - this.neighborList = neighborList; - } + public CellNeighbor(String nodeId, Set<NeighborDetails> neighborList) { + super(); + this.nodeId = nodeId; + this.neighborList = neighborList; + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } - public Set<NeighborDetails> getNeighborList() { - return neighborList; - } + public Set<NeighborDetails> getNeighborList() { + return neighborList; + } - public void setNeighborList(Set<NeighborDetails> neighborList) { - this.neighborList = neighborList; - } + public void setNeighborList(Set<NeighborDetails> neighborList) { + this.neighborList = neighborList; + } - static Logger log = Logger.getLogger(RansimController.class.getName()); + static Logger log = Logger.getLogger(RansimController.class.getName()); - public void display() { + public void display() { - List<NeighborDetails> iterator = new ArrayList<>(neighborList); - for (int ii = 0; ii < iterator.size(); ii++) { - log.info("neighbors NeighborList: " + iterator.get(ii).getNeigbor().getSourceCellNodeId() + " " - + iterator.get(ii).getNeigbor().getNeighborCell() + " " + iterator.get(ii).isBlacklisted()); - } + List<NeighborDetails> iterator = new ArrayList<>(neighborList); + for (int ii = 0; ii < iterator.size(); ii++) { + log.info("neighbors NeighborList: " + iterator.get(ii).getNeigbor().getSourceCellNodeId() + " " + + iterator.get(ii).getNeigbor().getNeighborCell() + " " + iterator.get(ii).isBlacklisted()); + } - } + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ConfigData.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ConfigData.java index 9af5537..afa454b 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ConfigData.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ConfigData.java @@ -22,22 +22,21 @@ package org.onap.ransim.rest.api.models; public class ConfigData { - private int maxNumberOfConns; + private int maxNumberOfConns; - public ConfigData() { - } + public ConfigData() { + } - public ConfigData(int maxNumberOfConns) { - super(); - this.maxNumberOfConns = maxNumberOfConns; - } + public ConfigData(int maxNumberOfConns) { + super(); + this.maxNumberOfConns = maxNumberOfConns; + } - public int getMaxNumberOfConns() { - return maxNumberOfConns; - } + public int getMaxNumberOfConns() { + return maxNumberOfConns; + } - public void setMaxNumberOfConns(int maxNumberOfConns) { - this.maxNumberOfConns = maxNumberOfConns; - } + public void setMaxNumberOfConns(int maxNumberOfConns) { + this.maxNumberOfConns = maxNumberOfConns; + } } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java index 618facf..b216e5e 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java @@ -24,54 +24,54 @@ import java.io.Serializable; public class CreateACellReq implements Serializable { - private long physicalCellId; + private long physicalCellId; - private int gridX; - private int gridY; + private int gridX; + private int gridY; - private static final long serialVersionUID = 3736300675426332512L; + private static final long serialVersionUID = 3736300675426332512L; - public CreateACellReq() { - // Default constructor for CreateACellReq - } + public CreateACellReq() { + // Default constructor for CreateACellReq + } - /** - * A constructor for CreateACellReq. - * - * @param physicalCellId PCI number of the new cell - * @param gridX x coordinate value for the cell - * @param gridY y coordinate value for the cell - */ - public CreateACellReq(long physicalCellId, int gridX, int gridY) { - super(); + /** + * A constructor for CreateACellReq. + * + * @param physicalCellId PCI number of the new cell + * @param gridX x coordinate value for the cell + * @param gridY y coordinate value for the cell + */ + public CreateACellReq(long physicalCellId, int gridX, int gridY) { + super(); - this.physicalCellId = physicalCellId; + this.physicalCellId = physicalCellId; - this.gridX = gridX; - this.gridY = gridY; - } + this.gridX = gridX; + this.gridY = gridY; + } - public long getPhysicalCellId() { - return physicalCellId; - } + public long getPhysicalCellId() { + return physicalCellId; + } - public void setPhysicalCellId(long physicalCellId) { - this.physicalCellId = physicalCellId; - } + public void setPhysicalCellId(long physicalCellId) { + this.physicalCellId = physicalCellId; + } - public int getGridX() { - return gridX; - } + public int getGridX() { + return gridX; + } - public void setGridX(int gridX) { - this.gridX = gridX; - } + public void setGridX(int gridX) { + this.gridX = gridX; + } - public int getGridY() { - return gridY; - } + public int getGridY() { + return gridY; + } - public void setGridY(int gridY) { - this.gridY = gridY; - } + public void setGridY(int gridY) { + this.gridY = gridY; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java index a6a7baf..7329a31 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java @@ -22,28 +22,28 @@ package org.onap.ransim.rest.api.models; public class DeleteACellReq { - private String nodeId; + private String nodeId; - /** - * A constructor for DeleteACellReq. - * - * @param nodeId node Id of the cell to be deleted - */ - public DeleteACellReq(String nodeId) { - super(); - this.nodeId = nodeId; - } + /** + * A constructor for DeleteACellReq. + * + * @param nodeId node Id of the cell to be deleted + */ + public DeleteACellReq(String nodeId) { + super(); + this.nodeId = nodeId; + } - public DeleteACellReq() { + public DeleteACellReq() { - } + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java index 6b00369..2b7dd39 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java @@ -22,50 +22,50 @@ package org.onap.ransim.rest.api.models; public class FmAlarmInfo { - private String problem; - private String collisionCount; - private String confusionCount; + private String problem; + private String collisionCount; + private String confusionCount; - public FmAlarmInfo() { - super(); - } + public FmAlarmInfo() { + super(); + } - /** - * Constructor with all fields. - * - * @param problem Collision or Confusion - * @param collisionCount No of cells that causes collision. - * @param confusionCount No od cells that causes confusion. - */ - public FmAlarmInfo(String problem, String collisionCount, String confusionCount) { - super(); - this.problem = problem; - this.collisionCount = collisionCount; - this.confusionCount = confusionCount; - } + /** + * Constructor with all fields. + * + * @param problem Collision or Confusion + * @param collisionCount No of cells that causes collision. + * @param confusionCount No od cells that causes confusion. + */ + public FmAlarmInfo(String problem, String collisionCount, String confusionCount) { + super(); + this.problem = problem; + this.collisionCount = collisionCount; + this.confusionCount = confusionCount; + } - public String getProblem() { - return problem; - } + public String getProblem() { + return problem; + } - public void setProblem(String problem) { - this.problem = problem; - } + public void setProblem(String problem) { + this.problem = problem; + } - public String getCollisionCount() { - return collisionCount; - } + public String getCollisionCount() { + return collisionCount; + } - public void setCollisionCount(String collisionCount) { - this.collisionCount = collisionCount; - } + public void setCollisionCount(String collisionCount) { + this.collisionCount = collisionCount; + } - public String getConfusionCount() { - return confusionCount; - } + public String getConfusionCount() { + return confusionCount; + } - public void setConfusionCount(String confusionCount) { - this.confusionCount = confusionCount; - } + public void setConfusionCount(String confusionCount) { + this.confusionCount = confusionCount; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUCPFunction.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUCPFunction.java index 6efb34c..71f8b07 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUCPFunction.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUCPFunction.java @@ -35,79 +35,79 @@ import javax.persistence.Table; @Entity @Table(name = "GNBCUCPFUNCTION") public class GNBCUCPFunction implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "GNBCUNAME") - private String gNBCUName; - @Column(name = "GNBID") - private Integer gNBId; - @Column(name = "GNBIDLENGTH") - private Integer gNBIdLength; - @Column(name = "PLMNID") - private String pLMNId; - @Column(name = "NFTYPE") - private String nFType; - @Column(name = "CELLCULIST") - @OneToMany(mappedBy = "gNBCUCPFunction", cascade = CascadeType.ALL) - private List<NRCellCU> cellCUList; - @ManyToOne // (cascade=CascadeType.ALL) - @JoinColumn(name = "nearrtricid") - private NearRTRIC nearRTRIC; - - public String getgNBCUName() { - return gNBCUName; - } - - public void setgNBCUName(String gNBCUName) { - this.gNBCUName = gNBCUName; - } - - public Integer getgNBId() { - return gNBId; - } - - public void setgNBId(Integer gNBId) { - this.gNBId = gNBId; - } - - public Integer getgNBIdLength() { - return gNBIdLength; - } - - public void setgNBIdLength(Integer gNBIdLength) { - this.gNBIdLength = gNBIdLength; - } - - public String getpLMNId() { - return pLMNId; - } - - public void setpLMNId(String pLMNId) { - this.pLMNId = pLMNId; - } - - public List<NRCellCU> getCellCUList() { - return cellCUList; - } - - public void setCellCUList(List<NRCellCU> cellCUList) { - this.cellCUList = cellCUList; - } - - public NearRTRIC getNearRTRIC() { - return nearRTRIC; - } - - public void setNearRTRIC(NearRTRIC nearRTRIC) { - this.nearRTRIC = nearRTRIC; - } - - public String getnFType() { - return nFType; - } - - public void setnFType(String nFType) { - this.nFType = nFType; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "GNBCUNAME") + private String gNBCUName; + @Column(name = "GNBID") + private Integer gNBId; + @Column(name = "GNBIDLENGTH") + private Integer gNBIdLength; + @Column(name = "PLMNID") + private String pLMNId; + @Column(name = "NFTYPE") + private String nFType; + @Column(name = "CELLCULIST") + @OneToMany(mappedBy = "gNBCUCPFunction", cascade = CascadeType.ALL) + private List<NRCellCU> cellCUList; + @ManyToOne // (cascade=CascadeType.ALL) + @JoinColumn(name = "nearrtricid") + private NearRTRIC nearRTRIC; + + public String getgNBCUName() { + return gNBCUName; + } + + public void setgNBCUName(String gNBCUName) { + this.gNBCUName = gNBCUName; + } + + public Integer getgNBId() { + return gNBId; + } + + public void setgNBId(Integer gNBId) { + this.gNBId = gNBId; + } + + public Integer getgNBIdLength() { + return gNBIdLength; + } + + public void setgNBIdLength(Integer gNBIdLength) { + this.gNBIdLength = gNBIdLength; + } + + public String getpLMNId() { + return pLMNId; + } + + public void setpLMNId(String pLMNId) { + this.pLMNId = pLMNId; + } + + public List<NRCellCU> getCellCUList() { + return cellCUList; + } + + public void setCellCUList(List<NRCellCU> cellCUList) { + this.cellCUList = cellCUList; + } + + public NearRTRIC getNearRTRIC() { + return nearRTRIC; + } + + public void setNearRTRIC(NearRTRIC nearRTRIC) { + this.nearRTRIC = nearRTRIC; + } + + public String getnFType() { + return nFType; + } + + public void setnFType(String nFType) { + this.nFType = nFType; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUUPFunction.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUUPFunction.java index 5a3af3e..790a638 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUUPFunction.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBCUUPFunction.java @@ -37,79 +37,78 @@ import javax.persistence.Table; @Entity @Table(name = "GNBCUUPFUNCTION") public class GNBCUUPFunction implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "GNBCUUPID") - private Integer gNBCUUPId; - @Column(name = "GNBID") - private Integer gNBId; - @Column(name = "GNBIDLENGTH") - private Integer gNBIdLength; - // @Column(name="PLMNINFOLIST") - // @OneToMany(mappedBy = "gNBCUUPFunction", - // cascade={CascadeType.PERSIST,CascadeType.REMOVE}) - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "gnbcuupid")) - private List<PLMNInfo> pLMNInfoList; - @Column(name = "RESOURCETYPE") - private String resourceType; - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "nearrtricid") - private NearRTRIC nearRTRIC; - - public Integer getgNBCUUPId() { - return gNBCUUPId; - } - - public void setgNBCUUPId(Integer gNBCUUPId) { - this.gNBCUUPId = gNBCUUPId; - } - - public Integer getgNBId() { - return gNBId; - } - - public void setgNBId(Integer gNBId) { - this.gNBId = gNBId; - } - - public Integer getgNBIdLength() { - return gNBIdLength; - } - - public void setgNBIdLength(Integer gNBIdLength) { - this.gNBIdLength = gNBIdLength; - } - - public List<PLMNInfo> getpLMNInfoList() { - return pLMNInfoList; - } - - public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { - this.pLMNInfoList = pLMNInfoList; - } - - public NearRTRIC getNearRTRIC() { - return nearRTRIC; - } - - public void setNearRTRIC(NearRTRIC nearRTRIC) { - this.nearRTRIC = nearRTRIC; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - @Override - public String toString() { - return "GNBCUUPFunction [gNBCUUPId=" + gNBCUUPId + ", gNBId=" + gNBId + ", gNBIdLength=" + gNBIdLength - + ", pLMNInfoList=" + pLMNInfoList + ", resourceType=" + resourceType + ", nearRTRIC=" + nearRTRIC - + "]"; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "GNBCUUPID") + private Integer gNBCUUPId; + @Column(name = "GNBID") + private Integer gNBId; + @Column(name = "GNBIDLENGTH") + private Integer gNBIdLength; + // @Column(name="PLMNINFOLIST") + // @OneToMany(mappedBy = "gNBCUUPFunction", + // cascade={CascadeType.PERSIST,CascadeType.REMOVE}) + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "gnbcuupid")) + private List<PLMNInfo> pLMNInfoList; + @Column(name = "RESOURCETYPE") + private String resourceType; + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "nearrtricid") + private NearRTRIC nearRTRIC; + + public Integer getgNBCUUPId() { + return gNBCUUPId; + } + + public void setgNBCUUPId(Integer gNBCUUPId) { + this.gNBCUUPId = gNBCUUPId; + } + + public Integer getgNBId() { + return gNBId; + } + + public void setgNBId(Integer gNBId) { + this.gNBId = gNBId; + } + + public Integer getgNBIdLength() { + return gNBIdLength; + } + + public void setgNBIdLength(Integer gNBIdLength) { + this.gNBIdLength = gNBIdLength; + } + + public List<PLMNInfo> getpLMNInfoList() { + return pLMNInfoList; + } + + public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { + this.pLMNInfoList = pLMNInfoList; + } + + public NearRTRIC getNearRTRIC() { + return nearRTRIC; + } + + public void setNearRTRIC(NearRTRIC nearRTRIC) { + this.nearRTRIC = nearRTRIC; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + @Override + public String toString() { + return "GNBCUUPFunction [gNBCUUPId=" + gNBCUUPId + ", gNBId=" + gNBId + ", gNBIdLength=" + gNBIdLength + + ", pLMNInfoList=" + pLMNInfoList + ", resourceType=" + resourceType + ", nearRTRIC=" + nearRTRIC + + "]"; + } } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBDUFunction.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBDUFunction.java index 2df9786..618d61b 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBDUFunction.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GNBDUFunction.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -34,89 +35,89 @@ import javax.persistence.Table; @Entity @Table(name = "GNBDUFUNCTION") public class GNBDUFunction implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "GNBDUID") - private Integer gNBDUId; - @Column(name = "GNBID") - private Integer gNBId; - @Column(name = "GNBIDLENGTH") - private Integer gNBIdLength; - @Column(name = "GNBDUNAME") - private String gNBDUName; - @Column(name = "PLMNID") - private String pLMNId; - @Column(name = "NFTYPE") - private String nFType; - @Column(name = "CELLDULIST") - @OneToMany(mappedBy = "gNBDUFunction", cascade = CascadeType.ALL) - private List<NRCellDU> cellDUList; - @ManyToOne - @JoinColumn(name = "nearrtricid") - private NearRTRIC nearRTRIC; - - public Integer getgNBDUId() { - return gNBDUId; - } - - public void setgNBDUId(Integer gNBDUId) { - this.gNBDUId = gNBDUId; - } - - public Integer getgNBId() { - return gNBId; - } - - public void setgNBId(Integer gNBId) { - this.gNBId = gNBId; - } - - public Integer getgNBIdLength() { - return gNBIdLength; - } - - public void setgNBIdLength(Integer gNBIdLength) { - this.gNBIdLength = gNBIdLength; - } - - public String getgNBDUName() { - return gNBDUName; - } - - public void setgNBDUName(String gNBDUName) { - this.gNBDUName = gNBDUName; - } - - public String getpLMNId() { - return pLMNId; - } - - public void setpLMNId(String pLMNId) { - this.pLMNId = pLMNId; - } - - public List<NRCellDU> getCellDUList() { - return cellDUList; - } - - public void setCellDUList(List<NRCellDU> cellDUList) { - this.cellDUList = cellDUList; - } - - public NearRTRIC getNearRTRIC() { - return nearRTRIC; - } - - public void setNearRTRIC(NearRTRIC nearRTRIC) { - this.nearRTRIC = nearRTRIC; - } - - public String getnFType() { - return nFType; - } - - public void setnFType(String nFType) { - this.nFType = nFType; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "GNBDUID") + private Integer gNBDUId; + @Column(name = "GNBID") + private Integer gNBId; + @Column(name = "GNBIDLENGTH") + private Integer gNBIdLength; + @Column(name = "GNBDUNAME") + private String gNBDUName; + @Column(name = "PLMNID") + private String pLMNId; + @Column(name = "NFTYPE") + private String nFType; + @Column(name = "CELLDULIST") + @OneToMany(mappedBy = "gNBDUFunction", cascade = CascadeType.ALL) + private List<NRCellDU> cellDUList; + @ManyToOne + @JoinColumn(name = "nearrtricid") + private NearRTRIC nearRTRIC; + + public Integer getgNBDUId() { + return gNBDUId; + } + + public void setgNBDUId(Integer gNBDUId) { + this.gNBDUId = gNBDUId; + } + + public Integer getgNBId() { + return gNBId; + } + + public void setgNBId(Integer gNBId) { + this.gNBId = gNBId; + } + + public Integer getgNBIdLength() { + return gNBIdLength; + } + + public void setgNBIdLength(Integer gNBIdLength) { + this.gNBIdLength = gNBIdLength; + } + + public String getgNBDUName() { + return gNBDUName; + } + + public void setgNBDUName(String gNBDUName) { + this.gNBDUName = gNBDUName; + } + + public String getpLMNId() { + return pLMNId; + } + + public void setpLMNId(String pLMNId) { + this.pLMNId = pLMNId; + } + + public List<NRCellDU> getCellDUList() { + return cellDUList; + } + + public void setCellDUList(List<NRCellDU> cellDUList) { + this.cellDUList = cellDUList; + } + + public NearRTRIC getNearRTRIC() { + return nearRTRIC; + } + + public void setNearRTRIC(NearRTRIC nearRTRIC) { + this.nearRTRIC = nearRTRIC; + } + + public String getnFType() { + return nFType; + } + + public void setnFType(String nFType) { + this.nFType = nFType; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java index 8d49d1a..887d3bf 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java @@ -22,28 +22,28 @@ package org.onap.ransim.rest.api.models; public class GetACellDetailReq { - private String nodeId; + private String nodeId; - /** - * A constructor for GetACellDetailReq. - * - * @param nodeId node id of the cell - */ - public GetACellDetailReq(String nodeId) { - super(); - this.nodeId = nodeId; - } + /** + * A constructor for GetACellDetailReq. + * + * @param nodeId node id of the cell + */ + public GetACellDetailReq(String nodeId) { + super(); + this.nodeId = nodeId; + } - public GetACellDetailReq() { + public GetACellDetailReq() { - } + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java index 320db9d..11e8019 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java @@ -17,56 +17,57 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; import java.util.List; public class GetNeighborList { - private String nodeId; - private List<CellDetails> cellsWithNoHo; - private List<CellDetails> cellsWithHo; + private String nodeId; + private List<CellDetails> cellsWithNoHo; + private List<CellDetails> cellsWithHo; - public GetNeighborList() { - super(); - } + public GetNeighborList() { + super(); + } - /** - * Constructor with all fields. - * - * @param nodeId Node Id of cell - * @param cellsWithNoHO List of neighbors with unsuccessful handover. - * @param cellsWithHO List of neighbors with successful handover. - */ - public GetNeighborList(String nodeId, List<CellDetails> cellsWithNoHo, List<CellDetails> cellsWithHo) { - super(); - this.nodeId = nodeId; - this.cellsWithNoHo = cellsWithNoHo; - this.cellsWithHo = cellsWithHo; - } + /** + * Constructor with all fields. + * + * @param nodeId Node Id of cell + * @param cellsWithNoHO List of neighbors with unsuccessful handover. + * @param cellsWithHO List of neighbors with successful handover. + */ + public GetNeighborList(String nodeId, List<CellDetails> cellsWithNoHo, List<CellDetails> cellsWithHo) { + super(); + this.nodeId = nodeId; + this.cellsWithNoHo = cellsWithNoHo; + this.cellsWithHo = cellsWithHo; + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } - public List<CellDetails> getCellsWithNoHo() { - return cellsWithNoHo; - } + public List<CellDetails> getCellsWithNoHo() { + return cellsWithNoHo; + } - public void setCellsWithNoHo(List<CellDetails> cellsWithNoHo) { - this.cellsWithNoHo = cellsWithNoHo; - } + public void setCellsWithNoHo(List<CellDetails> cellsWithNoHo) { + this.cellsWithNoHo = cellsWithNoHo; + } - public List<CellDetails> getCellsWithHo() { - return cellsWithHo; - } + public List<CellDetails> getCellsWithHo() { + return cellsWithHo; + } - public void setCellsWithHo(List<CellDetails> cellsWithHo) { - this.cellsWithHo = cellsWithHo; - } + public void setCellsWithHo(List<CellDetails> cellsWithHo) { + this.cellsWithHo = cellsWithHo; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java index 3ec491c..b779112 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java @@ -22,28 +22,28 @@ package org.onap.ransim.rest.api.models; public class GetNeighborListReq { - private String nodeId; + private String nodeId; - public GetNeighborListReq() { + public GetNeighborListReq() { - } + } - /** - * A constructor for GetNeighborListReq. - * - * @param nodeId node Id of the cell who's neighbor list is required - */ - public GetNeighborListReq(String nodeId) { - super(); - this.nodeId = nodeId; - } + /** + * A constructor for GetNeighborListReq. + * + * @param nodeId node Id of the cell who's neighbor list is required + */ + public GetNeighborListReq(String nodeId) { + super(); + this.nodeId = nodeId; + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java index 5349190..da0e410 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java @@ -22,29 +22,29 @@ package org.onap.ransim.rest.api.models; public class GetNetconfServerDetailsReq { - private String serverId; - - /** - * A constructor for GetNetconfServerDetailsReq. - * - * @param serverId server Id of the netconf server - */ - public GetNetconfServerDetailsReq(String serverId) { - super(); - this.serverId = serverId; - } - - public GetNetconfServerDetailsReq() { - - // TODO Auto-generated constructor stub - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } + private String serverId; + + /** + * A constructor for GetNetconfServerDetailsReq. + * + * @param serverId server Id of the netconf server + */ + public GetNetconfServerDetailsReq(String serverId) { + super(); + this.serverId = serverId; + } + + public GetNetconfServerDetailsReq() { + + // TODO Auto-generated constructor stub + } + + public String getServerId() { + return serverId; + } + + public void setServerId(String serverId) { + this.serverId = serverId; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java index 245dea3..ce1a715 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java @@ -17,43 +17,44 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; public class GetPmDataReq { - private String nodeIdBad; - private String nodeIdPoor; - - public GetPmDataReq() { - super(); - } - - /** - * Constructor with all fields. - * - * @param nodeIdBad Cells with bad PM value. - * @param nodeIdPoor Cells with poor PM value. - */ - public GetPmDataReq(String nodeIdBad, String nodeIdPoor) { - super(); - this.nodeIdBad = nodeIdBad; - this.nodeIdPoor = nodeIdPoor; - } - - public String getNodeIdBad() { - return nodeIdBad; - } - - public void setNodeIdBad(String nodeIdBad) { - this.nodeIdBad = nodeIdBad; - } - - public String getNodeIdPoor() { - return nodeIdPoor; - } - - public void setNodeIdPoor(String nodeIdPoor) { - this.nodeIdPoor = nodeIdPoor; - } + private String nodeIdBad; + private String nodeIdPoor; + + public GetPmDataReq() { + super(); + } + + /** + * Constructor with all fields. + * + * @param nodeIdBad Cells with bad PM value. + * @param nodeIdPoor Cells with poor PM value. + */ + public GetPmDataReq(String nodeIdBad, String nodeIdPoor) { + super(); + this.nodeIdBad = nodeIdBad; + this.nodeIdPoor = nodeIdPoor; + } + + public String getNodeIdBad() { + return nodeIdBad; + } + + public void setNodeIdBad(String nodeIdBad) { + this.nodeIdBad = nodeIdBad; + } + + public String getNodeIdPoor() { + return nodeIdPoor; + } + + public void setNodeIdPoor(String nodeIdPoor) { + this.nodeIdPoor = nodeIdPoor; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java index 6b2cf32..f193d5a 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java @@ -21,72 +21,72 @@ package org.onap.ransim.rest.api.models; public class GetTopology { - private CellDetails currentCell; - private int gridX; - private int gridY; - private String nodeId; - private long physicalCellId; - - /** - * A constructor GetTopology. - * - * @param currentCell current cell details - * @param gridX x coordinate value for the cell - * @param gridY y coordinate value for the cell - * @param nodeId node id of the cell - * @param physicalCellId pci value for the cell - */ - public GetTopology(CellDetails currentCell, int gridX, int gridY, String nodeId, long physicalCellId) { - super(); - this.currentCell = currentCell; - this.gridX = gridX; - this.gridY = gridY; - this.nodeId = nodeId; - this.physicalCellId = physicalCellId; - } - - public GetTopology() { - - } - - public CellDetails getCurrentCell() { - return currentCell; - } - - public void setCurrentCell(CellDetails currentCell) { - this.currentCell = currentCell; - } - - public int getGridX() { - return gridX; - } - - public void setGridX(int gridX) { - this.gridX = gridX; - } - - public int getGridY() { - return gridY; - } - - public void setGridY(int gridY) { - this.gridY = gridY; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public long getPhysicalCellId() { - return physicalCellId; - } - - public void setPhysicalCellId(long physicalCellId) { - this.physicalCellId = physicalCellId; - } + private CellDetails currentCell; + private int gridX; + private int gridY; + private String nodeId; + private long physicalCellId; + + /** + * A constructor GetTopology. + * + * @param currentCell current cell details + * @param gridX x coordinate value for the cell + * @param gridY y coordinate value for the cell + * @param nodeId node id of the cell + * @param physicalCellId pci value for the cell + */ + public GetTopology(CellDetails currentCell, int gridX, int gridY, String nodeId, long physicalCellId) { + super(); + this.currentCell = currentCell; + this.gridX = gridX; + this.gridY = gridY; + this.nodeId = nodeId; + this.physicalCellId = physicalCellId; + } + + public GetTopology() { + + } + + public CellDetails getCurrentCell() { + return currentCell; + } + + public void setCurrentCell(CellDetails currentCell) { + this.currentCell = currentCell; + } + + public int getGridX() { + return gridX; + } + + public void setGridX(int gridX) { + this.gridX = gridX; + } + + public int getGridY() { + return gridY; + } + + public void setGridY(int gridY) { + this.gridY = gridY; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public long getPhysicalCellId() { + return physicalCellId; + } + + public void setPhysicalCellId(long physicalCellId) { + this.physicalCellId = physicalCellId; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java index 6d20fcf..ff715e3 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java @@ -22,52 +22,52 @@ package org.onap.ransim.rest.api.models; public class ModifyACellReq { - private String nodeId; - private Long newPhysicalCellId; - private String newNbrs; + private String nodeId; + private Long newPhysicalCellId; + private String newNbrs; - /** - * A constructor for ModifyACellReq. - * - * @param nodeId node Id of the cell which is to be modified - * @param newPhysicalCellId new PCI number for the cell - * @param newNbrs new neighbor list for the cell - */ - public ModifyACellReq(String nodeId, Long newPhysicalCellId, String newNbrs) { - super(); - this.nodeId = nodeId; - this.newPhysicalCellId = newPhysicalCellId; - this.newNbrs = newNbrs; + /** + * A constructor for ModifyACellReq. + * + * @param nodeId node Id of the cell which is to be modified + * @param newPhysicalCellId new PCI number for the cell + * @param newNbrs new neighbor list for the cell + */ + public ModifyACellReq(String nodeId, Long newPhysicalCellId, String newNbrs) { + super(); + this.nodeId = nodeId; + this.newPhysicalCellId = newPhysicalCellId; + this.newNbrs = newNbrs; - } + } - public ModifyACellReq() { + public ModifyACellReq() { - // Default constructor for ModifyCell - } + // Default constructor for ModifyCell + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } - public Long getNewPhysicalCellId() { - return newPhysicalCellId; - } + public Long getNewPhysicalCellId() { + return newPhysicalCellId; + } - public void setNewPhysicalCellId(Long newPhysicalCellId) { - this.newPhysicalCellId = newPhysicalCellId; - } + public void setNewPhysicalCellId(Long newPhysicalCellId) { + this.newPhysicalCellId = newPhysicalCellId; + } - public String getNewNbrs() { - return newNbrs; - } + public String getNewNbrs() { + return newNbrs; + } - public void setNewNbrs(String newNbrs) { - this.newNbrs = newNbrs; - } + public void setNewNbrs(String newNbrs) { + this.newNbrs = newNbrs; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellCU.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellCU.java index 89ffdd7..2d49f63 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellCU.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellCU.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; @@ -37,50 +38,49 @@ import javax.persistence.Table; @Entity @Table(name = "NRCELLCU") public class NRCellCU implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "CELLLOCALID") - private Integer cellLocalId; - @Column(name = "RESOURCETYPE") - private String resourceType; - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "nrcellcu_celllocalid")) - private List<PLMNInfo> pLMNInfoList; - @ManyToOne - @JoinColumn(name = "gnbcuname") - private GNBCUCPFunction gNBCUCPFunction; + private static final long serialVersionUID = 1L; + @Id + @Column(name = "CELLLOCALID") + private Integer cellLocalId; + @Column(name = "RESOURCETYPE") + private String resourceType; + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "nrcellcu_celllocalid")) + private List<PLMNInfo> pLMNInfoList; + @ManyToOne + @JoinColumn(name = "gnbcuname") + private GNBCUCPFunction gNBCUCPFunction; - public Integer getCellLocalId() { - return cellLocalId; - } + public Integer getCellLocalId() { + return cellLocalId; + } - public void setCellLocalId(Integer cellLocalId) { - this.cellLocalId = cellLocalId; - } + public void setCellLocalId(Integer cellLocalId) { + this.cellLocalId = cellLocalId; + } - public List<PLMNInfo> getpLMNInfoList() { - return pLMNInfoList; - } + public List<PLMNInfo> getpLMNInfoList() { + return pLMNInfoList; + } - public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { - this.pLMNInfoList = pLMNInfoList; - } + public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { + this.pLMNInfoList = pLMNInfoList; + } - public GNBCUCPFunction getgNBCUCPFunction() { - return gNBCUCPFunction; - } + public GNBCUCPFunction getgNBCUCPFunction() { + return gNBCUCPFunction; + } - public void setgNBCUCPFunction(GNBCUCPFunction gNBCUCPFunction) { - this.gNBCUCPFunction = gNBCUCPFunction; - } + public void setgNBCUCPFunction(GNBCUCPFunction gNBCUCPFunction) { + this.gNBCUCPFunction = gNBCUCPFunction; + } - public String getResourceType() { - return resourceType; - } + public String getResourceType() { + return resourceType; + } - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellDU.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellDU.java index e93f5aa..4bd9f1c 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellDU.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NRCellDU.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; @@ -35,91 +36,110 @@ import javax.persistence.OneToMany; import javax.persistence.Table; @Entity -@Table(name="NRCELLDU") -public class NRCellDU implements Serializable{ - private static final long serialVersionUID = 1L; - @Id - @Column(name="CELLLOCALID") - private Integer cellLocalId; - @Column(name="OPERATIONALSTATE") - private String operationalState; - @Column(name="ADMINISTRATIVESTATE") - private String administrativeState; - @Column(name="CELLSTATE") - private String cellState; - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable(name="PLMNINFO",joinColumns = @JoinColumn(name="nrcelldu_celllocalid")) - private List<PLMNInfo> pLMNInfoList; - @Column(name="NRPCI") - private Integer nRPCI; - @Column(name="nRTAC") - private Integer nRTAC; - @Column(name="RESOURCETYPE") - private String resourceType; - @ManyToOne - @JoinColumn(name = "gnbduid") - private GNBDUFunction gNBDUFunction; - @Column(name="prb") - private Integer prbs; - - public Integer getCellLocalId() { - return cellLocalId; - } - public void setCellLocalId(Integer cellLocalId) { - this.cellLocalId = cellLocalId; - } - public List<PLMNInfo> getpLMNInfoList() { - return pLMNInfoList; - } - public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { - this.pLMNInfoList = pLMNInfoList; - } - public String getOperationalState() { - return operationalState; - } - public void setOperationalState(String operationalState) { - this.operationalState = operationalState; - } - public String getAdministrativeState() { - return administrativeState; - } - public void setAdministrativeState(String administrativeState) { - this.administrativeState = administrativeState; - } - public String getCellState() { - return cellState; - } - public void setCellState(String cellState) { - this.cellState = cellState; - } - public Integer getnRPCI() { - return nRPCI; - } - public void setnRPCI(Integer nRPCI) { - this.nRPCI = nRPCI; - } - public Integer getnRTAC() { - return nRTAC; - } - public void setnRTAC(Integer nRTAC) { - this.nRTAC = nRTAC; - } - public GNBDUFunction getgNBDUFunction() { - return gNBDUFunction; - } - public void setgNBDUFunction(GNBDUFunction gNBDUFunction) { - this.gNBDUFunction = gNBDUFunction; - } - public String getResourceType() { - return resourceType; - } - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - public Integer getPrbs() { - return prbs; - } - public void setPrbs(Integer prbs) { - this.prbs = prbs; - } +@Table(name = "NRCELLDU") +public class NRCellDU implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name = "CELLLOCALID") + private Integer cellLocalId; + @Column(name = "OPERATIONALSTATE") + private String operationalState; + @Column(name = "ADMINISTRATIVESTATE") + private String administrativeState; + @Column(name = "CELLSTATE") + private String cellState; + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "nrcelldu_celllocalid")) + private List<PLMNInfo> pLMNInfoList; + @Column(name = "NRPCI") + private Integer nRPCI; + @Column(name = "nRTAC") + private Integer nRTAC; + @Column(name = "RESOURCETYPE") + private String resourceType; + @ManyToOne + @JoinColumn(name = "gnbduid") + private GNBDUFunction gNBDUFunction; + @Column(name = "prb") + private Integer prbs; + + public Integer getCellLocalId() { + return cellLocalId; + } + + public void setCellLocalId(Integer cellLocalId) { + this.cellLocalId = cellLocalId; + } + + public List<PLMNInfo> getpLMNInfoList() { + return pLMNInfoList; + } + + public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { + this.pLMNInfoList = pLMNInfoList; + } + + public String getOperationalState() { + return operationalState; + } + + public void setOperationalState(String operationalState) { + this.operationalState = operationalState; + } + + public String getAdministrativeState() { + return administrativeState; + } + + public void setAdministrativeState(String administrativeState) { + this.administrativeState = administrativeState; + } + + public String getCellState() { + return cellState; + } + + public void setCellState(String cellState) { + this.cellState = cellState; + } + + public Integer getnRPCI() { + return nRPCI; + } + + public void setnRPCI(Integer nRPCI) { + this.nRPCI = nRPCI; + } + + public Integer getnRTAC() { + return nRTAC; + } + + public void setnRTAC(Integer nRTAC) { + this.nRTAC = nRTAC; + } + + public GNBDUFunction getgNBDUFunction() { + return gNBDUFunction; + } + + public void setgNBDUFunction(GNBDUFunction gNBDUFunction) { + this.gNBDUFunction = gNBDUFunction; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public Integer getPrbs() { + return prbs; + } + + public void setPrbs(Integer prbs) { + this.prbs = prbs; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NSSAIConfig.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NSSAIConfig.java index e650ff1..db7c4e0 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NSSAIConfig.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NSSAIConfig.java @@ -21,53 +21,54 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; +import java.sql.Timestamp; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Table; -import java.sql.Timestamp; @Table(name = "NSSAICONFIG") @Embeddable public class NSSAIConfig implements Serializable { - private static final long serialVersionUID = 1L; - @Column(name = "DLTHPTPERSLICE") - private Integer dLThptPerSlice; - @Column(name = "ULTHPTPERSLICE") - private Integer uLThptPerSlice; - @Column(name = "MAXNUMBEROFCONNS") - private Integer maxNumberOfConns; - @Column(name = "LASTUPDATEDTS") - private Timestamp lastUpdatedTS; + private static final long serialVersionUID = 1L; + @Column(name = "DLTHPTPERSLICE") + private Integer dLThptPerSlice; + @Column(name = "ULTHPTPERSLICE") + private Integer uLThptPerSlice; + @Column(name = "MAXNUMBEROFCONNS") + private Integer maxNumberOfConns; + @Column(name = "LASTUPDATEDTS") + private Timestamp lastUpdatedTS; - public Integer getdLThptPerSlice() { - return dLThptPerSlice; - } + public Integer getdLThptPerSlice() { + return dLThptPerSlice; + } - public void setdLThptPerSlice(Integer dLThptPerSlice) { - this.dLThptPerSlice = dLThptPerSlice; - } + public void setdLThptPerSlice(Integer dLThptPerSlice) { + this.dLThptPerSlice = dLThptPerSlice; + } - public Integer getuLThptPerSlice() { - return uLThptPerSlice; - } + public Integer getuLThptPerSlice() { + return uLThptPerSlice; + } - public void setuLThptPerSlice(Integer uLThptPerSlice) { - this.uLThptPerSlice = uLThptPerSlice; - } + public void setuLThptPerSlice(Integer uLThptPerSlice) { + this.uLThptPerSlice = uLThptPerSlice; + } - public Integer getMaxNumberOfConns() { - return maxNumberOfConns; - } + public Integer getMaxNumberOfConns() { + return maxNumberOfConns; + } - public void setMaxNumberOfConns(Integer maxNumberOfConns) { - this.maxNumberOfConns = maxNumberOfConns; - } + public void setMaxNumberOfConns(Integer maxNumberOfConns) { + this.maxNumberOfConns = maxNumberOfConns; + } - public Timestamp getLastUpdatedTS() { - return lastUpdatedTS; - } + public Timestamp getLastUpdatedTS() { + return lastUpdatedTS; + } - public void setLastUpdatedTS(Timestamp lastUpdatedTS) { - this.lastUpdatedTS = lastUpdatedTS; - } + public void setLastUpdatedTS(Timestamp lastUpdatedTS) { + this.lastUpdatedTS = lastUpdatedTS; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java index 1033b3b..23fe8ef 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java @@ -17,38 +17,39 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; public class NbrDump { - private String nodeId; - private String blacklisted; + private String nodeId; + private String blacklisted; - public NbrDump() { - super(); - // TODO Auto-generated constructor stub - } + public NbrDump() { + super(); + // TODO Auto-generated constructor stub + } - public NbrDump(String nodeId, String blacklisted) { - super(); - this.nodeId = nodeId; - this.blacklisted = blacklisted; - } + public NbrDump(String nodeId, String blacklisted) { + super(); + this.nodeId = nodeId; + this.blacklisted = blacklisted; + } - public String getNodeId() { - return nodeId; - } + public String getNodeId() { + return nodeId; + } - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } - public String getBlacklisted() { - return blacklisted; - } + public String getBlacklisted() { + return blacklisted; + } - public void setBlacklisted(String blacklisted) { - this.blacklisted = blacklisted; - } + public void setBlacklisted(String blacklisted) { + this.blacklisted = blacklisted; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NearRTRIC.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NearRTRIC.java index c2fbd06..5a716e9 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NearRTRIC.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NearRTRIC.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; @@ -35,100 +36,100 @@ import javax.persistence.Table; @Entity @Table(name = "NEARRTRIC") public class NearRTRIC implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "NEARRTRICID") - private Integer nearRTRICId; - @Column(name = "GNBID") - private Integer gNBId; - @ElementCollection(targetClass = String.class) - @CollectionTable(name = "TRACKINGAREA", joinColumns = @JoinColumn(name = "nearrtricid")) - private List<String> trackingArea; - @Column(name = "RESOURCETYPE") - private String resourceType; - @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) - private List<GNBCUCPFunction> gNBCUCPList; - @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) - private List<GNBCUUPFunction> gNBCUUPList; - @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) - private List<GNBDUFunction> gNBDUList; - @ElementCollection(targetClass = String.class) - @CollectionTable(name = "RANNFNSSI", joinColumns = @JoinColumn(name = "nearrtricid")) - private List<String> ranNFNSSIList; - @ElementCollection - @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "nearrtricid")) - private List<PLMNInfo> pLMNInfoList; - - public Integer getNearRTRICId() { - return nearRTRICId; - } - - public void setNearRTRICId(Integer nearRTRICId) { - this.nearRTRICId = nearRTRICId; - } - - public Integer getgNBId() { - return gNBId; - } - - public void setgNBId(Integer gNBId) { - this.gNBId = gNBId; - } - - public List<String> getTrackingArea() { - return trackingArea; - } - - public void setTrackingArea(List<String> trackingArea) { - this.trackingArea = trackingArea; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public List<GNBCUCPFunction> getgNBCUCPList() { - return gNBCUCPList; - } - - public void setgNBCUCPList(List<GNBCUCPFunction> gNBCUCPList) { - this.gNBCUCPList = gNBCUCPList; - } - - public List<GNBCUUPFunction> getgNBCUUPList() { - return gNBCUUPList; - } - - public void setgNBCUUPList(List<GNBCUUPFunction> gNBCUUPList) { - this.gNBCUUPList = gNBCUUPList; - } - - public List<GNBDUFunction> getgNBDUList() { - return gNBDUList; - } - - public void setgNBDUList(List<GNBDUFunction> gNBDUList) { - this.gNBDUList = gNBDUList; - } - - public List<PLMNInfo> getpLMNInfoList() { - return pLMNInfoList; - } - - public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { - this.pLMNInfoList = pLMNInfoList; - } - - public List<String> getRanNFNSSIList() { - return ranNFNSSIList; - } - - public void setRanNFNSSIList(List<String> ranNFNSSIList) { - this.ranNFNSSIList = ranNFNSSIList; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "NEARRTRICID") + private Integer nearRTRICId; + @Column(name = "GNBID") + private Integer gNBId; + @ElementCollection(targetClass = String.class) + @CollectionTable(name = "TRACKINGAREA", joinColumns = @JoinColumn(name = "nearrtricid")) + private List<String> trackingArea; + @Column(name = "RESOURCETYPE") + private String resourceType; + @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) + private List<GNBCUCPFunction> gNBCUCPList; + @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) + private List<GNBCUUPFunction> gNBCUUPList; + @OneToMany(mappedBy = "nearRTRIC", cascade = CascadeType.ALL) + private List<GNBDUFunction> gNBDUList; + @ElementCollection(targetClass = String.class) + @CollectionTable(name = "RANNFNSSI", joinColumns = @JoinColumn(name = "nearrtricid")) + private List<String> ranNFNSSIList; + @ElementCollection + @CollectionTable(name = "PLMNINFO", joinColumns = @JoinColumn(name = "nearrtricid")) + private List<PLMNInfo> pLMNInfoList; + + public Integer getNearRTRICId() { + return nearRTRICId; + } + + public void setNearRTRICId(Integer nearRTRICId) { + this.nearRTRICId = nearRTRICId; + } + + public Integer getgNBId() { + return gNBId; + } + + public void setgNBId(Integer gNBId) { + this.gNBId = gNBId; + } + + public List<String> getTrackingArea() { + return trackingArea; + } + + public void setTrackingArea(List<String> trackingArea) { + this.trackingArea = trackingArea; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public List<GNBCUCPFunction> getgNBCUCPList() { + return gNBCUCPList; + } + + public void setgNBCUCPList(List<GNBCUCPFunction> gNBCUCPList) { + this.gNBCUCPList = gNBCUCPList; + } + + public List<GNBCUUPFunction> getgNBCUUPList() { + return gNBCUUPList; + } + + public void setgNBCUUPList(List<GNBCUUPFunction> gNBCUUPList) { + this.gNBCUUPList = gNBCUUPList; + } + + public List<GNBDUFunction> getgNBDUList() { + return gNBDUList; + } + + public void setgNBDUList(List<GNBDUFunction> gNBDUList) { + this.gNBDUList = gNBDUList; + } + + public List<PLMNInfo> getpLMNInfoList() { + return pLMNInfoList; + } + + public void setpLMNInfoList(List<PLMNInfo> pLMNInfoList) { + this.pLMNInfoList = pLMNInfoList; + } + + public List<String> getRanNFNSSIList() { + return ranNFNSSIList; + } + + public void setRanNFNSSIList(List<String> ranNFNSSIList) { + this.ranNFNSSIList = ranNFNSSIList; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java index 4af3166..28764e9 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; import javax.persistence.EmbeddedId; @@ -27,35 +28,35 @@ import javax.persistence.Table; @Table(name = "NeighborDetails") public class NeighborDetails { - @EmbeddedId - private NeihborId neigbor; + @EmbeddedId + private NeihborId neigbor; - private boolean blacklisted; + private boolean blacklisted; - public NeighborDetails() { + public NeighborDetails() { - } + } - public NeighborDetails(NeihborId neigbor, boolean blacklisted) { - super(); - this.neigbor = neigbor; - this.blacklisted = blacklisted; - } + public NeighborDetails(NeihborId neigbor, boolean blacklisted) { + super(); + this.neigbor = neigbor; + this.blacklisted = blacklisted; + } - public NeihborId getNeigbor() { - return neigbor; - } + public NeihborId getNeigbor() { + return neigbor; + } - public void setNeigbor(NeihborId neigbor) { - this.neigbor = neigbor; - } + public void setNeigbor(NeihborId neigbor) { + this.neigbor = neigbor; + } - public boolean isBlacklisted() { - return blacklisted; - } + public boolean isBlacklisted() { + return blacklisted; + } - public void setBlacklisted(boolean blacklisted) { - this.blacklisted = blacklisted; - } + public void setBlacklisted(boolean blacklisted) { + this.blacklisted = blacklisted; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java index a18a55b..c2f9384 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java @@ -17,48 +17,49 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; public class NeighborPmDetails { - private String nbrCellId; - private String kpiName; - private int kpiValue; + private String nbrCellId; + private String kpiName; + private int kpiValue; - public NeighborPmDetails(String nbrCellId, String kpiName, int kpiValue) { - super(); - this.nbrCellId = nbrCellId; - this.kpiName = kpiName; - this.kpiValue = kpiValue; - } + public NeighborPmDetails(String nbrCellId, String kpiName, int kpiValue) { + super(); + this.nbrCellId = nbrCellId; + this.kpiName = kpiName; + this.kpiValue = kpiValue; + } - public NeighborPmDetails() { - super(); - // TODO Auto-generated constructor stub - } + public NeighborPmDetails() { + super(); + // TODO Auto-generated constructor stub + } - public String getNbrCellId() { - return nbrCellId; - } + public String getNbrCellId() { + return nbrCellId; + } - public void setNbrCellId(String nbrCellId) { - this.nbrCellId = nbrCellId; - } + public void setNbrCellId(String nbrCellId) { + this.nbrCellId = nbrCellId; + } - public String getKpiName() { - return kpiName; - } + public String getKpiName() { + return kpiName; + } - public void setKpiName(String kpiName) { - this.kpiName = kpiName; - } + public void setKpiName(String kpiName) { + this.kpiName = kpiName; + } - public int getKpiValue() { - return kpiValue; - } + public int getKpiValue() { + return kpiValue; + } - public void setKpiValue(int kpiValue) { - this.kpiValue = kpiValue; - } + public void setKpiValue(int kpiValue) { + this.kpiValue = kpiValue; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java index 3bef66d..92b8771 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.models; import java.io.Serializable; @@ -26,65 +27,65 @@ import javax.persistence.Embeddable; @Embeddable public class NeihborId implements Serializable { - - private static final long serialVersionUID = 1L; - @Column(name = "sourceCellNodeId") - private String sourceCellNodeId; + private static final long serialVersionUID = 1L; + + @Column(name = "sourceCellNodeId") + private String sourceCellNodeId; - @Column(name = "neighborCellNodeId") - private String neighborCell; + @Column(name = "neighborCellNodeId") + private String neighborCell; - public NeihborId() { - } + public NeihborId() { + } - public NeihborId(String sourceCellNodeId, String neighborCell) { - this.sourceCellNodeId = sourceCellNodeId; - this.neighborCell = neighborCell; - } + public NeihborId(String sourceCellNodeId, String neighborCell) { + this.sourceCellNodeId = sourceCellNodeId; + this.neighborCell = neighborCell; + } - public String getSourceCellNodeId() { - return sourceCellNodeId; - } + public String getSourceCellNodeId() { + return sourceCellNodeId; + } - public String getNeighborCell() { - return neighborCell; - } + public String getNeighborCell() { + return neighborCell; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((neighborCell == null) ? 0 : neighborCell.hashCode()); - result = prime * result + ((sourceCellNodeId == null) ? 0 : sourceCellNodeId.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((neighborCell == null) ? 0 : neighborCell.hashCode()); + result = prime * result + ((sourceCellNodeId == null) ? 0 : sourceCellNodeId.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - NeihborId other = (NeihborId) obj; - if (neighborCell == null) { - if (other.neighborCell != null) { - return false; - } - } else if (!neighborCell.equals(other.neighborCell)) - return false; - if (sourceCellNodeId == null) { - if (other.sourceCellNodeId != null) { - return false; - } - } else if (!sourceCellNodeId.equals(other.sourceCellNodeId)) { - return false; - } - return true; - } -}
\ No newline at end of file + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + NeihborId other = (NeihborId) obj; + if (neighborCell == null) { + if (other.neighborCell != null) { + return false; + } + } else if (!neighborCell.equals(other.neighborCell)) + return false; + if (sourceCellNodeId == null) { + if (other.sourceCellNodeId != null) { + return false; + } + } else if (!sourceCellNodeId.equals(other.sourceCellNodeId)) { + return false; + } + return true; + } +} diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java index e0a1dc9..a33f616 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java @@ -25,8 +25,8 @@ import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; @@ -34,66 +34,66 @@ import javax.persistence.Table; @Table(name = "NetconfServers") public class NetconfServers { - @Id - @Column(name = "serverId", unique = true, nullable = false, length = 20) - private String serverId; - - private String ip; - private String netconfPort; - - @OneToMany(targetEntity = CellDetails.class,fetch = FetchType.EAGER, cascade = CascadeType.ALL) - private Set<CellDetails> cells; - - public NetconfServers() { - - } - - /** - * A constructor for Netconf server table class. - * - * @param serverId server Id of the netconf server - * @param ip ip address of the netconf server - * @param netconfPort port number of the netconf server - * @param cells List of cells belonging to the netconf server - */ - public NetconfServers(String serverId, String ip, String netconfPort, Set<CellDetails> cells) { - super(); - this.serverId = serverId; - this.ip = ip; - this.netconfPort = netconfPort; - this.cells = cells; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getNetconfPort() { - return netconfPort; - } - - public void setNetconfPort(String netconfPort) { - this.netconfPort = netconfPort; - } - - public Set<CellDetails> getCells() { - return cells; - } - - public void setCells(Set<CellDetails> cells) { - this.cells = cells; - } + @Id + @Column(name = "serverId", unique = true, nullable = false, length = 20) + private String serverId; + + private String ip; + private String netconfPort; + + @OneToMany(targetEntity = CellDetails.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL) + private Set<CellDetails> cells; + + public NetconfServers() { + + } + + /** + * A constructor for Netconf server table class. + * + * @param serverId server Id of the netconf server + * @param ip ip address of the netconf server + * @param netconfPort port number of the netconf server + * @param cells List of cells belonging to the netconf server + */ + public NetconfServers(String serverId, String ip, String netconfPort, Set<CellDetails> cells) { + super(); + this.serverId = serverId; + this.ip = ip; + this.netconfPort = netconfPort; + this.cells = cells; + } + + public String getServerId() { + return serverId; + } + + public void setServerId(String serverId) { + this.serverId = serverId; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getNetconfPort() { + return netconfPort; + } + + public void setNetconfPort(String netconfPort) { + this.netconfPort = netconfPort; + } + + public Set<CellDetails> getCells() { + return cells; + } + + public void setCells(Set<CellDetails> cells) { + this.cells = cells; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java index 5d6e82e..86a83de 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java @@ -20,83 +20,83 @@ package org.onap.ransim.rest.api.models; +import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Id; import javax.persistence.GeneratedValue; -import javax.persistence.Column; import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; @Entity @Table(name = "OperationLog") public class OperationLog { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int rowId; - private long time; - private String nodeId; - private String source; - - @Column(name = "message", length = 300) - private String message; - private String fieldName; - private String operation; - - public int getRowId() { - return rowId; - } - - public void setRowId(int rowId) { - this.rowId = rowId; - } - - public long getTime() { - return time; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public void setTime(long time) { - this.time = time; - } - - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getFieldName() { - return fieldName; - } - - public void setFieldName(String fieldName) { - this.fieldName = fieldName; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int rowId; + private long time; + private String nodeId; + private String source; + + @Column(name = "message", length = 300) + private String message; + private String fieldName; + private String operation; + + public int getRowId() { + return rowId; + } + + public void setRowId(int rowId) { + this.rowId = rowId; + } + + public long getTime() { + return time; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public void setTime(long time) { + this.time = time; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfo.java index a45ad77..a7121bd 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfo.java @@ -36,28 +36,28 @@ import javax.persistence.Table; @Embeddable @Table(name = "PLMNINFO") public class PLMNInfo implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Column(name = "PLMNID") - private String pLMNId; + @Column(name = "PLMNID") + private String pLMNId; - @Embedded - private SNSSAI sNSSAI; + @Embedded + private SNSSAI sNSSAI; - public String getpLMNId() { - return pLMNId; - } + public String getpLMNId() { + return pLMNId; + } - public void setpLMNId(String pLMNId) { - this.pLMNId = pLMNId; - } + public void setpLMNId(String pLMNId) { + this.pLMNId = pLMNId; + } - public SNSSAI getsNSSAI() { - return sNSSAI; - } + public SNSSAI getsNSSAI() { + return sNSSAI; + } - public void setsNSSAI(SNSSAI sNSSAI) { - this.sNSSAI = sNSSAI; - } + public void setsNSSAI(SNSSAI sNSSAI) { + this.sNSSAI = sNSSAI; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java index af16d44..fd674bc 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java @@ -21,94 +21,93 @@ package org.onap.ransim.rest.api.models; public class PLMNInfoModel { - private String pLMNId; - private String snssai; - private String status; - private String gnbType; - private int gnbId; - private int nrCellId; - private String nearrtricid; - private long maxNumberOfConns; - - public PLMNInfoModel() { - - } - - public PLMNInfoModel(String pLMNId, String snssai, String status, String gnbType, int gnbId, int nrCellId, - String nearrtricid, long maxNumberOfConns) { - super(); - this.pLMNId = pLMNId; - this.snssai = snssai; - this.status = status; - this.gnbType = gnbType; - this.gnbId = gnbId; - this.nrCellId = nrCellId; - this.nearrtricid = nearrtricid; - this.maxNumberOfConns = maxNumberOfConns; - } - - public String getpLMNId() { - return pLMNId; - } - - public void setpLMNId(String pLMNId) { - this.pLMNId = pLMNId; - } - - public String getSnssai() { - return snssai; - } - - public void setSnssai(String snssai) { - this.snssai = snssai; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getGnbType() { - return gnbType; - } - - public void setGnbType(String gnbType) { - this.gnbType = gnbType; - } - - public int getGnbId() { - return gnbId; - } - - public void setGnbId(int gnbId) { - this.gnbId = gnbId; - } - - public int getNrCellId() { - return nrCellId; - } - - public void setNrCellId(int nrCellId) { - this.nrCellId = nrCellId; - } - - public String getNearrtricid() { - return nearrtricid; - } - - public void setNearrtricid(String nearrtricid) { - this.nearrtricid = nearrtricid; - } - - public long getMaxNumberOfConns() { - return maxNumberOfConns; - } - - public void setMaxNumberOfConns(long maxNumberOfConns) { - this.maxNumberOfConns = maxNumberOfConns; - } + private String pLMNId; + private String snssai; + private String status; + private String gnbType; + private int gnbId; + private int nrCellId; + private String nearrtricid; + private long maxNumberOfConns; + + public PLMNInfoModel() { + + } + + public PLMNInfoModel(String pLMNId, String snssai, String status, String gnbType, int gnbId, int nrCellId, + String nearrtricid, long maxNumberOfConns) { + super(); + this.pLMNId = pLMNId; + this.snssai = snssai; + this.status = status; + this.gnbType = gnbType; + this.gnbId = gnbId; + this.nrCellId = nrCellId; + this.nearrtricid = nearrtricid; + this.maxNumberOfConns = maxNumberOfConns; + } + + public String getpLMNId() { + return pLMNId; + } + + public void setpLMNId(String pLMNId) { + this.pLMNId = pLMNId; + } + + public String getSnssai() { + return snssai; + } + + public void setSnssai(String snssai) { + this.snssai = snssai; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGnbType() { + return gnbType; + } + + public void setGnbType(String gnbType) { + this.gnbType = gnbType; + } + + public int getGnbId() { + return gnbId; + } + + public void setGnbId(int gnbId) { + this.gnbId = gnbId; + } + + public int getNrCellId() { + return nrCellId; + } + + public void setNrCellId(int nrCellId) { + this.nrCellId = nrCellId; + } + + public String getNearrtricid() { + return nearrtricid; + } + + public void setNearrtricid(String nearrtricid) { + this.nearrtricid = nearrtricid; + } + + public long getMaxNumberOfConns() { + return maxNumberOfConns; + } + + public void setMaxNumberOfConns(long maxNumberOfConns) { + this.maxNumberOfConns = maxNumberOfConns; + } } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java index 9f0ad6e..6b273ae 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java @@ -24,24 +24,24 @@ import java.util.List; public class PmDataDump { - private List<PmParameters> kpiDump; + private List<PmParameters> kpiDump; - public PmDataDump() { - super(); - // TODO Auto-generated constructor stub - } + public PmDataDump() { + super(); + // TODO Auto-generated constructor stub + } - public PmDataDump(List<PmParameters> kpiDump) { - super(); - this.kpiDump = kpiDump; - } + public PmDataDump(List<PmParameters> kpiDump) { + super(); + this.kpiDump = kpiDump; + } - public List<PmParameters> getKpiDump() { - return kpiDump; - } + public List<PmParameters> getKpiDump() { + return kpiDump; + } - public void setKpiDump(List<PmParameters> kpiDump) { - this.kpiDump = kpiDump; - } + public void setKpiDump(List<PmParameters> kpiDump) { + this.kpiDump = kpiDump; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java index 6ff4721..3e368d4 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java @@ -22,77 +22,77 @@ package org.onap.ransim.rest.api.models; public class PmParameters { - private String parameter1; - private String successValue1; - private String badValue1; - private String poorValue1; - private String parameter2; - private String successValue2; - private String badValue2; - private String poorValue2; - - public String getParameter1() { - return parameter1; - } - - public void setParameter1(String parameter1) { - this.parameter1 = parameter1; - } - - public String getSuccessValue1() { - return successValue1; - } - - public void setSuccessValue1(String successValue1) { - this.successValue1 = successValue1; - } - - public String getBadValue1() { - return badValue1; - } - - public void setBadValue1(String badValue1) { - this.badValue1 = badValue1; - } - - public String getPoorValue1() { - return poorValue1; - } - - public void setPoorValue1(String poorValue1) { - this.poorValue1 = poorValue1; - } - - public String getParameter2() { - return parameter2; - } - - public void setParameter2(String parameter2) { - this.parameter2 = parameter2; - } - - public String getSuccessValue2() { - return successValue2; - } - - public void setSuccessValue2(String successValue2) { - this.successValue2 = successValue2; - } - - public String getBadValue2() { - return badValue2; - } - - public void setBadValue2(String badValue2) { - this.badValue2 = badValue2; - } - - public String getPoorValue2() { - return poorValue2; - } - - public void setPoorValue2(String poorValue2) { - this.poorValue2 = poorValue2; - } + private String parameter1; + private String successValue1; + private String badValue1; + private String poorValue1; + private String parameter2; + private String successValue2; + private String badValue2; + private String poorValue2; + + public String getParameter1() { + return parameter1; + } + + public void setParameter1(String parameter1) { + this.parameter1 = parameter1; + } + + public String getSuccessValue1() { + return successValue1; + } + + public void setSuccessValue1(String successValue1) { + this.successValue1 = successValue1; + } + + public String getBadValue1() { + return badValue1; + } + + public void setBadValue1(String badValue1) { + this.badValue1 = badValue1; + } + + public String getPoorValue1() { + return poorValue1; + } + + public void setPoorValue1(String poorValue1) { + this.poorValue1 = poorValue1; + } + + public String getParameter2() { + return parameter2; + } + + public void setParameter2(String parameter2) { + this.parameter2 = parameter2; + } + + public String getSuccessValue2() { + return successValue2; + } + + public void setSuccessValue2(String successValue2) { + this.successValue2 = successValue2; + } + + public String getBadValue2() { + return badValue2; + } + + public void setBadValue2(String badValue2) { + this.badValue2 = badValue2; + } + + public String getPoorValue2() { + return poorValue2; + } + + public void setPoorValue2(String poorValue2) { + this.poorValue2 = poorValue2; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RANSliceInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RANSliceInfo.java index 5ec30c8..b42cd51 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RANSliceInfo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RANSliceInfo.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; @@ -35,106 +36,106 @@ import javax.persistence.Table; @Entity(name = "RANINVENTORY") @Table(name = "RANINVENTORY") public class RANSliceInfo implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "RANNFNSSIID") - private String ranNFNSSIId; - @ElementCollection - @CollectionTable(name = "rannssi", joinColumns = @JoinColumn(name = "rannfnssiid")) - private List<String> ranNSSIList; - @ElementCollection - @CollectionTable(name = "nssai", joinColumns = @JoinColumn(name = "rannfnssiid")) - private List<String> nSSAIList; - @OneToMany(mappedBy = "rANSliceInventory", cascade = CascadeType.ALL) - private List<SliceProfile> sliceProfilesList; - @Column(name = "TALIST") - private String trackingAreaList; - @Column(name = "SUBNETSTATUS") - private String subnetStatus; - @Column(name = "NSSTID") - private String nsstId; - @Column(name = "SLICETYPE") - private String sliceType; - @Column(name = "ISSHAREABLE") - private String isShareable; - - public String getRanNFNSSIId() { - return ranNFNSSIId; - } - - public void setRanNFNSSIId(String ranNFNSSIId) { - this.ranNFNSSIId = ranNFNSSIId; - } - - public List<String> getRanNSSIList() { - return ranNSSIList; - } - - public void setRanNSSIList(List<String> ranNSSIList) { - this.ranNSSIList = ranNSSIList; - } - - public List<SliceProfile> getSliceProfilesList() { - return sliceProfilesList; - } - - public void setSliceProfilesList(List<SliceProfile> sliceProfilesList) { - this.sliceProfilesList = sliceProfilesList; - } - - public String getSubnetStatus() { - return subnetStatus; - } - - public void setSubnetStatus(String subnetStatus) { - this.subnetStatus = subnetStatus; - } - - public String getNsstId() { - return nsstId; - } - - public void setNsstId(String nsstId) { - this.nsstId = nsstId; - } - - public String getSliceType() { - return sliceType; - } - - public void setSliceType(String sliceType) { - this.sliceType = sliceType; - } - - public String getIsShareable() { - return isShareable; - } - - public void setIsShareable(String isShareable) { - this.isShareable = isShareable; - } - - public List<String> getnSSAIList() { - return nSSAIList; - } - - public void setnSSAIList(List<String> nSSAIList) { - this.nSSAIList = nSSAIList; - } - - public String getTrackingAreaList() { - return trackingAreaList; - } - - public void setTrackingAreaList(String trackingAreaList) { - this.trackingAreaList = trackingAreaList; - } - - @Override - public String toString() { - return "RANSliceInfo [ranNFNSSIId=" + ranNFNSSIId + ", ranNSSIList=" + ranNSSIList + ", nSSAIList=" + nSSAIList - + ", sliceProfilesList=" + sliceProfilesList + ", trackingAreaList=" + trackingAreaList - + ", subnetStatus=" + subnetStatus + ", nsstId=" + nsstId + ", sliceType=" + sliceType - + ", isShareable=" + isShareable + "]"; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "RANNFNSSIID") + private String ranNFNSSIId; + @ElementCollection + @CollectionTable(name = "rannssi", joinColumns = @JoinColumn(name = "rannfnssiid")) + private List<String> ranNSSIList; + @ElementCollection + @CollectionTable(name = "nssai", joinColumns = @JoinColumn(name = "rannfnssiid")) + private List<String> nSSAIList; + @OneToMany(mappedBy = "rANSliceInventory", cascade = CascadeType.ALL) + private List<SliceProfile> sliceProfilesList; + @Column(name = "TALIST") + private String trackingAreaList; + @Column(name = "SUBNETSTATUS") + private String subnetStatus; + @Column(name = "NSSTID") + private String nsstId; + @Column(name = "SLICETYPE") + private String sliceType; + @Column(name = "ISSHAREABLE") + private String isShareable; + + public String getRanNFNSSIId() { + return ranNFNSSIId; + } + + public void setRanNFNSSIId(String ranNFNSSIId) { + this.ranNFNSSIId = ranNFNSSIId; + } + + public List<String> getRanNSSIList() { + return ranNSSIList; + } + + public void setRanNSSIList(List<String> ranNSSIList) { + this.ranNSSIList = ranNSSIList; + } + + public List<SliceProfile> getSliceProfilesList() { + return sliceProfilesList; + } + + public void setSliceProfilesList(List<SliceProfile> sliceProfilesList) { + this.sliceProfilesList = sliceProfilesList; + } + + public String getSubnetStatus() { + return subnetStatus; + } + + public void setSubnetStatus(String subnetStatus) { + this.subnetStatus = subnetStatus; + } + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getSliceType() { + return sliceType; + } + + public void setSliceType(String sliceType) { + this.sliceType = sliceType; + } + + public String getIsShareable() { + return isShareable; + } + + public void setIsShareable(String isShareable) { + this.isShareable = isShareable; + } + + public List<String> getnSSAIList() { + return nSSAIList; + } + + public void setnSSAIList(List<String> nSSAIList) { + this.nSSAIList = nSSAIList; + } + + public String getTrackingAreaList() { + return trackingAreaList; + } + + public void setTrackingAreaList(String trackingAreaList) { + this.trackingAreaList = trackingAreaList; + } + + @Override + public String toString() { + return "RANSliceInfo [ranNFNSSIId=" + ranNFNSSIId + ", ranNSSIList=" + ranNSSIList + ", nSSAIList=" + nSSAIList + + ", sliceProfilesList=" + sliceProfilesList + ", trackingAreaList=" + trackingAreaList + + ", subnetStatus=" + subnetStatus + ", nsstId=" + nsstId + ", sliceType=" + sliceType + + ", isShareable=" + isShareable + "]"; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyMember.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyMember.java index aced9cf..7e8d1bb 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyMember.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyMember.java @@ -21,6 +21,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -30,36 +31,36 @@ import javax.persistence.Table; @Entity @Table(name = "RRMPOLICYMEMBER") public class RRMPolicyMember implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "PLMNID") - private String pLMNId; - @Column(name = "SNSSAI") - private String sNSSAI; - @ManyToOne - private RRMPolicyRatio rrmPolicy; + private static final long serialVersionUID = 1L; + @Id + @Column(name = "PLMNID") + private String pLMNId; + @Column(name = "SNSSAI") + private String sNSSAI; + @ManyToOne + private RRMPolicyRatio rrmPolicy; - public String getpLMNId() { - return pLMNId; - } + public String getpLMNId() { + return pLMNId; + } - public void setpLMNId(String pLMNId) { - this.pLMNId = pLMNId; - } + public void setpLMNId(String pLMNId) { + this.pLMNId = pLMNId; + } - public String getsNSSAI() { - return sNSSAI; - } + public String getsNSSAI() { + return sNSSAI; + } - public void setsNSSAI(String sNSSAI) { - this.sNSSAI = sNSSAI; - } + public void setsNSSAI(String sNSSAI) { + this.sNSSAI = sNSSAI; + } - public RRMPolicyRatio getRrmPolicy() { - return rrmPolicy; - } + public RRMPolicyRatio getRrmPolicy() { + return rrmPolicy; + } - public void setRrmPolicy(RRMPolicyRatio rrmPolicy) { - this.rrmPolicy = rrmPolicy; - } + public void setRrmPolicy(RRMPolicyRatio rrmPolicy) { + this.rrmPolicy = rrmPolicy; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyRatio.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyRatio.java index 27c5d9c..33546c3 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyRatio.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/RRMPolicyRatio.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.ElementCollection; @@ -33,98 +34,97 @@ import javax.persistence.Table; @Entity @Table(name = "RRMPOLICYRATIO") public class RRMPolicyRatio implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "RRMPOLICYID") - private Integer rrmPolicyID; - @Column(name = "RESOURCEID") - private String resourceID; - @Column(name = "RESOURCETYPE") - private String resourceType; - @Column(name = "SLICETYPE") - private String sliceType; -// @OneToMany(mappedBy = "rrmPolicy", cascade={CascadeType.PERSIST,CascadeType.REMOVE}) - @OneToMany(mappedBy = "rrmPolicy", cascade = CascadeType.ALL) - private List<RRMPolicyMember> rRMPolicyMemberList; - @Column(name = "QUOTATYPE") - private String quotaType; - @Column(name = "RRMPOLICYMAXRATIO") - private Integer rRMPolicyMaxRatio; - @Column(name = "RRMPOLICYMINRATIO") - private Integer rRMPolicyMinRatio; - @Column(name = "RRMPOLICYDEDICATEDRATIO") - private Integer rRMPolicyDedicatedRatio; - - public Integer getRrmPolicyID() { - return rrmPolicyID; - } - - public void setRrmPolicyID(Integer rrmPolicyID) { - this.rrmPolicyID = rrmPolicyID; - } - - public String getResourceID() { - return resourceID; - } - - public void setResourceID(String resourceID) { - this.resourceID = resourceID; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getSliceType() { - return sliceType; - } - - public void setSliceType(String sliceType) { - this.sliceType = sliceType; - } - - public List<RRMPolicyMember> getrRMPolicyMemberList() { - return rRMPolicyMemberList; - } - - public void setrRMPolicyMemberList(List<RRMPolicyMember> rRMPolicyMemberList) { - this.rRMPolicyMemberList = rRMPolicyMemberList; - } - - public String getQuotaType() { - return quotaType; - } - - public void setQuotaType(String quotaType) { - this.quotaType = quotaType; - } - - public Integer getrRMPolicyMaxRatio() { - return rRMPolicyMaxRatio; - } - - public void setrRMPolicyMaxRatio(Integer rRMPolicyMaxRatio) { - this.rRMPolicyMaxRatio = rRMPolicyMaxRatio; - } - - public Integer getrRMPolicyMinRatio() { - return rRMPolicyMinRatio; - } - - public void setrRMPolicyMinRatio(Integer rRMPolicyMinRatio) { - this.rRMPolicyMinRatio = rRMPolicyMinRatio; - } - - public Integer getrRMPolicyDedicatedRatio() { - return rRMPolicyDedicatedRatio; - } - - public void setrRMPolicyDedicatedRatio(Integer rRMPolicyDedicatedRatio) { - this.rRMPolicyDedicatedRatio = rRMPolicyDedicatedRatio; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "RRMPOLICYID") + private Integer rrmPolicyID; + @Column(name = "RESOURCEID") + private String resourceID; + @Column(name = "RESOURCETYPE") + private String resourceType; + @Column(name = "SLICETYPE") + private String sliceType; + // @OneToMany(mappedBy = "rrmPolicy", cascade={CascadeType.PERSIST,CascadeType.REMOVE}) + @OneToMany(mappedBy = "rrmPolicy", cascade = CascadeType.ALL) + private List<RRMPolicyMember> rRMPolicyMemberList; + @Column(name = "QUOTATYPE") + private String quotaType; + @Column(name = "RRMPOLICYMAXRATIO") + private Integer rRMPolicyMaxRatio; + @Column(name = "RRMPOLICYMINRATIO") + private Integer rRMPolicyMinRatio; + @Column(name = "RRMPOLICYDEDICATEDRATIO") + private Integer rRMPolicyDedicatedRatio; + + public Integer getRrmPolicyID() { + return rrmPolicyID; + } + + public void setRrmPolicyID(Integer rrmPolicyID) { + this.rrmPolicyID = rrmPolicyID; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getSliceType() { + return sliceType; + } + + public void setSliceType(String sliceType) { + this.sliceType = sliceType; + } + + public List<RRMPolicyMember> getrRMPolicyMemberList() { + return rRMPolicyMemberList; + } + + public void setrRMPolicyMemberList(List<RRMPolicyMember> rRMPolicyMemberList) { + this.rRMPolicyMemberList = rRMPolicyMemberList; + } + + public String getQuotaType() { + return quotaType; + } + + public void setQuotaType(String quotaType) { + this.quotaType = quotaType; + } + + public Integer getrRMPolicyMaxRatio() { + return rRMPolicyMaxRatio; + } + + public void setrRMPolicyMaxRatio(Integer rRMPolicyMaxRatio) { + this.rRMPolicyMaxRatio = rRMPolicyMaxRatio; + } + + public Integer getrRMPolicyMinRatio() { + return rRMPolicyMinRatio; + } + + public void setrRMPolicyMinRatio(Integer rRMPolicyMinRatio) { + this.rRMPolicyMinRatio = rRMPolicyMinRatio; + } + + public Integer getrRMPolicyDedicatedRatio() { + return rRMPolicyDedicatedRatio; + } + + public void setrRMPolicyDedicatedRatio(Integer rRMPolicyDedicatedRatio) { + this.rRMPolicyDedicatedRatio = rRMPolicyDedicatedRatio; + } } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SNSSAI.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SNSSAI.java index 1c35546..e33a871 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SNSSAI.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SNSSAI.java @@ -21,6 +21,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Embedded; @@ -32,57 +33,57 @@ import javax.persistence.Table; @Embeddable @Table(name = "SNSSAI") public class SNSSAI implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "sNSSAI") - private String sNSSAI; - @Column(name = "STATUS") - private String status; - @Column(name = "GLOBALSUBSCRIBERID") - private String globalSubscriberId; - @Column(name = "SUBSCRIPTIONSERVICETYPE") - private String subscriptionServiceType; - @Embedded - private NSSAIConfig configData; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } - - public String getSubscriptionServiceType() { - return subscriptionServiceType; - } - - public void setSubscriptionServiceType(String subscriptionServiceType) { - this.subscriptionServiceType = subscriptionServiceType; - } - - public NSSAIConfig getConfigData() { - return configData; - } - - public void setConfigData(NSSAIConfig configData) { - this.configData = configData; - } - - public String getsNSSAI() { - return sNSSAI; - } - - public void setsNSSAI(String sNSSAI) { - this.sNSSAI = sNSSAI; - } + private static final long serialVersionUID = 1L; + + @Column(name = "sNSSAI") + private String sNSSAI; + @Column(name = "STATUS") + private String status; + @Column(name = "GLOBALSUBSCRIBERID") + private String globalSubscriberId; + @Column(name = "SUBSCRIPTIONSERVICETYPE") + private String subscriptionServiceType; + @Embedded + private NSSAIConfig configData; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public NSSAIConfig getConfigData() { + return configData; + } + + public void setConfigData(NSSAIConfig configData) { + this.configData = configData; + } + + public String getsNSSAI() { + return sNSSAI; + } + + public void setsNSSAI(String sNSSAI) { + this.sNSSAI = sNSSAI; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java index 1738e65..e3f95d6 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java @@ -22,28 +22,28 @@ package org.onap.ransim.rest.api.models; public class SetCollisionReq { - private boolean collision; + private boolean collision; - /** - * A constructor for SetCollisionReq. - * - * @param collision to set if the new simulation has collision between the cells - */ - public SetCollisionReq(boolean collision) { - super(); - this.collision = collision; - } + /** + * A constructor for SetCollisionReq. + * + * @param collision to set if the new simulation has collision between the cells + */ + public SetCollisionReq(boolean collision) { + super(); + this.collision = collision; + } - public SetCollisionReq() { + public SetCollisionReq() { - } + } - public boolean isCollision() { - return collision; - } + public boolean isCollision() { + return collision; + } - public void setCollision(boolean collision) { - this.collision = collision; - } + public void setCollision(boolean collision) { + this.collision = collision; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java index bd99dee..6116a8e 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java @@ -22,87 +22,87 @@ package org.onap.ransim.rest.api.models; public class SetConstants { - private int gridSize; - private int gridType; - private boolean collision; - - private int processCapacity; - private int numberOfMachines; - private String serverIdPrefix; - - public SetConstants() { - - } - - /** - * A constructor for SetConstants. - * - * @param gridSize grid dimension for the topology (number of cells - * along the side) - * @param gridType honeycomb or square grid - * @param collision to set if the new simulation has collision between - * the cells - * @param processCapacity number of netconf servers - * @param numberOfMachines number of machines running in one netconf server - * @param serverIdPrefix server id prefix - */ - public SetConstants(int gridSize, int gridType, boolean collision, int processCapacity, int numberOfMachines, - String serverIdPrefix) { - super(); - this.gridSize = gridSize; - this.gridType = gridType; - this.collision = collision; - this.processCapacity = processCapacity; - this.numberOfMachines = numberOfMachines; - this.serverIdPrefix = serverIdPrefix; - } - - public int getGridSize() { - return gridSize; - } - - public void setGridSize(int gridSize) { - this.gridSize = gridSize; - } - - public int getGridType() { - return gridType; - } - - public void setGridType(int gridType) { - this.gridType = gridType; - } - - public boolean isCollision() { - return collision; - } - - public void setCollision(boolean collision) { - this.collision = collision; - } - - public int getProcessCapacity() { - return processCapacity; - } - - public void setProcessCapacity(int processCapacity) { - this.processCapacity = processCapacity; - } - - public int getNumberOfMachines() { - return numberOfMachines; - } - - public void setNumberOfMachines(int numberOfMachines) { - this.numberOfMachines = numberOfMachines; - } - - public String getServerIdPrefix() { - return serverIdPrefix; - } - - public void setServerIdPrefix(String serverIdPrefix) { - this.serverIdPrefix = serverIdPrefix; - } + private int gridSize; + private int gridType; + private boolean collision; + + private int processCapacity; + private int numberOfMachines; + private String serverIdPrefix; + + public SetConstants() { + + } + + /** + * A constructor for SetConstants. + * + * @param gridSize grid dimension for the topology (number of cells + * along the side) + * @param gridType honeycomb or square grid + * @param collision to set if the new simulation has collision between + * the cells + * @param processCapacity number of netconf servers + * @param numberOfMachines number of machines running in one netconf server + * @param serverIdPrefix server id prefix + */ + public SetConstants(int gridSize, int gridType, boolean collision, int processCapacity, int numberOfMachines, + String serverIdPrefix) { + super(); + this.gridSize = gridSize; + this.gridType = gridType; + this.collision = collision; + this.processCapacity = processCapacity; + this.numberOfMachines = numberOfMachines; + this.serverIdPrefix = serverIdPrefix; + } + + public int getGridSize() { + return gridSize; + } + + public void setGridSize(int gridSize) { + this.gridSize = gridSize; + } + + public int getGridType() { + return gridType; + } + + public void setGridType(int gridType) { + this.gridType = gridType; + } + + public boolean isCollision() { + return collision; + } + + public void setCollision(boolean collision) { + this.collision = collision; + } + + public int getProcessCapacity() { + return processCapacity; + } + + public void setProcessCapacity(int processCapacity) { + this.processCapacity = processCapacity; + } + + public int getNumberOfMachines() { + return numberOfMachines; + } + + public void setNumberOfMachines(int numberOfMachines) { + this.numberOfMachines = numberOfMachines; + } + + public String getServerIdPrefix() { + return serverIdPrefix; + } + + public void setServerIdPrefix(String serverIdPrefix) { + this.serverIdPrefix = serverIdPrefix; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SliceProfile.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SliceProfile.java index d8f280b..c65a22e 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SliceProfile.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SliceProfile.java @@ -22,6 +22,7 @@ package org.onap.ransim.rest.api.models; import java.io.Serializable; import java.util.List; + import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; @@ -34,141 +35,141 @@ import javax.persistence.Table; @Entity @Table(name = "SLICEPROFILE") public class SliceProfile implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name = "SLICEPROFILEID") - private String sliceProfileId; - @Column(name = "SNSSAI") - private String sNSSAI; - @Column(name = "PLMNIDLIST") - private String pLMNIdList; - @Column(name = "MAXNOOFUES") - private Integer maxNumberofUEs; - @Column(name = "LATENCY") - private Integer latency; - @Column(name = "DLTHPTPERSLICE") - private Integer dLThptPerSlice; - @Column(name = "ULTHPTPERSLICE") - private Integer uLThptPerSlice; - @Column(name = "MAXNUMBEROFCONNS") - private Integer maxNumberofConns; - - public Integer getdLThptPerSlice() { - return dLThptPerSlice; - } - - public void setdLThptPerSlice(Integer dLThptPerSlice) { - this.dLThptPerSlice = dLThptPerSlice; - } - - public Integer getuLThptPerSlice() { - return uLThptPerSlice; - } - - public void setuLThptPerSlice(Integer uLThptPerSlice) { - this.uLThptPerSlice = uLThptPerSlice; - } - - public Integer getMaxNumberofConns() { - return maxNumberofConns; - } - - public void setMaxNumberofConns(Integer maxNumberofConns) { - this.maxNumberofConns = maxNumberofConns; - } - - public String getCoverageAreaList() { - return coverageAreaList; - } - - /* - * @Column(name="EXPDATARATEDL") private Integer expDataRateDL; - * - * @Column(name="EXPDATARATEUL") private Integer expDataRateUL; - * - * @Column(name="MAXNUMBEROFPDUSESSIONS") private Integer - * maxNumberofPDUSessions; - */ - @Column(name = "UEMOBILITYLEVEL") - private String uEMobilityLevel; - @Column(name = "RESOURCESHARINGLEVEL") - private String resourceSharingLevel; - // @ElementCollection - // @CollectionTable(name="coveragearealist", joinColumns = - // @JoinColumn(name="sliceprofileid")) - @Column(name = "coveragearealist") - private String coverageAreaList; - @ManyToOne - @JoinColumn(name = "rannfnssiid") - private RANSliceInfo rANSliceInventory; - - public String getSliceProfileId() { - return sliceProfileId; - } - - public void setSliceProfileId(String sliceProfileId) { - this.sliceProfileId = sliceProfileId; - } - - public String getsNSSAI() { - return sNSSAI; - } - - public void setsNSSAI(String sNSSAI) { - this.sNSSAI = sNSSAI; - } - - public String getpLMNIdList() { - return pLMNIdList; - } - - public void setpLMNIdList(String pLMNIdList) { - this.pLMNIdList = pLMNIdList; - } - - public Integer getMaxNumberofUEs() { - return maxNumberofUEs; - } - - public void setMaxNumberofUEs(Integer maxNumberofUEs) { - this.maxNumberofUEs = maxNumberofUEs; - } - - public Integer getLatency() { - return latency; - } - - public void setLatency(Integer latency) { - this.latency = latency; - } - - public String getuEMobilityLevel() { - return uEMobilityLevel; - } - - public void setuEMobilityLevel(String uEMobilityLevel) { - this.uEMobilityLevel = uEMobilityLevel; - } - - public String getResourceSharingLevel() { - return resourceSharingLevel; - } - - public void setResourceSharingLevel(String resourceSharingLevel) { - this.resourceSharingLevel = resourceSharingLevel; - } - - public RANSliceInfo getrANSliceInventory() { - return rANSliceInventory; - } - - public void setrANSliceInventory(RANSliceInfo rANSliceInventory) { - this.rANSliceInventory = rANSliceInventory; - } - - public void setCoverageAreaList(String coverageAreaList) { - this.coverageAreaList = coverageAreaList; - } + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "SLICEPROFILEID") + private String sliceProfileId; + @Column(name = "SNSSAI") + private String sNSSAI; + @Column(name = "PLMNIDLIST") + private String pLMNIdList; + @Column(name = "MAXNOOFUES") + private Integer maxNumberofUEs; + @Column(name = "LATENCY") + private Integer latency; + @Column(name = "DLTHPTPERSLICE") + private Integer dLThptPerSlice; + @Column(name = "ULTHPTPERSLICE") + private Integer uLThptPerSlice; + @Column(name = "MAXNUMBEROFCONNS") + private Integer maxNumberofConns; + + public Integer getdLThptPerSlice() { + return dLThptPerSlice; + } + + public void setdLThptPerSlice(Integer dLThptPerSlice) { + this.dLThptPerSlice = dLThptPerSlice; + } + + public Integer getuLThptPerSlice() { + return uLThptPerSlice; + } + + public void setuLThptPerSlice(Integer uLThptPerSlice) { + this.uLThptPerSlice = uLThptPerSlice; + } + + public Integer getMaxNumberofConns() { + return maxNumberofConns; + } + + public void setMaxNumberofConns(Integer maxNumberofConns) { + this.maxNumberofConns = maxNumberofConns; + } + + public String getCoverageAreaList() { + return coverageAreaList; + } + + /* + * @Column(name="EXPDATARATEDL") private Integer expDataRateDL; + * + * @Column(name="EXPDATARATEUL") private Integer expDataRateUL; + * + * @Column(name="MAXNUMBEROFPDUSESSIONS") private Integer + * maxNumberofPDUSessions; + */ + @Column(name = "UEMOBILITYLEVEL") + private String uEMobilityLevel; + @Column(name = "RESOURCESHARINGLEVEL") + private String resourceSharingLevel; + // @ElementCollection + // @CollectionTable(name="coveragearealist", joinColumns = + // @JoinColumn(name="sliceprofileid")) + @Column(name = "coveragearealist") + private String coverageAreaList; + @ManyToOne + @JoinColumn(name = "rannfnssiid") + private RANSliceInfo rANSliceInventory; + + public String getSliceProfileId() { + return sliceProfileId; + } + + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + + public String getsNSSAI() { + return sNSSAI; + } + + public void setsNSSAI(String sNSSAI) { + this.sNSSAI = sNSSAI; + } + + public String getpLMNIdList() { + return pLMNIdList; + } + + public void setpLMNIdList(String pLMNIdList) { + this.pLMNIdList = pLMNIdList; + } + + public Integer getMaxNumberofUEs() { + return maxNumberofUEs; + } + + public void setMaxNumberofUEs(Integer maxNumberofUEs) { + this.maxNumberofUEs = maxNumberofUEs; + } + + public Integer getLatency() { + return latency; + } + + public void setLatency(Integer latency) { + this.latency = latency; + } + + public String getuEMobilityLevel() { + return uEMobilityLevel; + } + + public void setuEMobilityLevel(String uEMobilityLevel) { + this.uEMobilityLevel = uEMobilityLevel; + } + + public String getResourceSharingLevel() { + return resourceSharingLevel; + } + + public void setResourceSharingLevel(String resourceSharingLevel) { + this.resourceSharingLevel = resourceSharingLevel; + } + + public RANSliceInfo getrANSliceInventory() { + return rANSliceInventory; + } + + public void setrANSliceInventory(RANSliceInfo rANSliceInventory) { + this.rANSliceInventory = rANSliceInventory; + } + + public void setCoverageAreaList(String coverageAreaList) { + this.coverageAreaList = coverageAreaList; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TACells.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TACells.java index 37ff491..40ab024 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TACells.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TACells.java @@ -30,31 +30,31 @@ import javax.persistence.Table; @Entity @Table(name = "TACELLS") public class TACells implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "TRACKINGAREA") - private String trackingArea; - @Column(name = "CELLS") - private String cellsList; - - public String getTrackingArea() { - return trackingArea; - } - - public void setTrackingArea(String trackingArea) { - this.trackingArea = trackingArea; - } - - public String getCellsList() { - return cellsList; - } - - public void setCellsList(String cellsList) { - this.cellsList = cellsList; - } - - @Override - public String toString() { - return "TACells [trackingArea=" + trackingArea + ", cellsList=" + cellsList + "]"; - } + private static final long serialVersionUID = 1L; + @Id + @Column(name = "TRACKINGAREA") + private String trackingArea; + @Column(name = "CELLS") + private String cellsList; + + public String getTrackingArea() { + return trackingArea; + } + + public void setTrackingArea(String trackingArea) { + this.trackingArea = trackingArea; + } + + public String getCellsList() { + return cellsList; + } + + public void setCellsList(String cellsList) { + this.cellsList = cellsList; + } + + @Override + public String toString() { + return "TACells [trackingArea=" + trackingArea + ", cellsList=" + cellsList + "]"; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java index faf7c54..3547eac 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java @@ -23,84 +23,84 @@ package org.onap.ransim.rest.api.models; import java.util.List; public class Topology { - int gridSize; - float minScreenX = 0; - float minScreenY = 0; - float maxScreenX = 10; - float maxScreenY = 10; - List<CellDetails> cellTopology; - - /** - * A constructor for Topology. - * - * @param gridSize grid size - * @param minScreenX min value of screen X for a cell in the topology - * @param minScreenY min value of screen Y for a cell in the topology - * @param maxScreenX max value of screen X for a cell in the topology - * @param maxScreenY max value of screen Y for a cell in the topology - * @param cellTopology list of cells within the topology - */ - public Topology(int gridSize, float minScreenX, float minScreenY, float maxScreenX, float maxScreenY, - List<CellDetails> cellTopology) { - super(); - this.gridSize = gridSize; - this.minScreenX = minScreenX; - this.minScreenY = minScreenY; - this.maxScreenX = maxScreenX; - this.maxScreenY = maxScreenY; - this.cellTopology = cellTopology; - } - - public Topology() { - - } - - public int getGridSize() { - return gridSize; - } - - public void setGridSize(int gridSize) { - this.gridSize = gridSize; - } - - public float getMinScreenX() { - return minScreenX; - } - - public void setMinScreenX(float minScreenX) { - this.minScreenX = minScreenX; - } - - public float getMinScreenY() { - return minScreenY; - } - - public void setMinScreenY(float minScreenY) { - this.minScreenY = minScreenY; - } - - public float getMaxScreenX() { - return maxScreenX; - } - - public void setMaxScreenX(float maxScreenX) { - this.maxScreenX = maxScreenX; - } - - public float getMaxScreenY() { - return maxScreenY; - } - - public void setMaxScreenY(float maxScreenY) { - this.maxScreenY = maxScreenY; - } - - public List<CellDetails> getCellTopology() { - return cellTopology; - } - - public void setCellTopology(List<CellDetails> cellTopology) { - this.cellTopology = cellTopology; - } + int gridSize; + float minScreenX = 0; + float minScreenY = 0; + float maxScreenX = 10; + float maxScreenY = 10; + List<CellDetails> cellTopology; + + /** + * A constructor for Topology. + * + * @param gridSize grid size + * @param minScreenX min value of screen X for a cell in the topology + * @param minScreenY min value of screen Y for a cell in the topology + * @param maxScreenX max value of screen X for a cell in the topology + * @param maxScreenY max value of screen Y for a cell in the topology + * @param cellTopology list of cells within the topology + */ + public Topology(int gridSize, float minScreenX, float minScreenY, float maxScreenX, float maxScreenY, + List<CellDetails> cellTopology) { + super(); + this.gridSize = gridSize; + this.minScreenX = minScreenX; + this.minScreenY = minScreenY; + this.maxScreenX = maxScreenX; + this.maxScreenY = maxScreenY; + this.cellTopology = cellTopology; + } + + public Topology() { + + } + + public int getGridSize() { + return gridSize; + } + + public void setGridSize(int gridSize) { + this.gridSize = gridSize; + } + + public float getMinScreenX() { + return minScreenX; + } + + public void setMinScreenX(float minScreenX) { + this.minScreenX = minScreenX; + } + + public float getMinScreenY() { + return minScreenY; + } + + public void setMinScreenY(float minScreenY) { + this.minScreenY = minScreenY; + } + + public float getMaxScreenX() { + return maxScreenX; + } + + public void setMaxScreenX(float maxScreenX) { + this.maxScreenX = maxScreenX; + } + + public float getMaxScreenY() { + return maxScreenY; + } + + public void setMaxScreenY(float maxScreenY) { + this.maxScreenY = maxScreenY; + } + + public List<CellDetails> getCellTopology() { + return cellTopology; + } + + public void setCellTopology(List<CellDetails> cellTopology) { + this.cellTopology = cellTopology; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java index b2aefec..54e6bcf 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java @@ -24,28 +24,28 @@ import java.util.List; public class TopologyDump { - private List<CellData> cellList; + private List<CellData> cellList; - /** - * A constructor for TopologyDump. - * - * @param cellList list of cells - */ - public TopologyDump(List<CellData> cellList) { + /** + * A constructor for TopologyDump. + * + * @param cellList list of cells + */ + public TopologyDump(List<CellData> cellList) { - this.cellList = cellList; - } + this.cellList = cellList; + } - public TopologyDump() { + public TopologyDump() { - } + } - public List<CellData> getCellList() { - return cellList; - } + public List<CellData> getCellList() { + return cellList; + } - public void setCellList(List<CellData> cellList) { - this.cellList = cellList; - } + public void setCellList(List<CellData> cellList) { + this.cellList = cellList; + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellDetailsRepo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellDetailsRepo.java index 48e20bf..da7e8d6 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellDetailsRepo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellDetailsRepo.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.repository; import java.util.List; @@ -29,9 +30,9 @@ import org.springframework.stereotype.Repository; @Repository public interface CellDetailsRepo extends CrudRepository<CellDetails, String> { - @Query("SELECT n FROM CellDetails n WHERE n.serverId is null") - List<CellDetails> findCellsWithNoServerId(); - - @Query("SELECT cd from CellDetails cd where cd.pciCollisionDetected=true or cd.pciConfusionDetected=true") - List<CellDetails> getCellsWithCollisionOrConfusion(); + @Query("SELECT n FROM CellDetails n WHERE n.serverId is null") + List<CellDetails> findCellsWithNoServerId(); + + @Query("SELECT cd from CellDetails cd where cd.pciCollisionDetected=true or cd.pciConfusionDetected=true") + List<CellDetails> getCellsWithCollisionOrConfusion(); } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellNeighborRepo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellNeighborRepo.java index 99b620a..87134b2 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellNeighborRepo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/CellNeighborRepo.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.repository; import org.onap.ransim.rest.api.models.CellNeighbor; diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUCPRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUCPRepository.java index 06bf630..d9e028f 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUCPRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUCPRepository.java @@ -22,18 +22,20 @@ package org.onap.ransim.rest.api.repository; import java.util.List; +import org.onap.ransim.rest.api.models.GNBCUCPFunction; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.GNBCUCPFunction; - @Repository public interface GNBCUCPRepository extends CrudRepository<GNBCUCPFunction, String> { - @Query(nativeQuery = true, value = "select distinct(cucp.gnbcuname) from gnbcucpfunction cucp join nrcellcu cellcu where cellcu.celllocalid in (:cellIdList)") - public List<String> findCUCPByCellIds(List<Integer> cellIdList); + @Query( + nativeQuery = true, + value = "select distinct(cucp.gnbcuname) from gnbcucpfunction cucp join nrcellcu cellcu where cellcu.celllocalid in (:cellIdList)") + public List<String> findCUCPByCellIds(List<Integer> cellIdList); - @Query(nativeQuery = true, value = "select * from gnbcucpfunction cucp join plmninfo plmn where plmn.snssai=?1 and plmn.nrcellcu_celllocalid IS NOT NULL") - public List<GNBCUCPFunction> findCUCPsByNSSAI(String nSSAI); + @Query( + nativeQuery = true, + value = "select * from gnbcucpfunction cucp join plmninfo plmn where plmn.snssai=?1 and plmn.nrcellcu_celllocalid IS NOT NULL") + public List<GNBCUCPFunction> findCUCPsByNSSAI(String nSSAI); } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUUPRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUUPRepository.java index 62d76e6..8bb2ad2 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUUPRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBCUUPRepository.java @@ -20,11 +20,11 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.GNBCUUPFunction; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.GNBCUUPFunction; @Repository -public interface GNBCUUPRepository extends CrudRepository<GNBCUUPFunction,Integer>{ +public interface GNBCUUPRepository extends CrudRepository<GNBCUUPFunction, Integer> { } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBDURepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBDURepository.java index eec816d..29a7a8c 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBDURepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/GNBDURepository.java @@ -21,14 +21,16 @@ package org.onap.ransim.rest.api.repository; import java.util.List; + +import org.onap.ransim.rest.api.models.GNBDUFunction; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.GNBDUFunction; @Repository -public interface GNBDURepository extends CrudRepository<GNBDUFunction,Integer>{ - @Query(nativeQuery = true, value = "select * from gnbdufunction du join plmninfo plmn where plmn.snssai=?1 and plmn.nrcelldu_celllocalid IS NOT NULL") - public List<GNBDUFunction> findDUsByNSSAI(String nSSAI); +public interface GNBDURepository extends CrudRepository<GNBDUFunction, Integer> { + @Query( + nativeQuery = true, + value = "select * from gnbdufunction du join plmninfo plmn where plmn.snssai=?1 and plmn.nrcelldu_celllocalid IS NOT NULL") + public List<GNBDUFunction> findDUsByNSSAI(String nSSAI); } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NRCellCURepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NRCellCURepository.java index 7cb3629..cbad231 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NRCellCURepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NRCellCURepository.java @@ -20,11 +20,11 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.NRCellCU; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.NRCellCU; @Repository -public interface NRCellCURepository extends CrudRepository<NRCellCU,Integer>{ - +public interface NRCellCURepository extends CrudRepository<NRCellCU, Integer> { + } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NearRTRICRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NearRTRICRepository.java index dee5b17..8ed4882 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NearRTRICRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NearRTRICRepository.java @@ -22,23 +22,26 @@ package org.onap.ransim.rest.api.repository; import java.util.List; import java.util.Set; + +import org.onap.ransim.rest.api.models.NearRTRIC; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.NearRTRIC; @Repository -public interface NearRTRICRepository extends CrudRepository<NearRTRIC,Integer>{ - - @Query(nativeQuery = true, value = "select * from nearrtric ric join trackingarea ta where tracking_area=?1") - public List<NearRTRIC> getListOfRICsInTrackingArea(String trackingArea); - - @Query(nativeQuery=true, value="select * from nearrtric ric join gnbcucpfunction cucp where cucp.gnbcuname=?1") - public List<NearRTRIC> findNearRTRICByCUCPName(String cucpNames); - - @Query(nativeQuery = true, value = "select * from nearrtric ric join rannfnssi nssi where nssi.rannfnssilist=?1") - public List<NearRTRIC> findNearRTRICByNSSI(String ranNFNSSIId); - - @Query(nativeQuery = true, value = "select * from nearrtric ric join plmninfo plmn where plmn.snssai=?1 and plmn.nearrtricid IS NOT NULL") - public Set<NearRTRIC> findNearRTRICByNSSAI(String nSSAI); +public interface NearRTRICRepository extends CrudRepository<NearRTRIC, Integer> { + + @Query(nativeQuery = true, value = "select * from nearrtric ric join trackingarea ta where tracking_area=?1") + public List<NearRTRIC> getListOfRICsInTrackingArea(String trackingArea); + + @Query(nativeQuery = true, value = "select * from nearrtric ric join gnbcucpfunction cucp where cucp.gnbcuname=?1") + public List<NearRTRIC> findNearRTRICByCUCPName(String cucpNames); + + @Query(nativeQuery = true, value = "select * from nearrtric ric join rannfnssi nssi where nssi.rannfnssilist=?1") + public List<NearRTRIC> findNearRTRICByNSSI(String ranNFNSSIId); + + @Query( + nativeQuery = true, + value = "select * from nearrtric ric join plmninfo plmn where plmn.snssai=?1 and plmn.nearrtricid IS NOT NULL") + public Set<NearRTRIC> findNearRTRICByNSSAI(String nSSAI); } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NeighborDetailsRepo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NeighborDetailsRepo.java index 7209f40..0493a10 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NeighborDetailsRepo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NeighborDetailsRepo.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.repository; import org.onap.ransim.rest.api.models.NeighborDetails; diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NetconfServersRepo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NetconfServersRepo.java index e0ecc03..2e0ae32 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NetconfServersRepo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/NetconfServersRepo.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.repository; import org.onap.ransim.rest.api.models.NetconfServers; diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/OperationLogRepo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/OperationLogRepo.java index 0541fec..8e900f5 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/OperationLogRepo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/OperationLogRepo.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ransim.rest.api.repository; import org.onap.ransim.rest.api.models.OperationLog; @@ -24,6 +25,6 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface OperationLogRepo extends CrudRepository<OperationLog, String>{ +public interface OperationLogRepo extends CrudRepository<OperationLog, String> { } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RANInventoryRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RANInventoryRepository.java index 7b41e9e..8972732 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RANInventoryRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RANInventoryRepository.java @@ -20,14 +20,15 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.RANSliceInfo; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.RANSliceInfo; - @Repository -public interface RANInventoryRepository extends CrudRepository<RANSliceInfo,String>{ - @Query(nativeQuery = true, value = "select distinct(raninfo.rannfnssiid) from raninventory raninfo join nssai where nssai.nssailist=?1") - public String findRANNFNSSIofNSSAI(String sNSSAI); +public interface RANInventoryRepository extends CrudRepository<RANSliceInfo, String> { + @Query( + nativeQuery = true, + value = "select distinct(raninfo.rannfnssiid) from raninventory raninfo join nssai where nssai.nssailist=?1") + public String findRANNFNSSIofNSSAI(String sNSSAI); } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyMemberRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyMemberRepository.java index 365869d..d0b0b25 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyMemberRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyMemberRepository.java @@ -20,12 +20,11 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.RRMPolicyMember; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.RRMPolicyMember; - @Repository -public interface RRMPolicyMemberRepository extends CrudRepository<RRMPolicyMember,Integer>{ +public interface RRMPolicyMemberRepository extends CrudRepository<RRMPolicyMember, Integer> { } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyRepository.java index 1cb786a..880381f 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/RRMPolicyRepository.java @@ -20,16 +20,15 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.RRMPolicyRatio; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.RRMPolicyRatio; - @Repository -public interface RRMPolicyRepository extends CrudRepository<RRMPolicyRatio,Integer>{ - - @Query(nativeQuery = true, value="select * from rrmpolicy where resourcetype=?1 and resourceid=?2") - public RRMPolicyRatio findByResourceTypeAndId(String resourceType, String resourceId); +public interface RRMPolicyRepository extends CrudRepository<RRMPolicyRatio, Integer> { + + @Query(nativeQuery = true, value = "select * from rrmpolicy where resourcetype=?1 and resourceid=?2") + public RRMPolicyRatio findByResourceTypeAndId(String resourceType, String resourceId); } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/SliceProfileRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/SliceProfileRepository.java index 7f706ef..6db7626 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/SliceProfileRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/SliceProfileRepository.java @@ -23,7 +23,6 @@ package org.onap.ransim.rest.api.repository; import org.onap.ransim.rest.api.models.SliceProfile; import org.springframework.data.repository.CrudRepository; -public interface SliceProfileRepository extends CrudRepository <SliceProfile,String>{ +public interface SliceProfileRepository extends CrudRepository<SliceProfile, String> { } - diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/TACellRepository.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/TACellRepository.java index 9a0a70d..92ccd1a 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/TACellRepository.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/repository/TACellRepository.java @@ -20,16 +20,16 @@ package org.onap.ransim.rest.api.repository; +import org.onap.ransim.rest.api.models.TACells; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; -import org.onap.ransim.rest.api.models.TACells; /*** - * + * * @author onapadmin * */ @Repository -public interface TACellRepository extends CrudRepository <TACells,String> { - +public interface TACellRepository extends CrudRepository<TACells, String> { + } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java index d7e4b5d..7e2172b 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java @@ -32,9 +32,6 @@ import java.util.stream.Collectors; import org.apache.log4j.Logger; import org.modelmapper.ModelMapper; import org.modelmapper.convention.MatchingStrategies; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import org.onap.ransim.rest.api.models.GNBCUCPFunction; import org.onap.ransim.rest.api.models.GNBCUUPFunction; import org.onap.ransim.rest.api.models.GNBDUFunction; @@ -63,574 +60,601 @@ import org.onap.ransim.rest.web.mapper.NRCellDUModel; import org.onap.ransim.rest.web.mapper.NearRTRICModel; import org.onap.ransim.rest.web.mapper.RANSliceInfoModel; import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; @Service public class RANSliceConfigService { - private static Logger logger = Logger.getLogger(RANSliceConfigService.class.getName()); - @Autowired - private NRCellCURepository nRCellCURepository; - - @Autowired - private GNBCUCPRepository gNBCUCPRepository; - - @Autowired - private GNBCUUPRepository gNBCUUPRepository; - - @Autowired - private GNBDURepository gNBDURepository; - - @Autowired - private NearRTRICRepository nearRTRICRepository; - - @Autowired - private RRMPolicyRepository rRMPolicyRepository; - - @Autowired - private RANInventoryRepository ranInventoryRepo; - - @Autowired - private TACellRepository tACellRepository; - - private ModelMapper modelMapper = new ModelMapper(); - - /** - * To store/update the NRCEllCU details - * - * @param nRCellCUModel - * @return NRCellCUModel - */ - public NRCellCUModel saveNRcellCU(NRCellCUModel nRCellCUModel) { - logger.debug("Request received to save NRcellCU: id::"+ nRCellCUModel.getCellLocalId()); - NRCellCU cellCUEntity = new NRCellCU(); - modelMapper.map(nRCellCUModel, cellCUEntity); - if(!cellCUEntity.getpLMNInfoList().isEmpty()) { - for(PLMNInfo plmn:cellCUEntity.getpLMNInfoList()) { - //plmn.setnRCellCU(cellCUEntity); - } - } - NRCellCU cellCUEntityResponse = nRCellCURepository.save(cellCUEntity); - modelMapper.map(cellCUEntityResponse,nRCellCUModel); - return nRCellCUModel; - } - - /** - * To fetch the NRCellCU details - * - * @param cellLocalId - * @return NRCellCUModel - */ - public NRCellCUModel fetchNRCellCUDetails(Integer cellLocalId) { - logger.debug("Request received to fetchNRCellCUDetails: id::"+ cellLocalId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - NRCellCU cellCUEntity = nRCellCURepository.findById(cellLocalId).isPresent()?nRCellCURepository.findById(cellLocalId).get():null; - NRCellCUModel nRCellCUModel = new NRCellCUModel(); - modelMapper.map(cellCUEntity,nRCellCUModel); - return nRCellCUModel; - } - - /** - * To store the slice / config details of GNBCUCPFunction - * @param gNBCUCPModel - * @return - */ - public GNBCUCPModel saveGNBCUCP(GNBCUCPModel gNBCUCPModel) { - logger.debug("Request received to save GNBCUCPModel: id::"+ gNBCUCPModel.getgNBCUName()); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBCUCPFunction gNBCUCPFunction=new GNBCUCPFunction(); NearRTRIC nearRTRICRef = new NearRTRIC(); - try { - modelMapper.map(gNBCUCPModel, gNBCUCPFunction); - if(gNBCUCPModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).isPresent()) { - gNBCUCPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).get()); - } - if(gNBCUCPFunction!=null && !gNBCUCPFunction.getCellCUList().isEmpty()) { - gNBCUCPFunction.getCellCUList().forEach(cellCU->{ - cellCU.setgNBCUCPFunction(gNBCUCPFunction); - }); - } - GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.save(gNBCUCPFunction); - modelMapper.map(gNBCUCPEntity,gNBCUCPModel); - }catch(Exception e) { - logger.debug("Error occured during saveGNBCUCP"+e.getMessage()); - return null; - } - return gNBCUCPModel; - } - - /** - * To fetch the gNBCUCP details - * - * @param cucpName - * @return GNBCUCPModel - */ - public GNBCUCPModel fetchGNBCUCPData(String cucpName) { - logger.debug("Request received to fetch GNBCUCPFunction: name::"+ cucpName); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.findById(cucpName).isPresent()?gNBCUCPRepository.findById(cucpName).get():null; - GNBCUCPModel gNBCUCPModel = new GNBCUCPModel(); - modelMapper.map(gNBCUCPEntity,gNBCUCPModel); - return gNBCUCPModel; - } - - /** - * To store the slice / config details of GNBCUCPFunction - * @param gNBCUCPModel - * @return - */ - public GNBCUUPModel saveGNBCUUP(GNBCUUPModel gNBCUUPModel) { - logger.debug("Request received to save GNBCUUPModel: id::"+ gNBCUUPModel.getgNBCUUPId()); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBCUUPFunction gNBCUUPFunction=new GNBCUUPFunction(); - modelMapper.map(gNBCUUPModel, gNBCUUPFunction); - if(gNBCUUPModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).isPresent()) { - gNBCUUPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).get()); - } - if(gNBCUUPFunction!=null && !gNBCUUPFunction.getpLMNInfoList().isEmpty()) { - gNBCUUPFunction.getpLMNInfoList().forEach(plmn->{ - //plmn.setgNBCUUPFunction(gNBCUUPFunction); - }); - } - GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.save(gNBCUUPFunction); - modelMapper.map(gNBCUUPEntity,gNBCUUPModel); - return gNBCUUPModel; - } - - /** - * To fetch the gNBCUUP details - * - * @param cucpName - * @return GNBCUUPModel - */ - public GNBCUUPModel fetchGNBCUUPData(Integer gNBCUUPId) { - logger.debug("Request received to fetch GNBCUUPFunction: id::"+ gNBCUUPId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.findById(gNBCUUPId).isPresent()?gNBCUUPRepository.findById(gNBCUUPId).get():null; - GNBCUUPModel gNBCUUPModel = new GNBCUUPModel(); - modelMapper.map(gNBCUUPEntity,gNBCUUPModel); - return gNBCUUPModel; - } - - /** - * To store the slice / config details of GNBDUFunction - * @param GNBDUModel - * @return - */ - public GNBDUModel saveGNBDU(GNBDUModel gNBDUModel) { - logger.debug("Request received to save GNBDUModel: id::"+ gNBDUModel.getgNBDUId()); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBDUFunction gNBDUFunction=new GNBDUFunction();NearRTRIC nearRTRICRef = new NearRTRIC(); - modelMapper.map(gNBDUModel, gNBDUFunction); - if(gNBDUModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).isPresent()) { - nearRTRICRef = nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).get(); - gNBDUFunction.setNearRTRIC(nearRTRICRef); - } - NearRTRIC nearRTRICRefNew = nearRTRICRef; - nearRTRICRefNew.setNearRTRICId(gNBDUModel.getNearRTRICId()); - if(gNBDUFunction!=null && !gNBDUFunction.getCellDUList().isEmpty()) { - gNBDUFunction.getCellDUList().forEach(cellDU->{ - cellDU.setgNBDUFunction(gNBDUFunction); - }); - } - GNBDUFunction gNBDUEntity = gNBDURepository.save(gNBDUFunction); - modelMapper.map(gNBDUEntity,gNBDUModel); - return gNBDUModel; - } - - /** - * To fetch the gNBDU details - * - * @param gNBDUId - * @return GNBDUModel - */ - public GNBDUModel fetchGNBDUData(Integer gNBDUId) { - logger.debug("Request received to fetch GNBDUFunction: id::"+ gNBDUId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - GNBDUFunction gNBDUEntity = gNBDURepository.findById(gNBDUId).isPresent()?gNBDURepository.findById(gNBDUId).get():null; - GNBDUModel gNBDUModel = new GNBDUModel(); - modelMapper.map(gNBDUEntity,gNBDUModel); - return gNBDUModel; - } - - /** - * Stored NearRTRIC - * - * @param nearRTRIC - * @return - */ - public NearRTRICModel saveNearRTRIC(NearRTRICModel nearRTRIC) { - logger.debug("Request received to store NearRTRIC: id::"+ nearRTRIC.getNearRTRICId()); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - NearRTRIC nearRTRICEntity = new NearRTRIC(); - modelMapper.map(nearRTRIC, nearRTRICEntity); - NearRTRIC nearRTRICEntityEResponse = nearRTRICRepository.save(nearRTRICEntity); - modelMapper.map(nearRTRICEntityEResponse,nearRTRIC); - return nearRTRIC; - } - - /** - * To fetch the nearRTRIC details - * - * @param nearRTRICId - * @return NearRTRICModel - */ - public NearRTRICModel fetchNearRTRICData(Integer nearRTRICId) { - logger.debug("Request received to fetch GNBDUFunction: id::"+ nearRTRICId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - NearRTRIC nearRTRICEntity = nearRTRICRepository.findById(nearRTRICId).isPresent()?nearRTRICRepository.findById(nearRTRICId).get():null; - NearRTRICModel nearRTRICModel = new NearRTRICModel(); - modelMapper.map(nearRTRICEntity,nearRTRICModel); - return nearRTRICModel; - } - - /** - * To retrieve the RRMPolicy of a network function - * - * @param resourceType - * @param resourceID - * @return - */ - public RRMPolicyRatioModel fetchRRMPolicyOfNE(String resourceType, String resourceID) { - logger.debug("Request received to fetch RRMPolicy:"+ resourceType+"--"+resourceID); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - RRMPolicyRatioModel rrmPolicyResponse = new RRMPolicyRatioModel(); - RRMPolicyRatio rrmPolicyEntity = rRMPolicyRepository.findByResourceTypeAndId(resourceType, resourceID); - modelMapper.map(rrmPolicyEntity, rrmPolicyResponse); - return rrmPolicyResponse; - } - - /** - * To update RRM policy of NF - * - * @param rrmPolicy - * @return - */ - public RRMPolicyRatioModel updateRRMPolicy(RRMPolicyRatioModel rrmPolicy) { - logger.debug("Request received to update RRMPolicy:"+ rrmPolicy.getRrmPolicyID()); - RRMPolicyRatio rrmPolicyEntity = new RRMPolicyRatio(); - modelMapper.map(rrmPolicy, rrmPolicyEntity); - rrmPolicyEntity = rRMPolicyRepository.save(rrmPolicyEntity); - modelMapper.map(rrmPolicyEntity, rrmPolicy); - return rrmPolicy; - } - - /** - * @param trackingArea - * @return List<NearRTRICModel> - */ - public List<NearRTRICModel> findRICsInTA(String trackingArea) { - logger.debug("Request received to find the NearRTRICs in Tracking Area::"+ trackingArea); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<NearRTRIC> nearRTRICsList = nearRTRICRepository.getListOfRICsInTrackingArea(trackingArea); - List<NearRTRICModel> ricModelList = nearRTRICsList.stream() - .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList()); - return ricModelList; - } - - /** - * @param cellsList - * @return - */ - public List<NearRTRICModel> findNearRTRICofCells(List<Integer> cellsList){ - List<NearRTRIC> ricEntitiesList = new ArrayList<>(); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<String> cucpNames = gNBCUCPRepository.findCUCPByCellIds(cellsList); - cucpNames.forEach(cucpName -> { - List<NearRTRIC> ricEntities = new ArrayList<>(); - ricEntities = nearRTRICRepository.findNearRTRICByCUCPName(cucpName); - ricEntitiesList.addAll(ricEntities); - }); - List<NearRTRICModel> ricModelList = ricEntitiesList.stream() - .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList()); - return ricModelList; - } - - - /** - * To update the RAN Slice details - * - * @param rANSliceInfoModel - * @return RANSliceInfoModel - */ - public RANSliceInfoModel updateRANInventory(RANSliceInfoModel rANSliceInfoModel) { - logger.debug("Request received to update inventory for id::"+ rANSliceInfoModel.getRanNFNSSIId()); - RANSliceInfo rANSliceInfoEntity = new RANSliceInfo(); - modelMapper.map(rANSliceInfoModel, rANSliceInfoEntity); - if(ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).isPresent()) { - RANSliceInfo ranInfo = ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).get(); - List<String> ranNSSIList = ranInfo.getRanNSSIList(); - ranNSSIList.addAll(rANSliceInfoEntity.getRanNSSIList()); - rANSliceInfoEntity.setRanNSSIList(ranNSSIList); - - List<String> nSSAIList = ranInfo.getnSSAIList(); - nSSAIList.addAll(rANSliceInfoEntity.getnSSAIList()); - rANSliceInfoEntity.setnSSAIList(nSSAIList); - - List<SliceProfile> sliceProfilesList = ranInfo.getSliceProfilesList(); - sliceProfilesList.addAll(rANSliceInfoEntity.getSliceProfilesList()); - rANSliceInfoEntity.setSliceProfilesList(sliceProfilesList); - } - else { - if(!rANSliceInfoEntity.getSliceProfilesList().isEmpty()) { - for(SliceProfile profile:rANSliceInfoEntity.getSliceProfilesList()) { - profile.setrANSliceInventory(rANSliceInfoEntity); - } - } - } - rANSliceInfoEntity = ranInventoryRepo.save(rANSliceInfoEntity); - modelMapper.map(rANSliceInfoEntity, rANSliceInfoModel); - return rANSliceInfoModel; - } - - /** - * @param ranNFNSSIId - * @return RANSliceInfoModel - */ - public RANSliceInfoModel fetchRANSlice(String ranNFNSSIId) { - logger.debug("Request received to read inventory details for id::"+ ranNFNSSIId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - RANSliceInfo ranSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()?ranInventoryRepo.findById(ranNFNSSIId).get():null; - RANSliceInfoModel rANSliceInfoModel = new RANSliceInfoModel(); - modelMapper.map(ranSliceInfo, rANSliceInfoModel); - return rANSliceInfoModel; - } - - /** - * @param trackingArea - * @return List<String> - */ - public List<String> fetchCellsofTA(String trackingArea) { - logger.debug("Request recieved to fetch the cell details of TA:"+ trackingArea); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - String cells = tACellRepository.findById(trackingArea).isPresent()?tACellRepository.findById(trackingArea).get().getCellsList():null; - return cells!=null? Arrays.asList(cells.split(",")):null; - - } - - public Iterable<TACells> fetchAllTA() - { - logger.info("Request recieved to fetch all TA:"); - return tACellRepository.findAll(); - } - - /** - * @param nearRTRICId - * @return List<NRCellCUModel> - */ - public List<NRCellCUModel> fetchCUCellsofRIC(Integer nearRTRICId) { - logger.debug("Request recieved to fetch the cell (CU) details of nearRTRICId:"+ nearRTRICId); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<NRCellCU> cellCUEntities = new ArrayList<NRCellCU>(); - NearRTRIC nearRTRIC = nearRTRICRepository.findById(nearRTRICId).isPresent()?nearRTRICRepository.findById(nearRTRICId).get():null; - if(nearRTRIC!=null) { - List<GNBCUCPFunction> cucpFunctions = nearRTRIC.getgNBCUCPList(); - cucpFunctions.forEach(cucpFunction->{ - List<NRCellCU> cellCUList = new ArrayList<NRCellCU>(); - cellCUList.addAll(cucpFunction.getCellCUList()); - cellCUEntities.addAll(cellCUList); - }); - List<NRCellCUModel> cuCellModels = cellCUEntities.stream() - .map(cellCUEntity -> modelMapper.map(cellCUEntity, NRCellCUModel.class)).collect(Collectors.toList()); - return cuCellModels; - } - return new ArrayList<NRCellCUModel>(); - } - - /** - * @param trackingArea - * @return List<NRCellDUModel> - */ - public Map<Integer, List<NRCellDUModel>> fetchDUCellsofRIC(String sNSSAI) { - logger.debug("Request recieved to fetch the cell (DU) details of sNSSAI:"+ sNSSAI); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - Set<NRCellDU> cellDUEntities = new HashSet<NRCellDU>();Set<NRCellDU> cellDUs = new HashSet<NRCellDU>(); - List<NearRTRICModel> ricModels = findRICsByNSSAI(sNSSAI); - Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>(); - List<NearRTRIC> ricEntities = ricModels.stream() - .map(ric -> modelMapper.map(ric, NearRTRIC.class)).collect(Collectors.toList()); - ricEntities.forEach(ricEntity -> { - List<GNBDUFunction> duFunctions = ricEntity.getgNBDUList(); - duFunctions.forEach(duFunction -> { - List<NRCellDU> cellDUList =duFunction.getCellDUList(); - cellDUList.forEach(cellDU->{ - List<PLMNInfo> plmnList = cellDU.getpLMNInfoList(); - plmnList.forEach(plmn->{ - if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())){ - cellDUs.add(cellDU); - } - }); - }); - //cellDUList.addAll(duFunction.getCellDUList()); - cellDUEntities.addAll(cellDUs); - }); - List<NRCellDUModel> duCellModels = cellDUEntities.stream() - .map(cellDUEntity -> modelMapper.map(cellDUEntity, NRCellDUModel.class)).collect(Collectors.toList()); - cellsMap.put(ricEntity.getNearRTRICId(), duCellModels); - }); - - return cellsMap; - } - - /** - * @param ranNFNSSIID - * @return List<NearRTRICModel> - */ - public List<NearRTRICModel> findNearRTRICByNSSI(String ranNFNSSIID) { - logger.debug("Request recieved to fetch nearRTRIC of NSSI:"+ ranNFNSSIID); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSI(ranNFNSSIID); - List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream() - .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class)).collect(Collectors.toList()); - return nearRTRICModels; - } - - /** - * @param sNSSAI - * @return List<NearRTRICModel> - */ - public List<NearRTRICModel> findRICsByNSSAI(String sNSSAI){ - logger.debug("Request recieved to fetch nearRTRIC of NSSAI:"+ sNSSAI); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - Set<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSAI(sNSSAI); - List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream() - .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class)) - .collect(Collectors.toList()); - return nearRTRICModels; - } - - /** - * @param sNSSAI - * @return config Details - */ - public Map<String,Integer> findSliceProfileconfig(String sNSSAI){ - logger.debug("Request recieved to fetch Config requested for a slice:"+ sNSSAI); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - Map<String,Integer> configDetails = new HashMap<String, Integer>(); - String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI); - RANSliceInfo rANSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()? ranInventoryRepo.findById(ranNFNSSIId).get():null; - if(rANSliceInfo.getSliceProfilesList().size()>0) { - rANSliceInfo.getSliceProfilesList().forEach(sliceProfile->{ - if(sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())){ - //configDetails.put("maxNoOfConns",sliceProfile.getMaxNumberofConns()); - configDetails.put("dLThptPerSlice",sliceProfile.getdLThptPerSlice()); - configDetails.put("uLThptPerSlice",sliceProfile.getuLThptPerSlice()); - } - }); - } - return configDetails; - } - - /** - * @param sNSSAI - * @return RIC Config for a slice - */ - public Map<Integer, NSSAIConfig> findSliceConfig(String sNSSAI){ - logger.debug("Request recieved to fetch Slice config Details at RICs:"+ sNSSAI); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI); - Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>(); - nearRTRICModels.forEach(nearRTRIC->{ - nearRTRIC.getpLMNInfoList().forEach(plmn->{ - if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) { - configMap.put(nearRTRIC.getNearRTRICId(),plmn.getsNSSAI().getConfigData()); - } - }); - }); - return configMap; - } - - /** - * @param sNSSAI - * @return List<GNBDUModel> - */ - public List<GNBDUModel> findDUsofSNssai(String sNSSAI){ - logger.debug("Request recieved to fetch all DUs of NSSAI"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findDUsByNSSAI(sNSSAI); - List<GNBDUModel> duModels = duList.stream() - .map(duEntity -> modelMapper.map(duEntity, GNBDUModel.class)).collect(Collectors.toList()); - return duModels; - } - - /** - * @param sNSSAI - * @return List<GNBCUCPModel> - */ - public List<GNBCUCPModel> findCUsofSNssai(String sNSSAI){ - logger.debug("Request recieved to fetch all CUs of NSSAI"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<GNBCUCPFunction> cuList = (List<GNBCUCPFunction>) gNBCUCPRepository.findCUCPsByNSSAI(sNSSAI); - List<GNBCUCPModel> cuModels = cuList.stream() - .map(cuEntity -> modelMapper.map(cuEntity, GNBCUCPModel.class)).collect(Collectors.toList()); - return cuModels; - } - - /** - * @param sNSSAI - * @return Map<String, String> - */ - public Map<String, String> getSubscriberDetails(String sNSSAI){ - logger.debug("Request recieved to fetch SubscriberDetails"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - Map<String, String> details = new HashMap<String, String>(); - String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI); - details.put("ranNFNSSIId", ranNFNSSIId); - details.put("sNSSAI", sNSSAI); - RANSliceInfo rANSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()? ranInventoryRepo.findById(ranNFNSSIId).get():null; - if(rANSliceInfo.getSliceProfilesList().size()>0) { - rANSliceInfo.getSliceProfilesList().forEach(sliceProfile->{ - if(sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())){ - details.put("sliceProfileId",sliceProfile.getSliceProfileId()); - } - }); - } - List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI); - nearRTRICModels.forEach(nearRTRIC->{ - nearRTRIC.getpLMNInfoList().forEach(plmn->{ - if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) { - details.put("subscriptionServiceType",plmn.getsNSSAI().getSubscriptionServiceType()); - details.put("globalSubscriberId",plmn.getsNSSAI().getGlobalSubscriberId()); - } - }); - }); - - return details; - } - - // Data required for PM data Simulation - /** - * @return List<GNBCUCPModel> - */ - public List<GNBCUCPModel> findAllCUCPFunctions(){ - logger.debug("Request recieved to fetch all CUCPs"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<GNBCUCPFunction> cucpsList = (List<GNBCUCPFunction>) gNBCUCPRepository.findAll(); - List<GNBCUCPModel> cucpModels = cucpsList.stream() - .map(cucpEntity -> modelMapper.map(cucpEntity, GNBCUCPModel.class)).collect(Collectors.toList()); - return cucpModels; - } - - /** - * @return List<GNBDUModel> - */ - public List<GNBDUModel> findAllDUFunctions(){ - logger.debug("Request recieved to fetch all DUs"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findAll(); - List<GNBDUModel> duModels = duList.stream().map(duEntity -> { - GNBDUModel gnbDuModel = modelMapper.map(duEntity, GNBDUModel.class); - gnbDuModel.setNearRTRICId(duEntity.getNearRTRIC().getNearRTRICId()); - return gnbDuModel; - }).collect(Collectors.toList()); - return duModels; - } - - public List<NearRTRICModel> findAllNearRTRIC() - { - logger.debug("Request received to fetch all NearRTRICModel"); - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - List<NearRTRIC> rtricList = (List<NearRTRIC>) nearRTRICRepository.findAll(); - List<NearRTRICModel> rtricmodels = rtricList.stream() - .map(rtricEntity -> modelMapper.map(rtricEntity, NearRTRICModel.class)).collect(Collectors.toList()); - return rtricmodels; - } - + private static Logger logger = Logger.getLogger(RANSliceConfigService.class.getName()); + @Autowired + private NRCellCURepository nRCellCURepository; + + @Autowired + private GNBCUCPRepository gNBCUCPRepository; + + @Autowired + private GNBCUUPRepository gNBCUUPRepository; + + @Autowired + private GNBDURepository gNBDURepository; + + @Autowired + private NearRTRICRepository nearRTRICRepository; + + @Autowired + private RRMPolicyRepository rRMPolicyRepository; + + @Autowired + private RANInventoryRepository ranInventoryRepo; + + @Autowired + private TACellRepository tACellRepository; + + private ModelMapper modelMapper = new ModelMapper(); + + /** + * To store/update the NRCEllCU details + * + * @param nRCellCUModel + * @return NRCellCUModel + */ + public NRCellCUModel saveNRcellCU(NRCellCUModel nRCellCUModel) { + logger.debug("Request received to save NRcellCU: id::" + nRCellCUModel.getCellLocalId()); + NRCellCU cellCUEntity = new NRCellCU(); + modelMapper.map(nRCellCUModel, cellCUEntity); + if (!cellCUEntity.getpLMNInfoList().isEmpty()) { + for (PLMNInfo plmn : cellCUEntity.getpLMNInfoList()) { + // plmn.setnRCellCU(cellCUEntity); + } + } + NRCellCU cellCUEntityResponse = nRCellCURepository.save(cellCUEntity); + modelMapper.map(cellCUEntityResponse, nRCellCUModel); + return nRCellCUModel; + } + + /** + * To fetch the NRCellCU details + * + * @param cellLocalId + * @return NRCellCUModel + */ + public NRCellCUModel fetchNRCellCUDetails(Integer cellLocalId) { + logger.debug("Request received to fetchNRCellCUDetails: id::" + cellLocalId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + NRCellCU cellCUEntity = + nRCellCURepository.findById(cellLocalId).isPresent() ? nRCellCURepository.findById(cellLocalId).get() + : null; + NRCellCUModel nRCellCUModel = new NRCellCUModel(); + modelMapper.map(cellCUEntity, nRCellCUModel); + return nRCellCUModel; + } + + /** + * To store the slice / config details of GNBCUCPFunction + * + * @param gNBCUCPModel + * @return + */ + public GNBCUCPModel saveGNBCUCP(GNBCUCPModel gNBCUCPModel) { + logger.debug("Request received to save GNBCUCPModel: id::" + gNBCUCPModel.getgNBCUName()); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBCUCPFunction gNBCUCPFunction = new GNBCUCPFunction(); + NearRTRIC nearRTRICRef = new NearRTRIC(); + try { + modelMapper.map(gNBCUCPModel, gNBCUCPFunction); + if (gNBCUCPModel.getNearRTRICId() != null + && nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).isPresent()) { + gNBCUCPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).get()); + } + if (gNBCUCPFunction != null && !gNBCUCPFunction.getCellCUList().isEmpty()) { + gNBCUCPFunction.getCellCUList().forEach(cellCU -> { + cellCU.setgNBCUCPFunction(gNBCUCPFunction); + }); + } + GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.save(gNBCUCPFunction); + modelMapper.map(gNBCUCPEntity, gNBCUCPModel); + } catch (Exception e) { + logger.debug("Error occured during saveGNBCUCP" + e.getMessage()); + return null; + } + return gNBCUCPModel; + } + + /** + * To fetch the gNBCUCP details + * + * @param cucpName + * @return GNBCUCPModel + */ + public GNBCUCPModel fetchGNBCUCPData(String cucpName) { + logger.debug("Request received to fetch GNBCUCPFunction: name::" + cucpName); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBCUCPFunction gNBCUCPEntity = + gNBCUCPRepository.findById(cucpName).isPresent() ? gNBCUCPRepository.findById(cucpName).get() : null; + GNBCUCPModel gNBCUCPModel = new GNBCUCPModel(); + modelMapper.map(gNBCUCPEntity, gNBCUCPModel); + return gNBCUCPModel; + } + + /** + * To store the slice / config details of GNBCUCPFunction + * + * @param gNBCUCPModel + * @return + */ + public GNBCUUPModel saveGNBCUUP(GNBCUUPModel gNBCUUPModel) { + logger.debug("Request received to save GNBCUUPModel: id::" + gNBCUUPModel.getgNBCUUPId()); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction(); + modelMapper.map(gNBCUUPModel, gNBCUUPFunction); + if (gNBCUUPModel.getNearRTRICId() != null + && nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).isPresent()) { + gNBCUUPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).get()); + } + if (gNBCUUPFunction != null && !gNBCUUPFunction.getpLMNInfoList().isEmpty()) { + gNBCUUPFunction.getpLMNInfoList().forEach(plmn -> { + // plmn.setgNBCUUPFunction(gNBCUUPFunction); + }); + } + GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.save(gNBCUUPFunction); + modelMapper.map(gNBCUUPEntity, gNBCUUPModel); + return gNBCUUPModel; + } + + /** + * To fetch the gNBCUUP details + * + * @param cucpName + * @return GNBCUUPModel + */ + public GNBCUUPModel fetchGNBCUUPData(Integer gNBCUUPId) { + logger.debug("Request received to fetch GNBCUUPFunction: id::" + gNBCUUPId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBCUUPFunction gNBCUUPEntity = + gNBCUUPRepository.findById(gNBCUUPId).isPresent() ? gNBCUUPRepository.findById(gNBCUUPId).get() : null; + GNBCUUPModel gNBCUUPModel = new GNBCUUPModel(); + modelMapper.map(gNBCUUPEntity, gNBCUUPModel); + return gNBCUUPModel; + } + + /** + * To store the slice / config details of GNBDUFunction + * + * @param GNBDUModel + * @return + */ + public GNBDUModel saveGNBDU(GNBDUModel gNBDUModel) { + logger.debug("Request received to save GNBDUModel: id::" + gNBDUModel.getgNBDUId()); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBDUFunction gNBDUFunction = new GNBDUFunction(); + NearRTRIC nearRTRICRef = new NearRTRIC(); + modelMapper.map(gNBDUModel, gNBDUFunction); + if (gNBDUModel.getNearRTRICId() != null + && nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).isPresent()) { + nearRTRICRef = nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).get(); + gNBDUFunction.setNearRTRIC(nearRTRICRef); + } + NearRTRIC nearRTRICRefNew = nearRTRICRef; + nearRTRICRefNew.setNearRTRICId(gNBDUModel.getNearRTRICId()); + if (gNBDUFunction != null && !gNBDUFunction.getCellDUList().isEmpty()) { + gNBDUFunction.getCellDUList().forEach(cellDU -> { + cellDU.setgNBDUFunction(gNBDUFunction); + }); + } + GNBDUFunction gNBDUEntity = gNBDURepository.save(gNBDUFunction); + modelMapper.map(gNBDUEntity, gNBDUModel); + return gNBDUModel; + } + + /** + * To fetch the gNBDU details + * + * @param gNBDUId + * @return GNBDUModel + */ + public GNBDUModel fetchGNBDUData(Integer gNBDUId) { + logger.debug("Request received to fetch GNBDUFunction: id::" + gNBDUId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + GNBDUFunction gNBDUEntity = + gNBDURepository.findById(gNBDUId).isPresent() ? gNBDURepository.findById(gNBDUId).get() : null; + GNBDUModel gNBDUModel = new GNBDUModel(); + modelMapper.map(gNBDUEntity, gNBDUModel); + return gNBDUModel; + } + + /** + * Stored NearRTRIC + * + * @param nearRTRIC + * @return + */ + public NearRTRICModel saveNearRTRIC(NearRTRICModel nearRTRIC) { + logger.debug("Request received to store NearRTRIC: id::" + nearRTRIC.getNearRTRICId()); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + NearRTRIC nearRTRICEntity = new NearRTRIC(); + modelMapper.map(nearRTRIC, nearRTRICEntity); + NearRTRIC nearRTRICEntityEResponse = nearRTRICRepository.save(nearRTRICEntity); + modelMapper.map(nearRTRICEntityEResponse, nearRTRIC); + return nearRTRIC; + } + + /** + * To fetch the nearRTRIC details + * + * @param nearRTRICId + * @return NearRTRICModel + */ + public NearRTRICModel fetchNearRTRICData(Integer nearRTRICId) { + logger.debug("Request received to fetch GNBDUFunction: id::" + nearRTRICId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + NearRTRIC nearRTRICEntity = + nearRTRICRepository.findById(nearRTRICId).isPresent() ? nearRTRICRepository.findById(nearRTRICId).get() + : null; + NearRTRICModel nearRTRICModel = new NearRTRICModel(); + modelMapper.map(nearRTRICEntity, nearRTRICModel); + return nearRTRICModel; + } + + /** + * To retrieve the RRMPolicy of a network function + * + * @param resourceType + * @param resourceID + * @return + */ + public RRMPolicyRatioModel fetchRRMPolicyOfNE(String resourceType, String resourceID) { + logger.debug("Request received to fetch RRMPolicy:" + resourceType + "--" + resourceID); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + RRMPolicyRatioModel rrmPolicyResponse = new RRMPolicyRatioModel(); + RRMPolicyRatio rrmPolicyEntity = rRMPolicyRepository.findByResourceTypeAndId(resourceType, resourceID); + modelMapper.map(rrmPolicyEntity, rrmPolicyResponse); + return rrmPolicyResponse; + } + + /** + * To update RRM policy of NF + * + * @param rrmPolicy + * @return + */ + public RRMPolicyRatioModel updateRRMPolicy(RRMPolicyRatioModel rrmPolicy) { + logger.debug("Request received to update RRMPolicy:" + rrmPolicy.getRrmPolicyID()); + RRMPolicyRatio rrmPolicyEntity = new RRMPolicyRatio(); + modelMapper.map(rrmPolicy, rrmPolicyEntity); + rrmPolicyEntity = rRMPolicyRepository.save(rrmPolicyEntity); + modelMapper.map(rrmPolicyEntity, rrmPolicy); + return rrmPolicy; + } + + /** + * @param trackingArea + * @return List<NearRTRICModel> + */ + public List<NearRTRICModel> findRICsInTA(String trackingArea) { + logger.debug("Request received to find the NearRTRICs in Tracking Area::" + trackingArea); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<NearRTRIC> nearRTRICsList = nearRTRICRepository.getListOfRICsInTrackingArea(trackingArea); + List<NearRTRICModel> ricModelList = nearRTRICsList.stream() + .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList()); + return ricModelList; + } + + /** + * @param cellsList + * @return + */ + public List<NearRTRICModel> findNearRTRICofCells(List<Integer> cellsList) { + List<NearRTRIC> ricEntitiesList = new ArrayList<>(); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<String> cucpNames = gNBCUCPRepository.findCUCPByCellIds(cellsList); + cucpNames.forEach(cucpName -> { + List<NearRTRIC> ricEntities = new ArrayList<>(); + ricEntities = nearRTRICRepository.findNearRTRICByCUCPName(cucpName); + ricEntitiesList.addAll(ricEntities); + }); + List<NearRTRICModel> ricModelList = ricEntitiesList.stream() + .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList()); + return ricModelList; + } + + /** + * To update the RAN Slice details + * + * @param rANSliceInfoModel + * @return RANSliceInfoModel + */ + public RANSliceInfoModel updateRANInventory(RANSliceInfoModel rANSliceInfoModel) { + logger.debug("Request received to update inventory for id::" + rANSliceInfoModel.getRanNFNSSIId()); + RANSliceInfo rANSliceInfoEntity = new RANSliceInfo(); + modelMapper.map(rANSliceInfoModel, rANSliceInfoEntity); + if (ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).isPresent()) { + RANSliceInfo ranInfo = ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).get(); + List<String> ranNSSIList = ranInfo.getRanNSSIList(); + ranNSSIList.addAll(rANSliceInfoEntity.getRanNSSIList()); + rANSliceInfoEntity.setRanNSSIList(ranNSSIList); + + List<String> nSSAIList = ranInfo.getnSSAIList(); + nSSAIList.addAll(rANSliceInfoEntity.getnSSAIList()); + rANSliceInfoEntity.setnSSAIList(nSSAIList); + + List<SliceProfile> sliceProfilesList = ranInfo.getSliceProfilesList(); + sliceProfilesList.addAll(rANSliceInfoEntity.getSliceProfilesList()); + rANSliceInfoEntity.setSliceProfilesList(sliceProfilesList); + } else { + if (!rANSliceInfoEntity.getSliceProfilesList().isEmpty()) { + for (SliceProfile profile : rANSliceInfoEntity.getSliceProfilesList()) { + profile.setrANSliceInventory(rANSliceInfoEntity); + } + } + } + rANSliceInfoEntity = ranInventoryRepo.save(rANSliceInfoEntity); + modelMapper.map(rANSliceInfoEntity, rANSliceInfoModel); + return rANSliceInfoModel; + } + + /** + * @param ranNFNSSIId + * @return RANSliceInfoModel + */ + public RANSliceInfoModel fetchRANSlice(String ranNFNSSIId) { + logger.debug("Request received to read inventory details for id::" + ranNFNSSIId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + RANSliceInfo ranSliceInfo = + ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get() + : null; + RANSliceInfoModel rANSliceInfoModel = new RANSliceInfoModel(); + modelMapper.map(ranSliceInfo, rANSliceInfoModel); + return rANSliceInfoModel; + } + + /** + * @param trackingArea + * @return List<String> + */ + public List<String> fetchCellsofTA(String trackingArea) { + logger.debug("Request recieved to fetch the cell details of TA:" + trackingArea); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + String cells = tACellRepository.findById(trackingArea).isPresent() + ? tACellRepository.findById(trackingArea).get().getCellsList() + : null; + return cells != null ? Arrays.asList(cells.split(",")) : null; + + } + + public Iterable<TACells> fetchAllTA() { + logger.info("Request recieved to fetch all TA:"); + return tACellRepository.findAll(); + } + + /** + * @param nearRTRICId + * @return List<NRCellCUModel> + */ + public List<NRCellCUModel> fetchCUCellsofRIC(Integer nearRTRICId) { + logger.debug("Request recieved to fetch the cell (CU) details of nearRTRICId:" + nearRTRICId); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<NRCellCU> cellCUEntities = new ArrayList<NRCellCU>(); + NearRTRIC nearRTRIC = + nearRTRICRepository.findById(nearRTRICId).isPresent() ? nearRTRICRepository.findById(nearRTRICId).get() + : null; + if (nearRTRIC != null) { + List<GNBCUCPFunction> cucpFunctions = nearRTRIC.getgNBCUCPList(); + cucpFunctions.forEach(cucpFunction -> { + List<NRCellCU> cellCUList = new ArrayList<NRCellCU>(); + cellCUList.addAll(cucpFunction.getCellCUList()); + cellCUEntities.addAll(cellCUList); + }); + List<NRCellCUModel> cuCellModels = + cellCUEntities.stream().map(cellCUEntity -> modelMapper.map(cellCUEntity, NRCellCUModel.class)) + .collect(Collectors.toList()); + return cuCellModels; + } + return new ArrayList<NRCellCUModel>(); + } + + /** + * @param trackingArea + * @return List<NRCellDUModel> + */ + public Map<Integer, List<NRCellDUModel>> fetchDUCellsofRIC(String sNSSAI) { + logger.debug("Request recieved to fetch the cell (DU) details of sNSSAI:" + sNSSAI); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + Set<NRCellDU> cellDUEntities = new HashSet<NRCellDU>(); + Set<NRCellDU> cellDUs = new HashSet<NRCellDU>(); + List<NearRTRICModel> ricModels = findRICsByNSSAI(sNSSAI); + Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>(); + List<NearRTRIC> ricEntities = + ricModels.stream().map(ric -> modelMapper.map(ric, NearRTRIC.class)).collect(Collectors.toList()); + ricEntities.forEach(ricEntity -> { + List<GNBDUFunction> duFunctions = ricEntity.getgNBDUList(); + duFunctions.forEach(duFunction -> { + List<NRCellDU> cellDUList = duFunction.getCellDUList(); + cellDUList.forEach(cellDU -> { + List<PLMNInfo> plmnList = cellDU.getpLMNInfoList(); + plmnList.forEach(plmn -> { + if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) { + cellDUs.add(cellDU); + } + }); + }); + // cellDUList.addAll(duFunction.getCellDUList()); + cellDUEntities.addAll(cellDUs); + }); + List<NRCellDUModel> duCellModels = + cellDUEntities.stream().map(cellDUEntity -> modelMapper.map(cellDUEntity, NRCellDUModel.class)) + .collect(Collectors.toList()); + cellsMap.put(ricEntity.getNearRTRICId(), duCellModels); + }); + + return cellsMap; + } + + /** + * @param ranNFNSSIID + * @return List<NearRTRICModel> + */ + public List<NearRTRICModel> findNearRTRICByNSSI(String ranNFNSSIID) { + logger.debug("Request recieved to fetch nearRTRIC of NSSI:" + ranNFNSSIID); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSI(ranNFNSSIID); + List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream() + .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class)) + .collect(Collectors.toList()); + return nearRTRICModels; + } + + /** + * @param sNSSAI + * @return List<NearRTRICModel> + */ + public List<NearRTRICModel> findRICsByNSSAI(String sNSSAI) { + logger.debug("Request recieved to fetch nearRTRIC of NSSAI:" + sNSSAI); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + Set<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSAI(sNSSAI); + List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream() + .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class)) + .collect(Collectors.toList()); + return nearRTRICModels; + } + + /** + * @param sNSSAI + * @return config Details + */ + public Map<String, Integer> findSliceProfileconfig(String sNSSAI) { + logger.debug("Request recieved to fetch Config requested for a slice:" + sNSSAI); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + Map<String, Integer> configDetails = new HashMap<String, Integer>(); + String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI); + RANSliceInfo rANSliceInfo = + ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get() + : null; + if (rANSliceInfo.getSliceProfilesList().size() > 0) { + rANSliceInfo.getSliceProfilesList().forEach(sliceProfile -> { + if (sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())) { + // configDetails.put("maxNoOfConns",sliceProfile.getMaxNumberofConns()); + configDetails.put("dLThptPerSlice", sliceProfile.getdLThptPerSlice()); + configDetails.put("uLThptPerSlice", sliceProfile.getuLThptPerSlice()); + } + }); + } + return configDetails; + } + + /** + * @param sNSSAI + * @return RIC Config for a slice + */ + public Map<Integer, NSSAIConfig> findSliceConfig(String sNSSAI) { + logger.debug("Request recieved to fetch Slice config Details at RICs:" + sNSSAI); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI); + Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>(); + nearRTRICModels.forEach(nearRTRIC -> { + nearRTRIC.getpLMNInfoList().forEach(plmn -> { + if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) { + configMap.put(nearRTRIC.getNearRTRICId(), plmn.getsNSSAI().getConfigData()); + } + }); + }); + return configMap; + } + + /** + * @param sNSSAI + * @return List<GNBDUModel> + */ + public List<GNBDUModel> findDUsofSNssai(String sNSSAI) { + logger.debug("Request recieved to fetch all DUs of NSSAI"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findDUsByNSSAI(sNSSAI); + List<GNBDUModel> duModels = duList.stream().map(duEntity -> modelMapper.map(duEntity, GNBDUModel.class)) + .collect(Collectors.toList()); + return duModels; + } + + /** + * @param sNSSAI + * @return List<GNBCUCPModel> + */ + public List<GNBCUCPModel> findCUsofSNssai(String sNSSAI) { + logger.debug("Request recieved to fetch all CUs of NSSAI"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<GNBCUCPFunction> cuList = (List<GNBCUCPFunction>) gNBCUCPRepository.findCUCPsByNSSAI(sNSSAI); + List<GNBCUCPModel> cuModels = cuList.stream().map(cuEntity -> modelMapper.map(cuEntity, GNBCUCPModel.class)) + .collect(Collectors.toList()); + return cuModels; + } + + /** + * @param sNSSAI + * @return Map<String, String> + */ + public Map<String, String> getSubscriberDetails(String sNSSAI) { + logger.debug("Request recieved to fetch SubscriberDetails"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + Map<String, String> details = new HashMap<String, String>(); + String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI); + details.put("ranNFNSSIId", ranNFNSSIId); + details.put("sNSSAI", sNSSAI); + RANSliceInfo rANSliceInfo = + ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get() + : null; + if (rANSliceInfo.getSliceProfilesList().size() > 0) { + rANSliceInfo.getSliceProfilesList().forEach(sliceProfile -> { + if (sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())) { + details.put("sliceProfileId", sliceProfile.getSliceProfileId()); + } + }); + } + List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI); + nearRTRICModels.forEach(nearRTRIC -> { + nearRTRIC.getpLMNInfoList().forEach(plmn -> { + if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) { + details.put("subscriptionServiceType", plmn.getsNSSAI().getSubscriptionServiceType()); + details.put("globalSubscriberId", plmn.getsNSSAI().getGlobalSubscriberId()); + } + }); + }); + + return details; + } + + // Data required for PM data Simulation + /** + * @return List<GNBCUCPModel> + */ + public List<GNBCUCPModel> findAllCUCPFunctions() { + logger.debug("Request recieved to fetch all CUCPs"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<GNBCUCPFunction> cucpsList = (List<GNBCUCPFunction>) gNBCUCPRepository.findAll(); + List<GNBCUCPModel> cucpModels = cucpsList.stream() + .map(cucpEntity -> modelMapper.map(cucpEntity, GNBCUCPModel.class)).collect(Collectors.toList()); + return cucpModels; + } + + /** + * @return List<GNBDUModel> + */ + public List<GNBDUModel> findAllDUFunctions() { + logger.debug("Request recieved to fetch all DUs"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findAll(); + List<GNBDUModel> duModels = duList.stream().map(duEntity -> { + GNBDUModel gnbDuModel = modelMapper.map(duEntity, GNBDUModel.class); + gnbDuModel.setNearRTRICId(duEntity.getNearRTRIC().getNearRTRICId()); + return gnbDuModel; + }).collect(Collectors.toList()); + return duModels; + } + + public List<NearRTRICModel> findAllNearRTRIC() { + logger.debug("Request received to fetch all NearRTRICModel"); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + List<NearRTRIC> rtricList = (List<NearRTRIC>) nearRTRICRepository.findAll(); + List<NearRTRICModel> rtricmodels = rtricList.stream() + .map(rtricEntity -> modelMapper.map(rtricEntity, NearRTRICModel.class)).collect(Collectors.toList()); + return rtricmodels; + } + } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java index a06f3c7..6197751 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java @@ -20,6 +20,8 @@ package org.onap.ransim.rest.api.services; +import com.google.gson.Gson; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -42,1039 +44,1016 @@ import javax.annotation.PostConstruct; import javax.websocket.Session; import org.apache.log4j.Logger; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.onap.ransim.netconf.NetconfClient; import org.onap.ransim.rest.api.handler.RansimPciHandler; import org.onap.ransim.rest.api.models.CellData; import org.onap.ransim.rest.api.models.CellDetails; import org.onap.ransim.rest.api.models.CellNeighbor; +import org.onap.ransim.rest.api.models.NSSAIConfig; import org.onap.ransim.rest.api.models.NbrDump; import org.onap.ransim.rest.api.models.NeighborDetails; import org.onap.ransim.rest.api.models.NeihborId; import org.onap.ransim.rest.api.models.NetconfServers; import org.onap.ransim.rest.api.models.PLMNInfo; -import org.onap.ransim.rest.api.models.TopologyDump; -import org.onap.ransim.rest.api.models.RRMPolicyRatio; import org.onap.ransim.rest.api.models.RRMPolicyMember; +import org.onap.ransim.rest.api.models.RRMPolicyRatio; import org.onap.ransim.rest.api.models.SliceProfile; +import org.onap.ransim.rest.api.models.TopologyDump; import org.onap.ransim.rest.api.repository.GNBCUUPRepository; import org.onap.ransim.rest.api.repository.NRCellCURepository; import org.onap.ransim.rest.api.repository.NRCellDURepository; -//import org.onap.ransim.rest.api.repository.PLMNInfoRepo; import org.onap.ransim.rest.api.repository.RRMPolicyRepository; import org.onap.ransim.rest.api.repository.SliceProfileRepository; import org.onap.ransim.rest.client.RestClient; +import org.onap.ransim.rest.web.mapper.GNBCUCPModel; +import org.onap.ransim.rest.web.mapper.GNBCUUPModel; +import org.onap.ransim.rest.web.mapper.GNBDUModel; +import org.onap.ransim.rest.web.mapper.NRCellCUModel; +import org.onap.ransim.rest.web.mapper.NRCellDUModel; +import org.onap.ransim.rest.web.mapper.NSSAIData; +import org.onap.ransim.rest.web.mapper.NearRTRICModel; +import org.onap.ransim.rest.web.mapper.PLMNInfoModel; +import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel; import org.onap.ransim.utilities.RansimUtilities; +import org.onap.ransim.websocket.model.*; +import org.onap.ransim.websocket.model.ConfigData; +import org.onap.ransim.websocket.model.ConfigPLMNInfo; import org.onap.ransim.websocket.model.ModifyNeighbor; import org.onap.ransim.websocket.model.ModifyPci; import org.onap.ransim.websocket.model.Neighbor; +import org.onap.ransim.websocket.model.SNSSAI; import org.onap.ransim.websocket.model.SetConfigTopology; import org.onap.ransim.websocket.model.Topology; import org.onap.ransim.websocket.model.UpdateCell; -import org.onap.ransim.websocket.model.ConfigPLMNInfo; -import org.onap.ransim.websocket.model.SNSSAI; -import org.onap.ransim.websocket.model.ConfigData; import org.onap.ransim.websocket.server.RansimWebSocketServer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.onap.ransim.rest.web.mapper.NearRTRICModel; -import org.onap.ransim.rest.web.mapper.GNBCUCPModel; -import org.onap.ransim.rest.web.mapper.GNBCUUPModel; -import org.onap.ransim.rest.web.mapper.GNBDUModel; -import org.onap.ransim.rest.web.mapper.NRCellDUModel; -import org.onap.ransim.rest.web.mapper.NRCellCUModel; -import org.onap.ransim.rest.web.mapper.PLMNInfoModel; -import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel; -import org.onap.ransim.rest.web.mapper.NSSAIData; -import org.onap.ransim.rest.api.models.NSSAIConfig; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; -import com.google.gson.Gson; -import org.onap.ransim.websocket.model.*; -import org.onap.ransim.netconf.NetconfClient; - @Service public class RansimControllerServices { - static Logger log = Logger.getLogger(RansimControllerServices.class.getName()); - - Properties netconfConstants = new Properties(); - public int gridSize = 10; - boolean collision = false; - String serverIdPrefix = ""; - public static String useCaseType = ""; - static int numberOfCellsPerNcServer = 15; - int numberOfMachines = 1; - int numberOfProcessPerMc = 5; - boolean strictValidateRansimAgentsAvailability = false; - static public Map<String, Session> webSocketSessions = new ConcurrentHashMap<String, Session>(); - public static Map<String, String> serverIdIpPortMapping = new ConcurrentHashMap<String, String>(); - - static Map<String, String> globalNcServerUuidMap = new ConcurrentHashMap<String, String>(); - static List<String> unassignedServerIds = Collections.synchronizedList(new ArrayList<String>()); - static Map<String, List<String>> serverIdIpNodeMapping = new ConcurrentHashMap<String, List<String>>(); - static Map<String, List<String>> ricIdFunctionMapping = new ConcurrentHashMap<String, List<String>>(); - static List<String> unassignedgNBIds = Collections.synchronizedList(new ArrayList<String>()); - static List<String> unassignedrtRicIds = Collections.synchronizedList(new ArrayList<String>()); + static Logger log = Logger.getLogger(RansimControllerServices.class.getName()); + + Properties netconfConstants = new Properties(); + public int gridSize = 10; + boolean collision = false; + String serverIdPrefix = ""; + public static String useCaseType = ""; + static int numberOfCellsPerNcServer = 15; + int numberOfMachines = 1; + int numberOfProcessPerMc = 5; + boolean strictValidateRansimAgentsAvailability = false; + static public Map<String, Session> webSocketSessions = new ConcurrentHashMap<String, Session>(); + public static Map<String, String> serverIdIpPortMapping = new ConcurrentHashMap<String, String>(); + + static Map<String, String> globalNcServerUuidMap = new ConcurrentHashMap<String, String>(); + static List<String> unassignedServerIds = Collections.synchronizedList(new ArrayList<String>()); + static Map<String, List<String>> serverIdIpNodeMapping = new ConcurrentHashMap<String, List<String>>(); + static Map<String, List<String>> ricIdFunctionMapping = new ConcurrentHashMap<String, List<String>>(); + static List<String> unassignedgNBIds = Collections.synchronizedList(new ArrayList<String>()); + static List<String> unassignedrtRicIds = Collections.synchronizedList(new ArrayList<String>()); static List<NearRTRICModel> rtricModelList = Collections.synchronizedList(new ArrayList<>()); - int nextServerIdNumber = 1001; - String sdnrServerIp = ""; - int sdnrServerPort = 0; - static String sdnrServerUserid = ""; - static String sdnrServerPassword = ""; - private static final String fileBasePath = "/tmp/ransim-install/config/"; - public static String dumpFileName = ""; - public static long maxPciValueAllowed = 503; - - @Autowired - RansimPciHandler rsPciHdlr; - - @Autowired - RansimRepositoryService ransimRepo; - - @Autowired - RANSliceConfigService ranSliceConfigService; - - @Autowired - RRMPolicyRepository rrmPolicyRepository; - - @Autowired - NRCellDURepository nRCellDURepository; - - @Autowired - NRCellCURepository nRCellCURepository; - - @Autowired - GNBCUUPRepository gNBCUUPRepository; -/* - @Autowired - PLMNInfoRepo pLMNInfoRepo; - - */ @Autowired - SliceProfileRepository sliceProfileRepository; - - @PostConstruct - private void startWSTheread() { - new KeepWebsockAliveThread(this).start(); - } - - private String checkIpPortAlreadyExists(String ipPort, Map<String, String> serverIdIpPortMapping) { - String serverId = null; - for (String key : serverIdIpPortMapping.keySet()) { - String value = serverIdIpPortMapping.get(key); - if (value.equals(ipPort)) { - serverId = key; - break; - } - } - return serverId; - } - - /** - * Add web socket sessions. - * * @param ipPort ip address for the session - * @param wsSession session details - */ - public synchronized String addWebSocketSessions(String ipPort, Session wsSession) { - loadProperties(); - if (webSocketSessions.containsKey(ipPort)) { - log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort - + " already exist. Removing old session."); - webSocketSessions.remove(ipPort); - } - - log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort); - webSocketSessions.put(ipPort, wsSession); - String serverId = null; - if (!serverIdIpPortMapping.containsValue(ipPort)) { - if (unassignedServerIds.size() > 0) { - log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort); - serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); - if (serverId == null) { - serverId = unassignedServerIds.remove(0); - } else { - if (unassignedServerIds.contains(serverId)) { - unassignedServerIds.remove(serverId); - } - } - log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedServerIds); - log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort); - serverIdIpPortMapping.put(serverId, ipPort); - log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); - mapServerIdToNodes(serverId); - try { - - NetconfServers server = ransimRepo.getNetconfServer(serverId); - if (server != null) { - server.setIp(ipPort.split(":")[0]); - server.setNetconfPort(ipPort.split(":")[1]); - ransimRepo.mergeNetconfServers(server); - } - - } catch (Exception e1) { - log.error("Exception mapServerIdToNodes :", e1); - } - } else { - log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort); - } - } else { - for (String key : serverIdIpPortMapping.keySet()) { - if (serverIdIpPortMapping.get(key).equals(ipPort)) { - log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already"); - serverId = key; - break; - } - } - } - return serverId; - } - - public synchronized String addRanWebSocketSessions(String ipPort, Session wsSession) { - if (webSocketSessions.containsKey(ipPort)) { - log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort - + " already exist. Removing old session."); - webSocketSessions.remove(ipPort); - } - - log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort); - webSocketSessions.put(ipPort, wsSession); - String serverId = null; - if (!serverIdIpPortMapping.containsValue(ipPort)) { - if(!ricIdFunctionMapping.isEmpty()){ - if (unassignedgNBIds.size() > 0) { - log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort); - serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); - if (serverId == null) { - serverId = unassignedgNBIds.remove(0); - } else { - if (unassignedgNBIds.contains(serverId)) { - unassignedgNBIds.remove(serverId); - } - } - log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedgNBIds); - log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort); - serverIdIpPortMapping.put(serverId, ipPort); - log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); - try { - NetconfServers server = ransimRepo.getNetconfServer(serverId); - if (server != null) { - server.setIp(ipPort.split(":")[0]); - server.setNetconfPort(ipPort.split(":")[1]); - ransimRepo.mergeNetconfServers(server); - } - - } catch (Exception e1) { - log.error("Exception mapServerIdToNodes :", e1); - } - } else - { - if(unassignedrtRicIds.size() > 0) - { - unassignedgNBIds.addAll(ricIdFunctionMapping.get(unassignedrtRicIds.get(0))); + int nextServerIdNumber = 1001; + String sdnrServerIp = ""; + int sdnrServerPort = 0; + static String sdnrServerUserid = ""; + static String sdnrServerPassword = ""; + private static final String fileBasePath = "/tmp/ransim-install/config/"; + public static String dumpFileName = ""; + public static long maxPciValueAllowed = 503; + + @Autowired + RansimPciHandler rsPciHdlr; + + @Autowired + RansimRepositoryService ransimRepo; + + @Autowired + RANSliceConfigService ranSliceConfigService; + + @Autowired + RRMPolicyRepository rrmPolicyRepository; + + @Autowired + NRCellDURepository nRCellDURepository; + + @Autowired + NRCellCURepository nRCellCURepository; + + @Autowired + GNBCUUPRepository gNBCUUPRepository; + /* + * @Autowired + * PLMNInfoRepo pLMNInfoRepo; + * + */ @Autowired + SliceProfileRepository sliceProfileRepository; + + @PostConstruct + private void startWSTheread() { + new KeepWebsockAliveThread(this).start(); + } + + private String checkIpPortAlreadyExists(String ipPort, Map<String, String> serverIdIpPortMapping) { + String serverId = null; + for (String key : serverIdIpPortMapping.keySet()) { + String value = serverIdIpPortMapping.get(key); + if (value.equals(ipPort)) { + serverId = key; + break; + } + } + return serverId; + } + + /** + * Add web socket sessions. + * * @param ipPort ip address for the session + * + * @param wsSession session details + */ + public synchronized String addWebSocketSessions(String ipPort, Session wsSession) { + loadProperties(); + if (webSocketSessions.containsKey(ipPort)) { + log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort + + " already exist. Removing old session."); + webSocketSessions.remove(ipPort); + } + + log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort); + webSocketSessions.put(ipPort, wsSession); + String serverId = null; + if (!serverIdIpPortMapping.containsValue(ipPort)) { + if (unassignedServerIds.size() > 0) { log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort); - serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); - if (serverId == null) { - serverId = unassignedrtRicIds.remove(0); - } else { - if (unassignedrtRicIds.contains(serverId)) { - unassignedrtRicIds.remove(serverId); - } - } - log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedrtRicIds); - log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort); - serverIdIpPortMapping.put(serverId, ipPort); - log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); - try { - NetconfServers server = ransimRepo.getNetconfServer(serverId); - if (server != null) { - server.setIp(ipPort.split(":")[0]); - server.setNetconfPort(ipPort.split(":")[1]); - ransimRepo.mergeNetconfServers(server); - } - - } catch (Exception e1) { - log.error("Exception mapServerIdToNodes :", e1); - } - } - else - { - log.info("addWebSocketSessions: No ric serverIds pending to assign for " + ipPort); - } - } - } - else - { - log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort); - } - } else { - for (String key : serverIdIpPortMapping.keySet()) { - if (serverIdIpPortMapping.get(key).equals(ipPort)) { - log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already"); - serverId = key; - break; - } - } - } - return serverId; - } - - /** - * Map server ID to the cells - * - * @param serverId Server ID - */ - private void mapServerIdToNodes(String serverId) { - dumpSessionDetails(); - // already mapped.RansimController Do nothing. - if (!serverIdIpNodeMapping.containsKey(serverId)) { - List<String> nodeIds = new ArrayList<String>(); - try { - List<CellDetails> nodes = ransimRepo.getCellsWithNoServerIds(); - for (CellDetails cell : nodes) { - cell.setServerId(serverId); - nodeIds.add(cell.getNodeId()); - ransimRepo.mergeCellDetails(cell); - } - serverIdIpNodeMapping.put(serverId, nodeIds); - } catch (Exception e1) { - log.info("Exception mapServerIdToNodes :", e1); - - } - } - } - - /** - * It removes the web socket sessions. - * - * @param ipPort ip address of the netconf server - */ - public synchronized void removeWebSocketSessions(String ipPort) { - log.info("remove websocket session request received for: " + ipPort); - try { - if (webSocketSessions.containsKey(ipPort)) { - String removedServerId = null; - for (String serverId : serverIdIpPortMapping.keySet()) { - String ipPortVal = serverIdIpPortMapping.get(serverId); - if (ipPortVal.equals(ipPort)) { - if (!unassignedServerIds.contains(serverId)) { - unassignedServerIds.add(serverId); - log.info(serverId + "added in unassignedServerIds"); - } - NetconfServers ns = ransimRepo.getNetconfServer(serverId); - ns.setIp(null); - ns.setNetconfPort(null); - log.info(serverId + " ip and Port set as null "); - ransimRepo.mergeNetconfServers(ns); - removedServerId = serverId; - break; - } - } - serverIdIpPortMapping.remove(removedServerId); - - Session wsSession = webSocketSessions.remove(ipPort); - log.info("removeWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort - + " is removed. Server Id : " + removedServerId); - } else { - log.info("addWebSocketSessions: Client session for " + ipPort + " not exist"); - } - } catch (Exception e) { - log.error("Exception in removeWebSocketSessions. e: " + e); - } - - } - - /** - * Checks the number of ransim agents running. - * - * @param cellsToBeSimulated number of cells to be simulated - * @return returns true if there are enough ransim agents running - */ - public boolean hasEnoughRansimAgentsRunning(int cellsToBeSimulated) { - - log.info("hasEnoughRansimAgentsRunning: numberOfCellsPerNCServer " + numberOfCellsPerNcServer - + " , webSocketSessions.size:" + webSocketSessions.size() + " , cellsToBeSimulated:" - + cellsToBeSimulated); - log.info(strictValidateRansimAgentsAvailability); - - if (strictValidateRansimAgentsAvailability) { - if (numberOfCellsPerNcServer * webSocketSessions.size() < cellsToBeSimulated) { - return false; - } - } - return true; - } - - /** - * It updates the constant values in the properties file. - */ - public void loadProperties() { - InputStream input = null; - try { - - input = new FileInputStream("/tmp/ransim-install/config/ransim.properties"); - netconfConstants.load(input); - serverIdPrefix = netconfConstants.getProperty("serverIdPrefix"); - numberOfCellsPerNcServer = Integer.parseInt(netconfConstants.getProperty("numberOfCellsPerNCServer")); - numberOfMachines = Integer.parseInt(netconfConstants.getProperty("numberOfMachines")); - numberOfProcessPerMc = Integer.parseInt(netconfConstants.getProperty("numberOfProcessPerMc")); - strictValidateRansimAgentsAvailability = Boolean - .parseBoolean(netconfConstants.getProperty("strictValidateRansimAgentsAvailability")); - maxPciValueAllowed = Long.parseLong(netconfConstants.getProperty("maxPciValueAllowed")); - sdnrServerIp = System.getenv("SDNR_IP"); + serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); + if (serverId == null) { + serverId = unassignedServerIds.remove(0); + } else { + if (unassignedServerIds.contains(serverId)) { + unassignedServerIds.remove(serverId); + } + } + log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedServerIds); + log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort); + serverIdIpPortMapping.put(serverId, ipPort); + log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); + mapServerIdToNodes(serverId); + try { + + NetconfServers server = ransimRepo.getNetconfServer(serverId); + if (server != null) { + server.setIp(ipPort.split(":")[0]); + server.setNetconfPort(ipPort.split(":")[1]); + ransimRepo.mergeNetconfServers(server); + } + + } catch (Exception e1) { + log.error("Exception mapServerIdToNodes :", e1); + } + } else { + log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort); + } + } else { + for (String key : serverIdIpPortMapping.keySet()) { + if (serverIdIpPortMapping.get(key).equals(ipPort)) { + log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already"); + serverId = key; + break; + } + } + } + return serverId; + } + + public synchronized String addRanWebSocketSessions(String ipPort, Session wsSession) { + if (webSocketSessions.containsKey(ipPort)) { + log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort + + " already exist. Removing old session."); + webSocketSessions.remove(ipPort); + } + + log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort); + webSocketSessions.put(ipPort, wsSession); + String serverId = null; + if (!serverIdIpPortMapping.containsValue(ipPort)) { + if (!ricIdFunctionMapping.isEmpty()) { + if (unassignedgNBIds.size() > 0) { + log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort); + serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); + if (serverId == null) { + serverId = unassignedgNBIds.remove(0); + } else { + if (unassignedgNBIds.contains(serverId)) { + unassignedgNBIds.remove(serverId); + } + } + log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedgNBIds); + log.info( + "RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort); + serverIdIpPortMapping.put(serverId, ipPort); + log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); + try { + NetconfServers server = ransimRepo.getNetconfServer(serverId); + if (server != null) { + server.setIp(ipPort.split(":")[0]); + server.setNetconfPort(ipPort.split(":")[1]); + ransimRepo.mergeNetconfServers(server); + } + + } catch (Exception e1) { + log.error("Exception mapServerIdToNodes :", e1); + } + } else { + if (unassignedrtRicIds.size() > 0) { + unassignedgNBIds.addAll(ricIdFunctionMapping.get(unassignedrtRicIds.get(0))); + log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort); + serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping); + if (serverId == null) { + serverId = unassignedrtRicIds.remove(0); + } else { + if (unassignedrtRicIds.contains(serverId)) { + unassignedrtRicIds.remove(serverId); + } + } + log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedrtRicIds); + log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + + ipPort); + serverIdIpPortMapping.put(serverId, ipPort); + log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping); + try { + NetconfServers server = ransimRepo.getNetconfServer(serverId); + if (server != null) { + server.setIp(ipPort.split(":")[0]); + server.setNetconfPort(ipPort.split(":")[1]); + ransimRepo.mergeNetconfServers(server); + } + + } catch (Exception e1) { + log.error("Exception mapServerIdToNodes :", e1); + } + } else { + log.info("addWebSocketSessions: No ric serverIds pending to assign for " + ipPort); + } + } + } else { + log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort); + } + } else { + for (String key : serverIdIpPortMapping.keySet()) { + if (serverIdIpPortMapping.get(key).equals(ipPort)) { + log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already"); + serverId = key; + break; + } + } + } + return serverId; + } + + /** + * Map server ID to the cells + * + * @param serverId Server ID + */ + private void mapServerIdToNodes(String serverId) { + dumpSessionDetails(); + // already mapped.RansimController Do nothing. + if (!serverIdIpNodeMapping.containsKey(serverId)) { + List<String> nodeIds = new ArrayList<String>(); + try { + List<CellDetails> nodes = ransimRepo.getCellsWithNoServerIds(); + for (CellDetails cell : nodes) { + cell.setServerId(serverId); + nodeIds.add(cell.getNodeId()); + ransimRepo.mergeCellDetails(cell); + } + serverIdIpNodeMapping.put(serverId, nodeIds); + } catch (Exception e1) { + log.info("Exception mapServerIdToNodes :", e1); + + } + } + } + + /** + * It removes the web socket sessions. + * + * @param ipPort ip address of the netconf server + */ + public synchronized void removeWebSocketSessions(String ipPort) { + log.info("remove websocket session request received for: " + ipPort); + try { + if (webSocketSessions.containsKey(ipPort)) { + String removedServerId = null; + for (String serverId : serverIdIpPortMapping.keySet()) { + String ipPortVal = serverIdIpPortMapping.get(serverId); + if (ipPortVal.equals(ipPort)) { + if (!unassignedServerIds.contains(serverId)) { + unassignedServerIds.add(serverId); + log.info(serverId + "added in unassignedServerIds"); + } + NetconfServers ns = ransimRepo.getNetconfServer(serverId); + ns.setIp(null); + ns.setNetconfPort(null); + log.info(serverId + " ip and Port set as null "); + ransimRepo.mergeNetconfServers(ns); + removedServerId = serverId; + break; + } + } + serverIdIpPortMapping.remove(removedServerId); + + Session wsSession = webSocketSessions.remove(ipPort); + log.info("removeWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort + + " is removed. Server Id : " + removedServerId); + } else { + log.info("addWebSocketSessions: Client session for " + ipPort + " not exist"); + } + } catch (Exception e) { + log.error("Exception in removeWebSocketSessions. e: " + e); + } + + } + + /** + * Checks the number of ransim agents running. + * + * @param cellsToBeSimulated number of cells to be simulated + * @return returns true if there are enough ransim agents running + */ + public boolean hasEnoughRansimAgentsRunning(int cellsToBeSimulated) { + + log.info("hasEnoughRansimAgentsRunning: numberOfCellsPerNCServer " + numberOfCellsPerNcServer + + " , webSocketSessions.size:" + webSocketSessions.size() + " , cellsToBeSimulated:" + + cellsToBeSimulated); + log.info(strictValidateRansimAgentsAvailability); + + if (strictValidateRansimAgentsAvailability) { + if (numberOfCellsPerNcServer * webSocketSessions.size() < cellsToBeSimulated) { + return false; + } + } + return true; + } + + /** + * It updates the constant values in the properties file. + */ + public void loadProperties() { + InputStream input = null; + try { + + input = new FileInputStream("/tmp/ransim-install/config/ransim.properties"); + netconfConstants.load(input); + serverIdPrefix = netconfConstants.getProperty("serverIdPrefix"); + numberOfCellsPerNcServer = Integer.parseInt(netconfConstants.getProperty("numberOfCellsPerNCServer")); + numberOfMachines = Integer.parseInt(netconfConstants.getProperty("numberOfMachines")); + numberOfProcessPerMc = Integer.parseInt(netconfConstants.getProperty("numberOfProcessPerMc")); + strictValidateRansimAgentsAvailability = + Boolean.parseBoolean(netconfConstants.getProperty("strictValidateRansimAgentsAvailability")); + maxPciValueAllowed = Long.parseLong(netconfConstants.getProperty("maxPciValueAllowed")); + sdnrServerIp = System.getenv("SDNR_IP"); sdnrServerPort = Integer.parseInt(System.getenv("SDNR_PORT")); sdnrServerUserid = System.getenv("SDNR_USER"); sdnrServerPassword = System.getenv("SDNR_PASSWORD"); useCaseType = "sonUsecase"; - } catch (Exception e) { - log.error("Properties file error", e); - } finally { - try { - if (input != null) { - input.close(); - } - } catch (Exception ex) { - log.error("Properties file error", ex); - } - } - } - - public void loadGNBFunctionProperties() { - try - { - sdnrServerIp = System.getenv("SDNR_IP"); + } catch (Exception e) { + log.error("Properties file error", e); + } finally { + try { + if (input != null) { + input.close(); + } + } catch (Exception ex) { + log.error("Properties file error", ex); + } + } + } + + public void loadGNBFunctionProperties() { + try { + sdnrServerIp = System.getenv("SDNR_IP"); sdnrServerPort = Integer.parseInt(System.getenv("SDNR_PORT")); sdnrServerUserid = System.getenv("SDNR_USER"); sdnrServerPassword = System.getenv("SDNR_PASSWORD"); useCaseType = "ranSlicingUsecase"; - rtricModelList = ranSliceConfigService.findAllNearRTRIC(); - for(NearRTRICModel rtricModel:rtricModelList) - { - List<String> gNBList = new ArrayList<>(); - for(GNBCUCPModel gNBCUCPModel : rtricModel.getgNBCUCPList()) - { - gNBList.add(gNBCUCPModel.getgNBCUName()); - setRanNetconfServers(gNBCUCPModel.getgNBCUName()); - for(NRCellCUModel nRCellCUModel : gNBCUCPModel.getCellCUList()) - { - if(nRCellCUModel.getpLMNInfoList().isEmpty()) - { - org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser(); - try (FileReader reader = new FileReader("/tmp/ransim-install/config/gNBCUConfig.json")) { - // Read JSON file - Object obj = jsonParser.parse(reader); - JSONArray List = (JSONArray) obj; - for (int i = 0; i < List.size(); i++) { - JSONObject gNB = (JSONObject) List.get(i); - String gNBCUName = (String) gNB.get("gNBCUName"); - Long gNBId = (Long) gNB.get("gNBId"); - Long gNBIdLength = (Long) gNB.get("gNBIdLength"); - String pLMNId = (String) gNB.get("pLMNId"); - String nFType = (String) gNB.get("nFType"); - Long nearRTRICId = (Long) gNB.get("nearRTRICId"); - String cellListVar = (String) gNB.get("cellCUList").toString(); - Object cellListObj = jsonParser.parse(cellListVar); - JSONArray cellList = (JSONArray) cellListObj; - List<NRCellCUModel> nRCellCUModelList = new ArrayList<NRCellCUModel>(); - for (int j = 0; j < cellList.size(); j++) { - JSONObject cell = (JSONObject) cellList.get(j); - Long cellLocalId = (Long) cell.get("cellLocalId"); - String plmVar = (String) cell.get("pLMNInfoList").toString(); - Object pmlVarObj = jsonParser.parse(plmVar); - JSONArray pmlList = (JSONArray) pmlVarObj; - List<PLMNInfoModel> plmnInfoModelList = new ArrayList<PLMNInfoModel>(); - for (int k = 0; k < pmlList.size(); k++) { - JSONObject pml = (JSONObject) pmlList.get(k); - String pLMNid = (String) pml.get("pLMNId"); - JSONObject sNSSAI = (JSONObject) pml.get("sNSSAI"); - String sNssai = (String) sNSSAI.get("sNSSAI"); - String status = (String) sNSSAI.get("status"); - JSONObject configData = (JSONObject) sNSSAI.get("configData"); - Long maxNumberOfConns = (Long) configData.get("maxNumberOfConns"); - NSSAIConfig configDataObj = new NSSAIConfig(); - configDataObj.setMaxNumberOfConns(maxNumberOfConns.intValue()); - NSSAIData nssaiData = new NSSAIData(); - nssaiData.setsNSSAI(sNssai); - nssaiData.setStatus(status); - nssaiData.setConfigData(configDataObj); - PLMNInfoModel plmnInfoModel = new PLMNInfoModel(); - plmnInfoModel.setpLMNId(pLMNid); - plmnInfoModel.setsNSSAI(nssaiData); - plmnInfoModelList.add(plmnInfoModel); - } - NRCellCUModel nrCellCUModel = new NRCellCUModel(); - nrCellCUModel.setCellLocalId(cellLocalId.intValue()); - nrCellCUModel.setpLMNInfoList(plmnInfoModelList); - nRCellCUModelList.add(nrCellCUModel); - } - GNBCUCPModel gNBModel = new GNBCUCPModel(); - gNBModel.setgNBCUName(gNBCUName); - gNBModel.setgNBId(gNBId.intValue()); - gNBModel.setgNBIdLength(gNBIdLength.intValue()); - gNBModel.setpLMNId(pLMNId); - gNBModel.setnFType(nFType); - gNBModel.setNearRTRICId(nearRTRICId.intValue()); - gNBModel.setCellCUList(nRCellCUModelList); - ranSliceConfigService.saveGNBCUCP(gNBModel); - } - } catch (Exception e) { - log.error("Properties file error", e); - } - } - } - } - for(GNBCUUPModel gNBCUUPModel:rtricModel.getgNBCUUPList()) - { - gNBList.add(gNBCUUPModel.getgNBCUUPId().toString()); - setRanNetconfServers(gNBCUUPModel.getgNBCUUPId().toString()); + rtricModelList = ranSliceConfigService.findAllNearRTRIC(); + for (NearRTRICModel rtricModel : rtricModelList) { + List<String> gNBList = new ArrayList<>(); + for (GNBCUCPModel gNBCUCPModel : rtricModel.getgNBCUCPList()) { + gNBList.add(gNBCUCPModel.getgNBCUName()); + setRanNetconfServers(gNBCUCPModel.getgNBCUName()); + for (NRCellCUModel nRCellCUModel : gNBCUCPModel.getCellCUList()) { + if (nRCellCUModel.getpLMNInfoList().isEmpty()) { + org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser(); + try (FileReader reader = new FileReader("/tmp/ransim-install/config/gNBCUConfig.json")) { + // Read JSON file + Object obj = jsonParser.parse(reader); + JSONArray List = (JSONArray) obj; + for (int i = 0; i < List.size(); i++) { + JSONObject gNB = (JSONObject) List.get(i); + String gNBCUName = (String) gNB.get("gNBCUName"); + Long gNBId = (Long) gNB.get("gNBId"); + Long gNBIdLength = (Long) gNB.get("gNBIdLength"); + String pLMNId = (String) gNB.get("pLMNId"); + String nFType = (String) gNB.get("nFType"); + Long nearRTRICId = (Long) gNB.get("nearRTRICId"); + String cellListVar = (String) gNB.get("cellCUList").toString(); + Object cellListObj = jsonParser.parse(cellListVar); + JSONArray cellList = (JSONArray) cellListObj; + List<NRCellCUModel> nRCellCUModelList = new ArrayList<NRCellCUModel>(); + for (int j = 0; j < cellList.size(); j++) { + JSONObject cell = (JSONObject) cellList.get(j); + Long cellLocalId = (Long) cell.get("cellLocalId"); + String plmVar = (String) cell.get("pLMNInfoList").toString(); + Object pmlVarObj = jsonParser.parse(plmVar); + JSONArray pmlList = (JSONArray) pmlVarObj; + List<PLMNInfoModel> plmnInfoModelList = new ArrayList<PLMNInfoModel>(); + for (int k = 0; k < pmlList.size(); k++) { + JSONObject pml = (JSONObject) pmlList.get(k); + String pLMNid = (String) pml.get("pLMNId"); + JSONObject sNSSAI = (JSONObject) pml.get("sNSSAI"); + String sNssai = (String) sNSSAI.get("sNSSAI"); + String status = (String) sNSSAI.get("status"); + JSONObject configData = (JSONObject) sNSSAI.get("configData"); + Long maxNumberOfConns = (Long) configData.get("maxNumberOfConns"); + NSSAIConfig configDataObj = new NSSAIConfig(); + configDataObj.setMaxNumberOfConns(maxNumberOfConns.intValue()); + NSSAIData nssaiData = new NSSAIData(); + nssaiData.setsNSSAI(sNssai); + nssaiData.setStatus(status); + nssaiData.setConfigData(configDataObj); + PLMNInfoModel plmnInfoModel = new PLMNInfoModel(); + plmnInfoModel.setpLMNId(pLMNid); + plmnInfoModel.setsNSSAI(nssaiData); + plmnInfoModelList.add(plmnInfoModel); + } + NRCellCUModel nrCellCUModel = new NRCellCUModel(); + nrCellCUModel.setCellLocalId(cellLocalId.intValue()); + nrCellCUModel.setpLMNInfoList(plmnInfoModelList); + nRCellCUModelList.add(nrCellCUModel); + } + GNBCUCPModel gNBModel = new GNBCUCPModel(); + gNBModel.setgNBCUName(gNBCUName); + gNBModel.setgNBId(gNBId.intValue()); + gNBModel.setgNBIdLength(gNBIdLength.intValue()); + gNBModel.setpLMNId(pLMNId); + gNBModel.setnFType(nFType); + gNBModel.setNearRTRICId(nearRTRICId.intValue()); + gNBModel.setCellCUList(nRCellCUModelList); + ranSliceConfigService.saveGNBCUCP(gNBModel); + } + } catch (Exception e) { + log.error("Properties file error", e); + } + } + } + } + for (GNBCUUPModel gNBCUUPModel : rtricModel.getgNBCUUPList()) { + gNBList.add(gNBCUUPModel.getgNBCUUPId().toString()); + setRanNetconfServers(gNBCUUPModel.getgNBCUUPId().toString()); + } + for (GNBDUModel gNBDUModel : rtricModel.getgNBDUList()) { + gNBList.add(gNBDUModel.getgNBDUId().toString()); + setRanNetconfServers(gNBDUModel.getgNBDUId().toString()); + } + unassignedrtRicIds.add(rtricModel.getNearRTRICId().toString()); + ricIdFunctionMapping.put(rtricModel.getNearRTRICId().toString(), gNBList); + setRanNetconfServers(rtricModel.getNearRTRICId().toString()); } - for(GNBDUModel gNBDUModel:rtricModel.getgNBDUList()) - { - gNBList.add(gNBDUModel.getgNBDUId().toString()); - setRanNetconfServers(gNBDUModel.getgNBDUId().toString()); + } catch (Exception e) { + log.error("Properties file error", e); + } + } + + public void setRanNetconfServers(String serverId) { + try { + + NetconfServers server = ransimRepo.getNetconfServer(serverId); + if (server == null) { + server = new NetconfServers(); + server.setServerId(serverId); } - unassignedrtRicIds.add(rtricModel.getNearRTRICId().toString()); - ricIdFunctionMapping.put(rtricModel.getNearRTRICId().toString(),gNBList); - setRanNetconfServers(rtricModel.getNearRTRICId().toString()); - } - } - catch(Exception e){ - log.error("Properties file error", e); - } - } - - public void setRanNetconfServers(String serverId) - { - try { - - NetconfServers server = ransimRepo.getNetconfServer(serverId); - if (server == null) { - server = new NetconfServers(); - server.setServerId(serverId); - } - ransimRepo.mergeNetconfServers(server); - - } catch (Exception eu) { - log.error("setNetconfServers Function Error", eu); - - } - } - - - /** - * The function adds the cell(with nodeId passed as an argument) to its netconf - * server list if the netconf server already exists. Else it will create a new - * netconf server in the NetconfServers Table and the cell into its list. - * - * @param nodeId node Id of the cell - */ - public void setNetconfServers(String nodeId) { - - CellDetails currentCell = ransimRepo.getCellDetail(nodeId); - - Set<CellDetails> newList = new HashSet<CellDetails>(); - try { - if (currentCell != null) { - NetconfServers server = ransimRepo.getNetconfServer(currentCell.getServerId()); - - if (server == null) { - - server = new NetconfServers(); - server.setServerId(currentCell.getServerId()); - } else { - newList.addAll(server.getCells()); - } - - newList.add(currentCell); - server.setCells(newList); - log.info("setNetconfServers: nodeId: " + nodeId + ", X:" + currentCell.getGridX() + ", Y:" - + currentCell.getGridY() + ", ip: " + server.getIp() + ", portNum: " + server.getNetconfPort() - + ", serverId:" + currentCell.getServerId()); - - ransimRepo.mergeNetconfServers(server); - - } - - } catch (Exception eu) { - log.error("setNetconfServers Function Error", eu); - - } - } - - /** - * generateClusterFromFile() - * - * @throws IOException - */ - public void generateClusterFromFile() throws IOException { - - log.debug("Inside generateClusterFromFile"); - File dumpFile = null; - String cellDetailsString = ""; - - dumpFile = new File(fileBasePath+dumpFileName); - - BufferedReader br = null; - try { - log.debug("Reading dump file"); - br = new BufferedReader(new FileReader(dumpFile)); - - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null) { - sb.append(line); - sb.append("\n"); - line = br.readLine(); - } - cellDetailsString = sb.toString(); - - TopologyDump dumpTopo = new Gson().fromJson(cellDetailsString, TopologyDump.class); - CellDetails cellsDb = new CellDetails(); - - log.info("dumpTopo.getCellList().size():" + dumpTopo.getCellList().size()); - for (int i = 0; i < dumpTopo.getCellList().size(); i++) { - Gson g = new Gson(); - String pnt = g.toJson(dumpTopo.getCellList().get(i)); - log.info("Creating Cell:" + pnt); - log.info("Creating Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId()); - - cellsDb = new CellDetails(); - cellsDb.setNodeId(dumpTopo.getCellList().get(i).getCell().getNodeId()); - cellsDb.setPhysicalCellId(dumpTopo.getCellList().get(i).getCell().getPhysicalCellId()); - cellsDb.setLongitude(dumpTopo.getCellList().get(i).getCell().getLongitude()); - cellsDb.setLatitude(dumpTopo.getCellList().get(i).getCell().getLatitude()); - cellsDb.setServerId(dumpTopo.getCellList().get(i).getCell().getPnfName()); - if (!unassignedServerIds.contains(cellsDb.getServerId())) { - unassignedServerIds.add(cellsDb.getServerId()); - } - cellsDb.setNetworkId(dumpTopo.getCellList().get(i).getCell().getNetworkId()); - - double lon = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLongitude()); - double lat = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLatitude()); - - double xx = (lon - 0) * RansimUtilities.metersDeglon(0); - double yy = (lat - 0) * RansimUtilities.metersDeglat(0); - - double rad = Math.sqrt(xx * xx + yy * yy); - - if (rad > 0) { - double ct = xx / rad; - double st = yy / rad; - xx = rad * ((ct * Math.cos(0)) + (st * Math.sin(0))); - yy = rad * ((st * Math.cos(0)) - (ct * Math.sin(0))); - } - - cellsDb.setScreenX((float) (xx)); - cellsDb.setScreenY((float) (yy)); - - List<String> attachedNoeds = serverIdIpNodeMapping.get(cellsDb.getServerId()); - log.info("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to " - + cellsDb.getServerId()); - if (attachedNoeds == null) { - attachedNoeds = new ArrayList<String>(); - } - attachedNoeds.add(cellsDb.getNodeId()); - serverIdIpNodeMapping.put(cellsDb.getServerId(), attachedNoeds); - if (attachedNoeds.size() > numberOfCellsPerNcServer) { - log.warn("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to " - + cellsDb.getServerId() + ", But it is exceeding numberOfCellsPerNcServer " - + numberOfCellsPerNcServer); - } - ransimRepo.mergeCellDetails(cellsDb); - setNetconfServers(cellsDb.getNodeId()); - } - - dumpSessionDetails(); - - try { - - for (int i = 0; i < dumpTopo.getCellList().size(); i++) { - - String cellNodeId = dumpTopo.getCellList().get(i).getCell().getNodeId(); - - // neighbor list with the corresponding node id - CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellNodeId); - // cell with the corresponding nodeId - CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId); - - Set<NeighborDetails> newCell = new HashSet<NeighborDetails>(); - - if (currentCell != null) { - if (neighborList == null) { - neighborList = new CellNeighbor(); - neighborList.setNodeId(cellNodeId); - } - List<NbrDump> neighboursFromFile = dumpTopo.getCellList().get(i).getNeighbor(); - log.info("Creating Neighbor for Cell :" + cellNodeId); - for (NbrDump a : neighboursFromFile) { - String id = a.getNodeId().trim(); - boolean noHo = Boolean.parseBoolean(a.getBlacklisted().trim()); - CellDetails neighborCell = ransimRepo.getCellDetail(id); - NeighborDetails neighborDetails = new NeighborDetails( - new NeihborId(currentCell.getNodeId(), neighborCell.getNodeId()), noHo); - - newCell.add(neighborDetails); - } - - neighborList.setNeighborList(newCell); - ransimRepo.mergeCellNeighbor(neighborList); - rsPciHdlr.setCollisionConfusionFromFile(cellNodeId); - - } - - } - - } catch (Exception e1) { - log.error("Exception generateClusterFromFile :", e1); - } - - try { - - long startTimeSectorNumber = System.currentTimeMillis(); - for (int i = 0; i < dumpTopo.getCellList().size(); i++) { - - CellData icellData = dumpTopo.getCellList().get(i); - CellDetails icell = ransimRepo.getCellDetail(icellData.getCell().getNodeId()); - int icount = icell.getSectorNumber(); - if (icount == 0) { - log.info("Setting sectorNumber for Cell(i) :" + icell.getNodeId()); - int jcount = 0; - for (int j = (i + 1); j < dumpTopo.getCellList().size(); j++) { - - CellData jcellData = dumpTopo.getCellList().get(j); - if (icellData.getCell().getLatitude().equals(jcellData.getCell().getLatitude())) { - if (icellData.getCell().getLongitude().equals(jcellData.getCell().getLongitude())) { - - if (icount == 0) { - icount++; - jcount = icount + 1; - } - - CellDetails jcell = ransimRepo - .getCellDetail(dumpTopo.getCellList().get(j).getCell().getNodeId()); - - jcell.setSectorNumber(jcount); - log.info("Setting sectorNumber for Cell(j) :" + jcell.getNodeId() + " icell: " - + icell.getNodeId() + " Sector number: " + jcount); - ransimRepo.mergeCellDetails(jcell); - jcount++; - if (jcount > 3) { - break; - } - } - } - } - icell.setSectorNumber(icount); - ransimRepo.mergeCellDetails(icell); - } - - } - - long endTimeSectorNumber = System.currentTimeMillis(); - log.info("Time taken for setting sector number: " + (endTimeSectorNumber - startTimeSectorNumber)); - - } catch (Exception e3) { - log.error("Exception generateClusterFromFile :", e3); - } - - } catch (Exception e) { - log.error("Exception generateClusterFromFile :", e); - - } finally { - br.close(); - } - } - - /** - * The function deletes the cell from the database with the nodeId passed in the - * arguments. It removes the cell from its neighbor's neighbor list and the - * netconf server list. - * - * @param nodeId node Id of the cell to be deleted. - * @return returns success or failure message - */ - public String deleteCellFunction(String nodeId) { - String result = "failure node dosent exist"; - log.info("deleteCellFunction called with nodeId :" + nodeId); - - try { - CellDetails deleteCelldetail = ransimRepo.getCellDetail(nodeId); - - CellNeighbor deleteCellNeighbor = ransimRepo.getCellNeighbor(nodeId); - - if (deleteCelldetail != null) { - if (deleteCellNeighbor != null) { - List<CellNeighbor> cellNeighborList = ransimRepo.getCellNeighborList(); - for (CellNeighbor cellNeighbors : cellNeighborList) { - Set<NeighborDetails> currentCellNeighbors = new HashSet<NeighborDetails>( - cellNeighbors.getNeighborList()); - - NeihborId deleteNeighborDetail = new NeihborId(cellNeighbors.getNodeId(), - deleteCelldetail.getNodeId()); - - if (currentCellNeighbors.contains(deleteNeighborDetail)) { - log.info("Deleted Cell is Neighbor of NodeId : " + cellNeighbors.getNodeId()); - currentCellNeighbors.remove(deleteNeighborDetail); - cellNeighbors.setNeighborList(currentCellNeighbors); - ransimRepo.mergeCellNeighbor(cellNeighbors); - } - } - - deleteCellNeighbor.getNeighborList().clear(); - ransimRepo.deleteCellNeighbor(deleteCellNeighbor); - } - - ransimRepo.deleteCellDetails(deleteCelldetail); - result = "cell has been deleted from the database"; - } else { - log.info("cell id does not exist"); - result = "failure nodeId dosent exist"; - return result; - } - } catch (Exception eu) { - log.error("Exception deleteCellFunction :", eu); - result = "Exception in function"; - } - return result; - } - - /** - * Send configuration details to all the netconf server. - */ - public void sendInitialConfigAll() { - try { - dumpSessionDetails(); - List<NetconfServers> ncServers = ransimRepo.getNetconfServersList(); - for (NetconfServers netconfServers : ncServers) { - String ipPortKey = serverIdIpPortMapping.get(netconfServers.getServerId()); - if (ipPortKey == null || ipPortKey.trim().equals("")) { - log.info("No client for " + netconfServers.getServerId()); - for (String ipPortKeyStr : webSocketSessions.keySet()) { - if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) { - serverIdIpPortMapping.put(netconfServers.getServerId(), ipPortKeyStr); - ipPortKey = ipPortKeyStr; - break; - } - } - } - if (ipPortKey != null && !ipPortKey.trim().equals("")) { - Session clSess = webSocketSessions.get(ipPortKey); - if (clSess != null) { - sendInitialConfig(netconfServers.getServerId()); - try { - String[] agentDetails = ipPortKey.split(":"); - new RestClient().sendMountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp, - sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid, - sdnrServerPassword); - } catch (Exception ex1) { - log.info("Ignoring exception", ex1); - } - - } else { - log.info("No session for " + ipPortKey); - } - } - } - } catch (Exception eu) { - log.error("Exception:", eu); - } - } - - public void sendRanInitialConfigAll() { - try { - List<NearRTRICModel> ncServers = ranSliceConfigService.findAllNearRTRIC(); - for (NearRTRICModel netconfServers : ncServers) { - String ipPortKey = serverIdIpPortMapping.get(netconfServers.getNearRTRICId()); - if (ipPortKey == null || ipPortKey.trim().equals("")) { - log.info("No client for " + netconfServers.getNearRTRICId()); - for (String ipPortKeyStr : webSocketSessions.keySet()) { - if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) { - serverIdIpPortMapping.put(netconfServers.getNearRTRICId().toString(), ipPortKeyStr); - ipPortKey = ipPortKeyStr; - break; - } - } - } - if (ipPortKey != null && !ipPortKey.trim().equals("")) { - Session clSess = webSocketSessions.get(ipPortKey); - if (clSess != null) { - sendRanInitialConfig(netconfServers.getNearRTRICId().toString()); - try { - String[] agentDetails = ipPortKey.split(":"); - new RestClient().sendMountRequestToSdnr(netconfServers.getNearRTRICId().toString(), sdnrServerIp, + ransimRepo.mergeNetconfServers(server); + + } catch (Exception eu) { + log.error("setNetconfServers Function Error", eu); + + } + } + + /** + * The function adds the cell(with nodeId passed as an argument) to its netconf + * server list if the netconf server already exists. Else it will create a new + * netconf server in the NetconfServers Table and the cell into its list. + * + * @param nodeId node Id of the cell + */ + public void setNetconfServers(String nodeId) { + + CellDetails currentCell = ransimRepo.getCellDetail(nodeId); + + Set<CellDetails> newList = new HashSet<CellDetails>(); + try { + if (currentCell != null) { + NetconfServers server = ransimRepo.getNetconfServer(currentCell.getServerId()); + + if (server == null) { + + server = new NetconfServers(); + server.setServerId(currentCell.getServerId()); + } else { + newList.addAll(server.getCells()); + } + + newList.add(currentCell); + server.setCells(newList); + log.info("setNetconfServers: nodeId: " + nodeId + ", X:" + currentCell.getGridX() + ", Y:" + + currentCell.getGridY() + ", ip: " + server.getIp() + ", portNum: " + server.getNetconfPort() + + ", serverId:" + currentCell.getServerId()); + + ransimRepo.mergeNetconfServers(server); + + } + + } catch (Exception eu) { + log.error("setNetconfServers Function Error", eu); + + } + } + + /** + * generateClusterFromFile() + * + * @throws IOException + */ + public void generateClusterFromFile() throws IOException { + + log.debug("Inside generateClusterFromFile"); + File dumpFile = null; + String cellDetailsString = ""; + + dumpFile = new File(fileBasePath + dumpFileName); + + BufferedReader br = null; + try { + log.debug("Reading dump file"); + br = new BufferedReader(new FileReader(dumpFile)); + + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + cellDetailsString = sb.toString(); + + TopologyDump dumpTopo = new Gson().fromJson(cellDetailsString, TopologyDump.class); + CellDetails cellsDb = new CellDetails(); + + log.info("dumpTopo.getCellList().size():" + dumpTopo.getCellList().size()); + for (int i = 0; i < dumpTopo.getCellList().size(); i++) { + Gson g = new Gson(); + String pnt = g.toJson(dumpTopo.getCellList().get(i)); + log.info("Creating Cell:" + pnt); + log.info("Creating Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId()); + + cellsDb = new CellDetails(); + cellsDb.setNodeId(dumpTopo.getCellList().get(i).getCell().getNodeId()); + cellsDb.setPhysicalCellId(dumpTopo.getCellList().get(i).getCell().getPhysicalCellId()); + cellsDb.setLongitude(dumpTopo.getCellList().get(i).getCell().getLongitude()); + cellsDb.setLatitude(dumpTopo.getCellList().get(i).getCell().getLatitude()); + cellsDb.setServerId(dumpTopo.getCellList().get(i).getCell().getPnfName()); + if (!unassignedServerIds.contains(cellsDb.getServerId())) { + unassignedServerIds.add(cellsDb.getServerId()); + } + cellsDb.setNetworkId(dumpTopo.getCellList().get(i).getCell().getNetworkId()); + + double lon = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLongitude()); + double lat = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLatitude()); + + double xx = (lon - 0) * RansimUtilities.metersDeglon(0); + double yy = (lat - 0) * RansimUtilities.metersDeglat(0); + + double rad = Math.sqrt(xx * xx + yy * yy); + + if (rad > 0) { + double ct = xx / rad; + double st = yy / rad; + xx = rad * ((ct * Math.cos(0)) + (st * Math.sin(0))); + yy = rad * ((st * Math.cos(0)) - (ct * Math.sin(0))); + } + + cellsDb.setScreenX((float) (xx)); + cellsDb.setScreenY((float) (yy)); + + List<String> attachedNoeds = serverIdIpNodeMapping.get(cellsDb.getServerId()); + log.info("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to " + + cellsDb.getServerId()); + if (attachedNoeds == null) { + attachedNoeds = new ArrayList<String>(); + } + attachedNoeds.add(cellsDb.getNodeId()); + serverIdIpNodeMapping.put(cellsDb.getServerId(), attachedNoeds); + if (attachedNoeds.size() > numberOfCellsPerNcServer) { + log.warn("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to " + + cellsDb.getServerId() + ", But it is exceeding numberOfCellsPerNcServer " + + numberOfCellsPerNcServer); + } + ransimRepo.mergeCellDetails(cellsDb); + setNetconfServers(cellsDb.getNodeId()); + } + + dumpSessionDetails(); + + try { + + for (int i = 0; i < dumpTopo.getCellList().size(); i++) { + + String cellNodeId = dumpTopo.getCellList().get(i).getCell().getNodeId(); + + // neighbor list with the corresponding node id + CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellNodeId); + // cell with the corresponding nodeId + CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId); + + Set<NeighborDetails> newCell = new HashSet<NeighborDetails>(); + + if (currentCell != null) { + if (neighborList == null) { + neighborList = new CellNeighbor(); + neighborList.setNodeId(cellNodeId); + } + List<NbrDump> neighboursFromFile = dumpTopo.getCellList().get(i).getNeighbor(); + log.info("Creating Neighbor for Cell :" + cellNodeId); + for (NbrDump a : neighboursFromFile) { + String id = a.getNodeId().trim(); + boolean noHo = Boolean.parseBoolean(a.getBlacklisted().trim()); + CellDetails neighborCell = ransimRepo.getCellDetail(id); + NeighborDetails neighborDetails = new NeighborDetails( + new NeihborId(currentCell.getNodeId(), neighborCell.getNodeId()), noHo); + + newCell.add(neighborDetails); + } + + neighborList.setNeighborList(newCell); + ransimRepo.mergeCellNeighbor(neighborList); + rsPciHdlr.setCollisionConfusionFromFile(cellNodeId); + + } + + } + + } catch (Exception e1) { + log.error("Exception generateClusterFromFile :", e1); + } + + try { + + long startTimeSectorNumber = System.currentTimeMillis(); + for (int i = 0; i < dumpTopo.getCellList().size(); i++) { + + CellData icellData = dumpTopo.getCellList().get(i); + CellDetails icell = ransimRepo.getCellDetail(icellData.getCell().getNodeId()); + int icount = icell.getSectorNumber(); + if (icount == 0) { + log.info("Setting sectorNumber for Cell(i) :" + icell.getNodeId()); + int jcount = 0; + for (int j = (i + 1); j < dumpTopo.getCellList().size(); j++) { + + CellData jcellData = dumpTopo.getCellList().get(j); + if (icellData.getCell().getLatitude().equals(jcellData.getCell().getLatitude())) { + if (icellData.getCell().getLongitude().equals(jcellData.getCell().getLongitude())) { + + if (icount == 0) { + icount++; + jcount = icount + 1; + } + + CellDetails jcell = ransimRepo + .getCellDetail(dumpTopo.getCellList().get(j).getCell().getNodeId()); + + jcell.setSectorNumber(jcount); + log.info("Setting sectorNumber for Cell(j) :" + jcell.getNodeId() + " icell: " + + icell.getNodeId() + " Sector number: " + jcount); + ransimRepo.mergeCellDetails(jcell); + jcount++; + if (jcount > 3) { + break; + } + } + } + } + icell.setSectorNumber(icount); + ransimRepo.mergeCellDetails(icell); + } + + } + + long endTimeSectorNumber = System.currentTimeMillis(); + log.info("Time taken for setting sector number: " + (endTimeSectorNumber - startTimeSectorNumber)); + + } catch (Exception e3) { + log.error("Exception generateClusterFromFile :", e3); + } + + } catch (Exception e) { + log.error("Exception generateClusterFromFile :", e); + + } finally { + br.close(); + } + } + + /** + * The function deletes the cell from the database with the nodeId passed in the + * arguments. It removes the cell from its neighbor's neighbor list and the + * netconf server list. + * + * @param nodeId node Id of the cell to be deleted. + * @return returns success or failure message + */ + public String deleteCellFunction(String nodeId) { + String result = "failure node dosent exist"; + log.info("deleteCellFunction called with nodeId :" + nodeId); + + try { + CellDetails deleteCelldetail = ransimRepo.getCellDetail(nodeId); + + CellNeighbor deleteCellNeighbor = ransimRepo.getCellNeighbor(nodeId); + + if (deleteCelldetail != null) { + if (deleteCellNeighbor != null) { + List<CellNeighbor> cellNeighborList = ransimRepo.getCellNeighborList(); + for (CellNeighbor cellNeighbors : cellNeighborList) { + Set<NeighborDetails> currentCellNeighbors = + new HashSet<NeighborDetails>(cellNeighbors.getNeighborList()); + + NeihborId deleteNeighborDetail = + new NeihborId(cellNeighbors.getNodeId(), deleteCelldetail.getNodeId()); + + if (currentCellNeighbors.contains(deleteNeighborDetail)) { + log.info("Deleted Cell is Neighbor of NodeId : " + cellNeighbors.getNodeId()); + currentCellNeighbors.remove(deleteNeighborDetail); + cellNeighbors.setNeighborList(currentCellNeighbors); + ransimRepo.mergeCellNeighbor(cellNeighbors); + } + } + + deleteCellNeighbor.getNeighborList().clear(); + ransimRepo.deleteCellNeighbor(deleteCellNeighbor); + } + + ransimRepo.deleteCellDetails(deleteCelldetail); + result = "cell has been deleted from the database"; + } else { + log.info("cell id does not exist"); + result = "failure nodeId dosent exist"; + return result; + } + } catch (Exception eu) { + log.error("Exception deleteCellFunction :", eu); + result = "Exception in function"; + } + return result; + } + + /** + * Send configuration details to all the netconf server. + */ + public void sendInitialConfigAll() { + try { + dumpSessionDetails(); + List<NetconfServers> ncServers = ransimRepo.getNetconfServersList(); + for (NetconfServers netconfServers : ncServers) { + String ipPortKey = serverIdIpPortMapping.get(netconfServers.getServerId()); + if (ipPortKey == null || ipPortKey.trim().equals("")) { + log.info("No client for " + netconfServers.getServerId()); + for (String ipPortKeyStr : webSocketSessions.keySet()) { + if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) { + serverIdIpPortMapping.put(netconfServers.getServerId(), ipPortKeyStr); + ipPortKey = ipPortKeyStr; + break; + } + } + } + if (ipPortKey != null && !ipPortKey.trim().equals("")) { + Session clSess = webSocketSessions.get(ipPortKey); + if (clSess != null) { + sendInitialConfig(netconfServers.getServerId()); + try { + String[] agentDetails = ipPortKey.split(":"); + new RestClient().sendMountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp, sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid, sdnrServerPassword); - } catch (Exception ex1) { - log.info("Ignoring exception", ex1); - } - - } else { - log.info("No session for " + ipPortKey); - } - } - } - } catch (Exception eu) { - log.error("Exception:", eu); - } + } catch (Exception ex1) { + log.info("Ignoring exception", ex1); + } + + } else { + log.info("No session for " + ipPortKey); + } + } + } + } catch (Exception eu) { + log.error("Exception:", eu); + } } + public void sendRanInitialConfigAll() { + try { + List<NearRTRICModel> ncServers = ranSliceConfigService.findAllNearRTRIC(); + for (NearRTRICModel netconfServers : ncServers) { + String ipPortKey = serverIdIpPortMapping.get(netconfServers.getNearRTRICId()); + if (ipPortKey == null || ipPortKey.trim().equals("")) { + log.info("No client for " + netconfServers.getNearRTRICId()); + for (String ipPortKeyStr : webSocketSessions.keySet()) { + if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) { + serverIdIpPortMapping.put(netconfServers.getNearRTRICId().toString(), ipPortKeyStr); + ipPortKey = ipPortKeyStr; + break; + } + } + } + if (ipPortKey != null && !ipPortKey.trim().equals("")) { + Session clSess = webSocketSessions.get(ipPortKey); + if (clSess != null) { + sendRanInitialConfig(netconfServers.getNearRTRICId().toString()); + try { + String[] agentDetails = ipPortKey.split(":"); + new RestClient().sendMountRequestToSdnr(netconfServers.getNearRTRICId().toString(), + sdnrServerIp, sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid, + sdnrServerPassword); + } catch (Exception ex1) { + log.info("Ignoring exception", ex1); + } + + } else { + log.info("No session for " + ipPortKey); + } + } + } + } catch (Exception eu) { + log.error("Exception:", eu); + } + } - /** - * Sends initial configuration details of the cells for a new netconf server - * that has been started. - * - * @param ipPortKey ip address details of the netconf server - */ - public void sendInitialConfigForNewAgent(String ipPortKey, String serverId) { - try { - dumpSessionDetails(); - if (ipPortKey != null && !ipPortKey.trim().equals("")) { - if (serverId != null && !serverId.trim().equals("")) { - Session clSess = webSocketSessions.get(ipPortKey); - if (clSess != null) { - String[] agentDetails = ipPortKey.split(":"); - sendInitialConfig(serverId); - new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0], + /** + * Sends initial configuration details of the cells for a new netconf server + * that has been started. + * + * @param ipPortKey ip address details of the netconf server + */ + public void sendInitialConfigForNewAgent(String ipPortKey, String serverId) { + try { + dumpSessionDetails(); + if (ipPortKey != null && !ipPortKey.trim().equals("")) { + if (serverId != null && !serverId.trim().equals("")) { + Session clSess = webSocketSessions.get(ipPortKey); + if (clSess != null) { + String[] agentDetails = ipPortKey.split(":"); + sendInitialConfig(serverId); + new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid, sdnrServerPassword); - - } else { - log.info("No session for " + ipPortKey); - } - } else { - log.info("No serverid for " + ipPortKey); - } - } else { - log.info("Invalid ipPortKey " + ipPortKey); - } - } catch (Exception eu) { - log.info("Exception:", eu); - } - } - - public void sendRanInitialConfigForNewAgent(String ipPortKey, String serverId) { - try { - if (ipPortKey != null && !ipPortKey.trim().equals("")) { - if (serverId != null && !serverId.trim().equals("")) { - Session clSess = webSocketSessions.get(ipPortKey); - if (clSess != null) { - String[] agentDetails = ipPortKey.split(":"); - sendRanInitialConfig(serverId); - new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0], + + } else { + log.info("No session for " + ipPortKey); + } + } else { + log.info("No serverid for " + ipPortKey); + } + } else { + log.info("Invalid ipPortKey " + ipPortKey); + } + } catch (Exception eu) { + log.info("Exception:", eu); + } + } + + public void sendRanInitialConfigForNewAgent(String ipPortKey, String serverId) { + try { + if (ipPortKey != null && !ipPortKey.trim().equals("")) { + if (serverId != null && !serverId.trim().equals("")) { + Session clSess = webSocketSessions.get(ipPortKey); + if (clSess != null) { + String[] agentDetails = ipPortKey.split(":"); + sendRanInitialConfig(serverId); + new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid, sdnrServerPassword); - } else { - log.info("No session for " + ipPortKey); - } - } else { - log.info("No serverid for " + ipPortKey); - } - } else { - log.info("Invalid ipPortKey " + ipPortKey); - } - } catch (Exception eu) { - log.info("Exception:", eu); - } - } - - public void sendRanInitialConfig(String serverId) { - - try - { - NetconfServers server = ransimRepo.getNetconfServer(serverId); - log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server); - if (server == null) { - return; - } - - for(NearRTRICModel rtRicModel:rtricModelList) { - if(rtRicModel.getNearRTRICId().toString().equals(serverId)) { - getInitalConfigTree(rtRicModel,serverId); - NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(), - server.getIp(), Integer.parseInt(server.getNetconfPort())); - - netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel,serverId)); + } else { + log.info("No session for " + ipPortKey); + } + } else { + log.info("No serverid for " + ipPortKey); + } + } else { + log.info("Invalid ipPortKey " + ipPortKey); + } + } catch (Exception eu) { + log.info("Exception:", eu); + } + } + + public void sendRanInitialConfig(String serverId) { + + try { + NetconfServers server = ransimRepo.getNetconfServer(serverId); + log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server); + if (server == null) { + return; } - else { - for(Map.Entry<String,List<String>> entry : ricIdFunctionMapping.entrySet()) { - for(String value : entry.getValue()) { - if(value.equals(serverId) && rtRicModel.getNearRTRICId().toString().equals(entry.getKey())) { - getInitalConfigTree(rtRicModel,serverId); - NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(), - server.getIp(), Integer.parseInt(server.getNetconfPort())); - - netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel,serverId)); - } - } - } - } + + for (NearRTRICModel rtRicModel : rtricModelList) { + if (rtRicModel.getNearRTRICId().toString().equals(serverId)) { + getInitalConfigTree(rtRicModel, serverId); + NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(), + server.getIp(), Integer.parseInt(server.getNetconfPort())); + + netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel, serverId)); + } else { + for (Map.Entry<String, List<String>> entry : ricIdFunctionMapping.entrySet()) { + for (String value : entry.getValue()) { + if (value.equals(serverId) + && rtRicModel.getNearRTRICId().toString().equals(entry.getKey())) { + getInitalConfigTree(rtRicModel, serverId); + NetconfClient netconfClient = + new NetconfClient("ransim", "admin", "admin", server.getServerId(), + server.getIp(), Integer.parseInt(server.getNetconfPort())); + + netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel, serverId)); + } + } + } + } + } + + } catch (Exception eu) { + log.info("Exception:", eu); } - - } - catch (Exception eu) { - log.info("Exception:", eu); - } - - } - - /** + + } + + /** * Gets the initial config tree from the database. */ - private void getInitalConfigTree(NearRTRICModel rtRicModel,String serverId) { + private void getInitalConfigTree(NearRTRICModel rtRicModel, String serverId) { RanNetwork ranNetwork = new RanNetwork(); List<NearRTRIC> nearRTRICList = new ArrayList<>(); - + NearRTRIC nearRTRIC = new NearRTRIC(); nearRTRIC.setIdNearRTRIC(rtRicModel.getNearRTRICId().toString()); Attributes attributes = new Attributes(); attributes.setLocationName("Palmdale"); attributes.setgNBId(rtRicModel.getgNBId().toString()); nearRTRIC.setAttributes(attributes); - + List<GNBCUUPFunction> gNBCUUPFunctionList = new ArrayList<>(); - for(GNBCUUPModel gNBCUUPModel:rtRicModel.getgNBCUUPList()) - { - if(gNBCUUPModel.getgNBCUUPId().toString().equals(serverId) || rtRicModel.getNearRTRICId().toString().equals(serverId)) - { - GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction(); - Attributes cUUPattributes = new Attributes(); - cUUPattributes.setgNBCUUPId(gNBCUUPModel.getgNBCUUPId().toString()); - gNBCUUPFunction.setAttributes(cUUPattributes); - gNBCUUPFunction.setIdGNBCUUPFunction(gNBCUUPModel.getgNBCUUPId().toString()); - gNBCUUPFunctionList.add(gNBCUUPFunction); - } + for (GNBCUUPModel gNBCUUPModel : rtRicModel.getgNBCUUPList()) { + if (gNBCUUPModel.getgNBCUUPId().toString().equals(serverId) + || rtRicModel.getNearRTRICId().toString().equals(serverId)) { + GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction(); + Attributes cUUPattributes = new Attributes(); + cUUPattributes.setgNBCUUPId(gNBCUUPModel.getgNBCUUPId().toString()); + gNBCUUPFunction.setAttributes(cUUPattributes); + gNBCUUPFunction.setIdGNBCUUPFunction(gNBCUUPModel.getgNBCUUPId().toString()); + gNBCUUPFunctionList.add(gNBCUUPFunction); + } } List<GNBDUFunction> gNBDUFunctionList = new ArrayList<>(); - for(GNBDUModel gNBDUModel:rtRicModel.getgNBDUList()) - { - if(gNBDUModel.getgNBDUId().toString().equals(serverId) || rtRicModel.getNearRTRICId().toString().equals(serverId)) - { - GNBDUFunction gNBDUFunction= new GNBDUFunction(); - Attributes dUattributes = new Attributes(); - dUattributes.setgNBId(gNBDUModel.getgNBId().toString()); - gNBDUFunction.setAttributes(dUattributes); - gNBDUFunction.setIdGNBDUFunction(gNBDUModel.getgNBDUId().toString()); - List<NRCellDU> nRCellDUList = new ArrayList<>(); - for(NRCellDUModel nRCellDUModel : gNBDUModel.getCellDUList()) - { - NRCellDU nRCellDU = new NRCellDU(); - Attributes nRCellDUattributes = new Attributes(); - nRCellDUattributes.setOperationalState(nRCellDUModel.getOperationalState()); - nRCellDUattributes.setCellState(nRCellDUModel.getCellState()); - nRCellDU.setAttributes(nRCellDUattributes); - nRCellDU.setIdNRCellDU(nRCellDUModel.getCellLocalId().toString()); - nRCellDUList.add(nRCellDU); - } - gNBDUFunction.setnRCellDU(nRCellDUList); - gNBDUFunctionList.add(gNBDUFunction); + for (GNBDUModel gNBDUModel : rtRicModel.getgNBDUList()) { + if (gNBDUModel.getgNBDUId().toString().equals(serverId) + || rtRicModel.getNearRTRICId().toString().equals(serverId)) { + GNBDUFunction gNBDUFunction = new GNBDUFunction(); + Attributes dUattributes = new Attributes(); + dUattributes.setgNBId(gNBDUModel.getgNBId().toString()); + gNBDUFunction.setAttributes(dUattributes); + gNBDUFunction.setIdGNBDUFunction(gNBDUModel.getgNBDUId().toString()); + List<NRCellDU> nRCellDUList = new ArrayList<>(); + for (NRCellDUModel nRCellDUModel : gNBDUModel.getCellDUList()) { + NRCellDU nRCellDU = new NRCellDU(); + Attributes nRCellDUattributes = new Attributes(); + nRCellDUattributes.setOperationalState(nRCellDUModel.getOperationalState()); + nRCellDUattributes.setCellState(nRCellDUModel.getCellState()); + nRCellDU.setAttributes(nRCellDUattributes); + nRCellDU.setIdNRCellDU(nRCellDUModel.getCellLocalId().toString()); + nRCellDUList.add(nRCellDU); + } + gNBDUFunction.setnRCellDU(nRCellDUList); + gNBDUFunctionList.add(gNBDUFunction); + } } - } nearRTRIC.setgNBDUFunction(gNBDUFunctionList); nearRTRIC.setgNBCUUPFunction(gNBCUUPFunctionList); nearRTRICList.add(nearRTRIC); @@ -1082,114 +1061,113 @@ public class RansimControllerServices { String ipPortKey = serverIdIpPortMapping.get(serverId); log.info("sendInitialConfig: ipPortKey:" + ipPortKey); - - Gson gson = new Gson(); - String jsonStr = gson.toJson(ranNetwork); + + Gson gson = new Gson(); + String jsonStr = gson.toJson(ranNetwork); + log.info("ConfigTopologyMessage: " + jsonStr); + Session session = webSocketSessions.get(ipPortKey); + RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, session); + } + + /** + * To send the initial configration to the netconf server. + * + * @param serverId ip address details of the netconf server + */ + public void sendInitialConfig(String serverId) { + + try { + NetconfServers server = ransimRepo.getNetconfServer(serverId); + log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server); + if (server == null) { + return; + } + + String ipPortKey = serverIdIpPortMapping.get(serverId); + + log.info("sendInitialConfig: ipPortKey:" + ipPortKey); + + List<CellDetails> cellList = new ArrayList<CellDetails>(server.getCells()); + + List<Topology> config = new ArrayList<Topology>(); + + for (int i = 0; i < server.getCells().size(); i++) { + Topology cell = new Topology(); + CellDetails currentCell = ransimRepo.getCellDetail(cellList.get(i).getNodeId()); + CellNeighbor neighbor = ransimRepo.getCellNeighbor(cellList.get(i).getNodeId()); + + cell.setCellId("" + currentCell.getNodeId()); + cell.setPciId(currentCell.getPhysicalCellId()); + cell.setPnfName(serverId); + + List<Neighbor> nbrList = new ArrayList<Neighbor>(); + Set<NeighborDetails> nbrsDet = neighbor.getNeighborList(); + for (NeighborDetails cellDetails : nbrsDet) { + Neighbor nbr = new Neighbor(); + CellDetails nbrCell = ransimRepo.getCellDetail(cellDetails.getNeigbor().getNeighborCell()); + nbr.setNodeId(nbrCell.getNodeId()); + nbr.setPhysicalCellId(nbrCell.getPhysicalCellId()); + nbr.setPnfName(nbrCell.getServerId()); + nbr.setServerId(nbrCell.getServerId()); + nbr.setPlmnId(nbrCell.getNetworkId()); + nbr.setBlacklisted(cellDetails.isBlacklisted()); + nbrList.add(nbr); + } + cell.setNeighborList(nbrList); + config.add(i, cell); + } + + SetConfigTopology topo = new SetConfigTopology(); + + topo.setServerId(server.getServerId()); + String uuid = globalNcServerUuidMap.get(server.getServerId()); + if (uuid == null) { + uuid = getUuid(); + globalNcServerUuidMap.put(server.getServerId(), uuid); + } + topo.setUuid(uuid); + + topo.setTopology(config); + + Gson gson = new Gson(); + String jsonStr = gson.toJson(topo); log.info("ConfigTopologyMessage: " + jsonStr); - Session session = webSocketSessions.get(ipPortKey); - RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, session); + Session clSess = webSocketSessions.get(ipPortKey); + Thread.sleep(10000); + RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, clSess); + + } catch (Exception eu) { + log.info("Exception:", eu); + } + } + private static String getUuid() { + return UUID.randomUUID().toString(); + } - /** - * To send the initial configration to the netconf server. - * - * @param serverId ip address details of the netconf server - */ - public void sendInitialConfig(String serverId) { - - try { - NetconfServers server = ransimRepo.getNetconfServer(serverId); - log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server); - if (server == null) { - return; - } - - String ipPortKey = serverIdIpPortMapping.get(serverId); - - log.info("sendInitialConfig: ipPortKey:" + ipPortKey); - - List<CellDetails> cellList = new ArrayList<CellDetails>(server.getCells()); - - List<Topology> config = new ArrayList<Topology>(); - - for (int i = 0; i < server.getCells().size(); i++) { - Topology cell = new Topology(); - CellDetails currentCell = ransimRepo.getCellDetail(cellList.get(i).getNodeId()); - CellNeighbor neighbor = ransimRepo.getCellNeighbor(cellList.get(i).getNodeId()); - - cell.setCellId("" + currentCell.getNodeId()); - cell.setPciId(currentCell.getPhysicalCellId()); - cell.setPnfName(serverId); - - List<Neighbor> nbrList = new ArrayList<Neighbor>(); - Set<NeighborDetails> nbrsDet = neighbor.getNeighborList(); - for (NeighborDetails cellDetails : nbrsDet) { - Neighbor nbr = new Neighbor(); - CellDetails nbrCell = ransimRepo.getCellDetail(cellDetails.getNeigbor().getNeighborCell()); - nbr.setNodeId(nbrCell.getNodeId()); - nbr.setPhysicalCellId(nbrCell.getPhysicalCellId()); - nbr.setPnfName(nbrCell.getServerId()); - nbr.setServerId(nbrCell.getServerId()); - nbr.setPlmnId(nbrCell.getNetworkId()); - nbr.setBlacklisted(cellDetails.isBlacklisted()); - nbrList.add(nbr); - } - cell.setNeighborList(nbrList); - config.add(i, cell); - } - - SetConfigTopology topo = new SetConfigTopology(); - - topo.setServerId(server.getServerId()); - String uuid = globalNcServerUuidMap.get(server.getServerId()); - if (uuid == null) { - uuid = getUuid(); - globalNcServerUuidMap.put(server.getServerId(), uuid); - } - topo.setUuid(uuid); - - topo.setTopology(config); - - Gson gson = new Gson(); - String jsonStr = gson.toJson(topo); - log.info("ConfigTopologyMessage: " + jsonStr); - Session clSess = webSocketSessions.get(ipPortKey); - Thread.sleep(10000); - RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, clSess); - - } catch (Exception eu) { - log.info("Exception:", eu); - } - - } - - private static String getUuid() { - return UUID.randomUUID().toString(); - } - - /** - * The function alters the database information based on the modifications made - * in the SDNR. - * - * @param message message received from the SDNR - * @param session sends the session details - * @param ipPort ip address of the netconf server - */ - public void handleModifyPciFromSdnr(String message, Session session, String ipPort) { - log.info("handleModifyPciFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); - ModifyPci modifyPci = new Gson().fromJson(message, ModifyPci.class); - log.info("handleModifyPciFromSDNR: modifyPci:" + modifyPci.getCellId() + "; pci: " + modifyPci.getPciId()); - String source = "Netconf"; - CellDetails cd = ransimRepo.getCellDetail(modifyPci.getCellId()); - long pci = cd.getPhysicalCellId(); - cd.setPhysicalCellId(modifyPci.getPciId()); - ransimRepo.mergeCellDetails(cd); - rsPciHdlr.updatePciOperationsTable(modifyPci.getCellId(), source, pci, modifyPci.getPciId()); - } - - public void handleRTRICConfigFromSdnr(String message, Session session, String ipPort) { - log.info("handleReconfigureRTRICFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); + /** + * The function alters the database information based on the modifications made + * in the SDNR. + * + * @param message message received from the SDNR + * @param session sends the session details + * @param ipPort ip address of the netconf server + */ + public void handleModifyPciFromSdnr(String message, Session session, String ipPort) { + log.info("handleModifyPciFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); + ModifyPci modifyPci = new Gson().fromJson(message, ModifyPci.class); + log.info("handleModifyPciFromSDNR: modifyPci:" + modifyPci.getCellId() + "; pci: " + modifyPci.getPciId()); + String source = "Netconf"; + CellDetails cd = ransimRepo.getCellDetail(modifyPci.getCellId()); + long pci = cd.getPhysicalCellId(); + cd.setPhysicalCellId(modifyPci.getPciId()); + ransimRepo.mergeCellDetails(cd); + rsPciHdlr.updatePciOperationsTable(modifyPci.getCellId(), source, pci, modifyPci.getPciId()); + } + + public void handleRTRICConfigFromSdnr(String message, Session session, String ipPort) { + log.info("handleReconfigureRTRICFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); ConfigPLMNInfo configPLMNInfo = new Gson().fromJson(message, ConfigPLMNInfo.class); log.info("handleReconfigureRTRICFromSDNR:" + configPLMNInfo.getSNSSAI()); List<GNBDUModel> gNBDUModelList = new ArrayList<>(); @@ -1197,331 +1175,327 @@ public class RansimControllerServices { headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); HttpEntity<Void> requestEntity = new HttpEntity<>(headers); try { - RestTemplate restTemplate = new RestTemplate(); - ResponseEntity<List<GNBDUModel>> response = restTemplate.exchange("http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list"+configPLMNInfo.getSNSSAI().get(0), HttpMethod.GET, requestEntity, - new ParameterizedTypeReference<List<GNBDUModel>>() { - }); - gNBDUModelList = response.getBody(); - } - catch (Exception e) { - log.info("Exception:", e); + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity<List<GNBDUModel>> response = restTemplate.exchange( + "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list" + + configPLMNInfo.getSNSSAI().get(0), + HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<GNBDUModel>>() {}); + gNBDUModelList = response.getBody(); + } catch (Exception e) { + log.info("Exception:", e); } - for(GNBDUModel gNBDUModel :gNBDUModelList) - { - String serverId = gNBDUModel.getgNBDUId().toString(); - int duCellCount = gNBDUModel.getCellDUList().size(); - for(SNSSAI sNSSAI : configPLMNInfo.getSNSSAI()) { - for(ConfigData configData : sNSSAI.getConfigData()) { - configData.setConfigValue((configData.getConfigValue())/duCellCount); - } - } - String ipPortKey = serverIdIpPortMapping.get(serverId); - log.info("sendConfigRTRICMessage: ipPortKey:" + ipPortKey); - - Gson gson = new Gson(); + for (GNBDUModel gNBDUModel : gNBDUModelList) { + String serverId = gNBDUModel.getgNBDUId().toString(); + int duCellCount = gNBDUModel.getCellDUList().size(); + for (SNSSAI sNSSAI : configPLMNInfo.getSNSSAI()) { + for (ConfigData configData : sNSSAI.getConfigData()) { + configData.setConfigValue((configData.getConfigValue()) / duCellCount); + } + } + String ipPortKey = serverIdIpPortMapping.get(serverId); + log.info("sendConfigRTRICMessage: ipPortKey:" + ipPortKey); + + Gson gson = new Gson(); String jsonStr = gson.toJson(configPLMNInfo); log.info("ConfigRTRICMessage: " + jsonStr); Session duSession = webSocketSessions.get(ipPortKey); RansimWebSocketServer.sendSetReconfigureMessage(jsonStr, duSession); } - } - - public void handleRRMPolicyRatioUpdateFromSdnr(String message, Session session, String ipPort){ - log.info("handle RRMPolicy update: " + message ); - RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class); - rrmPolicyRepository.save(rRMPolicyRatio); - } - - - public void handleRRMPolicyRatioDeleteFromSdnr(String message, Session session, String ipPort) { - log.info("handle RRMPolicyRatio Delete: " + message); - RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class); - rrmPolicyRepository.delete(rRMPolicyRatio); - } - - public void handlePLMNInfoUpdateFromSdnr(String message, Session session, String ipPort) { - log.info("handle PLMNInfo update: "+message); - List<PLMNInfo> pLMNInfoList = null; - org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = new Gson().fromJson(message, - org.onap.ransim.rest.api.models.PLMNInfoModel.class); - PLMNInfo plmnInfo = new PLMNInfo(); - NSSAIConfig nSSAIConfig = new NSSAIConfig(); - nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns())); - org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI(); - sNSSAI.setsNSSAI(plmnInfoModel.getSnssai()); - sNSSAI.setStatus(plmnInfoModel.getStatus()); - sNSSAI.setConfigData(nSSAIConfig); - plmnInfo.setpLMNId(plmnInfoModel.getpLMNId()); - plmnInfo.setsNSSAI(sNSSAI); - try { - if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) { - org.onap.ransim.rest.api.models.NRCellDU nrCellDu = nRCellDURepository - .findById(plmnInfoModel.getNrCellId()).get(); - if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) { - pLMNInfoList = nrCellDu.getpLMNInfoList(); - } else { - pLMNInfoList = new ArrayList<PLMNInfo>(); - } - pLMNInfoList.add(plmnInfo); - nrCellDu.setpLMNInfoList(pLMNInfoList); - nRCellDURepository.save(nrCellDu); - } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) { - org.onap.ransim.rest.api.models.NRCellCU nrCellCu = nRCellCURepository - .findById(plmnInfoModel.getNrCellId()).get(); - if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) { - pLMNInfoList = nrCellCu.getpLMNInfoList(); - } else { - pLMNInfoList = new ArrayList<PLMNInfo>(); - } - pLMNInfoList.add(plmnInfo); - nrCellCu.setpLMNInfoList(pLMNInfoList); - nRCellCURepository.save(nrCellCu); - } else { - org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction = gNBCUUPRepository - .findById(plmnInfoModel.getGnbId()).get(); - if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) { - pLMNInfoList = gNBCUUPFunction.getpLMNInfoList(); - } else { - pLMNInfoList = new ArrayList<PLMNInfo>(); - } - pLMNInfoList.add(plmnInfo); - gNBCUUPFunction.setpLMNInfoList(pLMNInfoList); - gNBCUUPRepository.save(gNBCUUPFunction); - } - } catch (NullPointerException nullPointerException) { - log.error("Record does not exist"); - } catch (Exception e) { - log.error("Unexpected error while fetching data from database: " + e); - } - } - - public void handlePLMNInfoDeleteFromSdnr(String message, Session session, String ipPort) { - log.info("handle PLMNInfo Delete: " + message); - org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = new Gson().fromJson(message, - org.onap.ransim.rest.api.models.PLMNInfoModel.class); - PLMNInfo plmnInfo = new PLMNInfo(); - NSSAIConfig nSSAIConfig = new NSSAIConfig(); - nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns())); - org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI(); - sNSSAI.setsNSSAI(plmnInfoModel.getSnssai()); - sNSSAI.setStatus(plmnInfoModel.getStatus()); - sNSSAI.setConfigData(nSSAIConfig); - plmnInfo.setpLMNId(plmnInfoModel.getpLMNId()); - plmnInfo.setsNSSAI(sNSSAI); - // pLMNInfoRepo.delete(plmnInfo); -} + } + + public void handleRRMPolicyRatioUpdateFromSdnr(String message, Session session, String ipPort) { + log.info("handle RRMPolicy update: " + message); + RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class); + rrmPolicyRepository.save(rRMPolicyRatio); + } + + public void handleRRMPolicyRatioDeleteFromSdnr(String message, Session session, String ipPort) { + log.info("handle RRMPolicyRatio Delete: " + message); + RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class); + rrmPolicyRepository.delete(rRMPolicyRatio); + } + + public void handlePLMNInfoUpdateFromSdnr(String message, Session session, String ipPort) { + log.info("handle PLMNInfo update: " + message); + List<PLMNInfo> pLMNInfoList = null; + org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = + new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class); + PLMNInfo plmnInfo = new PLMNInfo(); + NSSAIConfig nSSAIConfig = new NSSAIConfig(); + nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns())); + org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI(); + sNSSAI.setsNSSAI(plmnInfoModel.getSnssai()); + sNSSAI.setStatus(plmnInfoModel.getStatus()); + sNSSAI.setConfigData(nSSAIConfig); + plmnInfo.setpLMNId(plmnInfoModel.getpLMNId()); + plmnInfo.setsNSSAI(sNSSAI); + try { + if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) { + org.onap.ransim.rest.api.models.NRCellDU nrCellDu = + nRCellDURepository.findById(plmnInfoModel.getNrCellId()).get(); + if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) { + pLMNInfoList = nrCellDu.getpLMNInfoList(); + } else { + pLMNInfoList = new ArrayList<PLMNInfo>(); + } + pLMNInfoList.add(plmnInfo); + nrCellDu.setpLMNInfoList(pLMNInfoList); + nRCellDURepository.save(nrCellDu); + } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) { + org.onap.ransim.rest.api.models.NRCellCU nrCellCu = + nRCellCURepository.findById(plmnInfoModel.getNrCellId()).get(); + if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) { + pLMNInfoList = nrCellCu.getpLMNInfoList(); + } else { + pLMNInfoList = new ArrayList<PLMNInfo>(); + } + pLMNInfoList.add(plmnInfo); + nrCellCu.setpLMNInfoList(pLMNInfoList); + nRCellCURepository.save(nrCellCu); + } else { + org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction = + gNBCUUPRepository.findById(plmnInfoModel.getGnbId()).get(); + if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) { + pLMNInfoList = gNBCUUPFunction.getpLMNInfoList(); + } else { + pLMNInfoList = new ArrayList<PLMNInfo>(); + } + pLMNInfoList.add(plmnInfo); + gNBCUUPFunction.setpLMNInfoList(pLMNInfoList); + gNBCUUPRepository.save(gNBCUUPFunction); + } + } catch (NullPointerException nullPointerException) { + log.error("Record does not exist"); + } catch (Exception e) { + log.error("Unexpected error while fetching data from database: " + e); + } + } - public void handleSliceProfileUpdateFromSdnr(String message, Session session, String ipPort) { - log.info("handle SliceProfile update: "+message); - SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class); - sliceProfileRepository.save(sliceProfile); - } - - public void handleSliceProfileDeleteFromSdnr(String message, Session session, String ipPort) { - log.info("handle SliceProfile delete: "+message); - SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class); - sliceProfileRepository.delete(sliceProfile); - } - - - /** - * The function alters the database information based on the modifications made - * in the SDNR. - * - * @param message message received from the SDNR - * @param session sends the session details - * @param ipPort ip address of the netconf server - */ - public void handleModifyNeighborFromSdnr(String message, Session session, String ipPort) { - log.info("handleModifyAnrFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); - ModifyNeighbor modifyNeighbor = new Gson().fromJson(message, ModifyNeighbor.class); - log.info("handleModifyAnrFromSDNR: modifyPci:" + modifyNeighbor.getCellId()); - List<NeighborDetails> neighborList = new ArrayList<NeighborDetails>(); - List<String> cellList = new ArrayList<String>(); - cellList.add(modifyNeighbor.getCellId()); - String nbrsAdd = ""; - String nbrsDel = ""; - String source = "Netconf"; - - for (int i = 0; i < modifyNeighbor.getNeighborList().size(); i++) { - if (modifyNeighbor.getNeighborList().get(i).isBlacklisted()) { - NeighborDetails nd = new NeighborDetails( - new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()), - true); - ransimRepo.mergeNeighborDetails(nd); - cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId()); - if (nbrsAdd.equals("")) { - nbrsDel = modifyNeighbor.getNeighborList().get(i).getNodeId(); - } else { - nbrsDel += "," + modifyNeighbor.getNeighborList().get(i).getNodeId(); - } - } else { - NeighborDetails nd = new NeighborDetails( - new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()), - false); - ransimRepo.mergeNeighborDetails(nd); - cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId()); - if (nbrsDel.equals("")) { - nbrsAdd = modifyNeighbor.getNeighborList().get(i).getNodeId(); - } else { - nbrsAdd += "," + modifyNeighbor.getNeighborList().get(i).getNodeId(); - } - } - - } - - for (String cl : cellList) { - rsPciHdlr.setCollisionConfusionFromFile(cl); - } - - log.info("neighbor list: " + neighborList); - - rsPciHdlr.updateNbrsOperationsTable(modifyNeighbor.getCellId(), source, nbrsAdd, nbrsDel); - } - - /** - * The function sends the modification made in the GUI to the netconf server. - * - * @param cellId node Id of the cell which was modified - * @param pciId PCI number of the cell which was modified - */ - public void handleModifyPciFromGui(String cellId, long pciId) { - log.info("handleModifyPciFromGUI: cellId:" + cellId + " pciId:" + pciId); - - try { - CellDetails currentCell = ransimRepo.getCellDetail(cellId); - CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellId); - List<Neighbor> nbrList = new ArrayList<Neighbor>(); - Iterator<NeighborDetails> iter = neighborList.getNeighborList().iterator(); - while (iter.hasNext()) { - NeighborDetails nbCell = iter.next(); - Neighbor nbr = new Neighbor(); - CellDetails nbrCell = ransimRepo.getCellDetail(nbCell.getNeigbor().getNeighborCell()); - - nbr.setNodeId(nbrCell.getNodeId()); - nbr.setPhysicalCellId(nbrCell.getPhysicalCellId()); - nbr.setPnfName(nbrCell.getNodeName()); - nbr.setServerId(nbrCell.getServerId()); - nbr.setPlmnId(nbrCell.getNetworkId()); - nbrList.add(nbr); - } - - String pnfName = currentCell.getServerId(); - String ipPort = serverIdIpPortMapping.get(pnfName); - log.info("handleModifyPciFromGui:ipPort >>>>>>> " + ipPort); - - if (ipPort != null && !ipPort.trim().equals("")) { - - String[] ipPortArr = ipPort.split(":"); - Topology oneCell = new Topology(pnfName, pciId, cellId, nbrList); - UpdateCell updatedPci = new UpdateCell(currentCell.getServerId(), ipPortArr[0], ipPortArr[1], oneCell); - Gson gson = new Gson(); - String jsonStr = gson.toJson(updatedPci); - if (ipPort != null && !ipPort.trim().equals("")) { - Session clSess = webSocketSessions.get(ipPort); - if (clSess != null) { - RansimWebSocketServer.sendUpdateCellMessage(jsonStr, clSess); - log.info("handleModifyPciFromGui, message: " + jsonStr); - } else { - log.info("No client session for " + ipPort); - } - } else { - log.info("No client for " + currentCell.getServerId()); - } - } - - } catch (Exception eu) { - - log.error("Exception:", eu); - } - } - - /** - * The function unmounts the connection with SDNR. - * - * @return returns null value - */ - public String stopAllSimulation() { - try { - List<NetconfServers> ncServers = ransimRepo.getNetconfServersList(); - for (NetconfServers netconfServers : ncServers) { - try { - log.info("Unmount " + netconfServers.getServerId()); - new RestClient().sendUnmountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp, + public void handlePLMNInfoDeleteFromSdnr(String message, Session session, String ipPort) { + log.info("handle PLMNInfo Delete: " + message); + org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = + new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class); + PLMNInfo plmnInfo = new PLMNInfo(); + NSSAIConfig nSSAIConfig = new NSSAIConfig(); + nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns())); + org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI(); + sNSSAI.setsNSSAI(plmnInfoModel.getSnssai()); + sNSSAI.setStatus(plmnInfoModel.getStatus()); + sNSSAI.setConfigData(nSSAIConfig); + plmnInfo.setpLMNId(plmnInfoModel.getpLMNId()); + plmnInfo.setsNSSAI(sNSSAI); + // pLMNInfoRepo.delete(plmnInfo); + } + + public void handleSliceProfileUpdateFromSdnr(String message, Session session, String ipPort) { + log.info("handle SliceProfile update: " + message); + SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class); + sliceProfileRepository.save(sliceProfile); + } + + public void handleSliceProfileDeleteFromSdnr(String message, Session session, String ipPort) { + log.info("handle SliceProfile delete: " + message); + SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class); + sliceProfileRepository.delete(sliceProfile); + } + + /** + * The function alters the database information based on the modifications made + * in the SDNR. + * + * @param message message received from the SDNR + * @param session sends the session details + * @param ipPort ip address of the netconf server + */ + public void handleModifyNeighborFromSdnr(String message, Session session, String ipPort) { + log.info("handleModifyAnrFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort); + ModifyNeighbor modifyNeighbor = new Gson().fromJson(message, ModifyNeighbor.class); + log.info("handleModifyAnrFromSDNR: modifyPci:" + modifyNeighbor.getCellId()); + List<NeighborDetails> neighborList = new ArrayList<NeighborDetails>(); + List<String> cellList = new ArrayList<String>(); + cellList.add(modifyNeighbor.getCellId()); + String nbrsAdd = ""; + String nbrsDel = ""; + String source = "Netconf"; + + for (int i = 0; i < modifyNeighbor.getNeighborList().size(); i++) { + if (modifyNeighbor.getNeighborList().get(i).isBlacklisted()) { + NeighborDetails nd = new NeighborDetails( + new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()), + true); + ransimRepo.mergeNeighborDetails(nd); + cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId()); + if (nbrsAdd.equals("")) { + nbrsDel = modifyNeighbor.getNeighborList().get(i).getNodeId(); + } else { + nbrsDel += "," + modifyNeighbor.getNeighborList().get(i).getNodeId(); + } + } else { + NeighborDetails nd = new NeighborDetails( + new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()), + false); + ransimRepo.mergeNeighborDetails(nd); + cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId()); + if (nbrsDel.equals("")) { + nbrsAdd = modifyNeighbor.getNeighborList().get(i).getNodeId(); + } else { + nbrsAdd += "," + modifyNeighbor.getNeighborList().get(i).getNodeId(); + } + } + + } + + for (String cl : cellList) { + rsPciHdlr.setCollisionConfusionFromFile(cl); + } + + log.info("neighbor list: " + neighborList); + + rsPciHdlr.updateNbrsOperationsTable(modifyNeighbor.getCellId(), source, nbrsAdd, nbrsDel); + } + + /** + * The function sends the modification made in the GUI to the netconf server. + * + * @param cellId node Id of the cell which was modified + * @param pciId PCI number of the cell which was modified + */ + public void handleModifyPciFromGui(String cellId, long pciId) { + log.info("handleModifyPciFromGUI: cellId:" + cellId + " pciId:" + pciId); + + try { + CellDetails currentCell = ransimRepo.getCellDetail(cellId); + CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellId); + List<Neighbor> nbrList = new ArrayList<Neighbor>(); + Iterator<NeighborDetails> iter = neighborList.getNeighborList().iterator(); + while (iter.hasNext()) { + NeighborDetails nbCell = iter.next(); + Neighbor nbr = new Neighbor(); + CellDetails nbrCell = ransimRepo.getCellDetail(nbCell.getNeigbor().getNeighborCell()); + + nbr.setNodeId(nbrCell.getNodeId()); + nbr.setPhysicalCellId(nbrCell.getPhysicalCellId()); + nbr.setPnfName(nbrCell.getNodeName()); + nbr.setServerId(nbrCell.getServerId()); + nbr.setPlmnId(nbrCell.getNetworkId()); + nbrList.add(nbr); + } + + String pnfName = currentCell.getServerId(); + String ipPort = serverIdIpPortMapping.get(pnfName); + log.info("handleModifyPciFromGui:ipPort >>>>>>> " + ipPort); + + if (ipPort != null && !ipPort.trim().equals("")) { + + String[] ipPortArr = ipPort.split(":"); + Topology oneCell = new Topology(pnfName, pciId, cellId, nbrList); + UpdateCell updatedPci = new UpdateCell(currentCell.getServerId(), ipPortArr[0], ipPortArr[1], oneCell); + Gson gson = new Gson(); + String jsonStr = gson.toJson(updatedPci); + if (ipPort != null && !ipPort.trim().equals("")) { + Session clSess = webSocketSessions.get(ipPort); + if (clSess != null) { + RansimWebSocketServer.sendUpdateCellMessage(jsonStr, clSess); + log.info("handleModifyPciFromGui, message: " + jsonStr); + } else { + log.info("No client session for " + ipPort); + } + } else { + log.info("No client for " + currentCell.getServerId()); + } + } + + } catch (Exception eu) { + + log.error("Exception:", eu); + } + } + + /** + * The function unmounts the connection with SDNR. + * + * @return returns null value + */ + public String stopAllSimulation() { + try { + List<NetconfServers> ncServers = ransimRepo.getNetconfServersList(); + for (NetconfServers netconfServers : ncServers) { + try { + log.info("Unmount " + netconfServers.getServerId()); + new RestClient().sendUnmountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp, sdnrServerPort, sdnrServerUserid, sdnrServerPassword); - } catch (Exception e) { - log.error("Ignore Exception:", e); - } - serverIdIpNodeMapping.clear(); - } - return "Netconf servers unmounted."; - } catch (Exception eu) { - - log.error("Exception:", eu); - return "Error"; - } - } - - - - /** - * Used to dump session details. - */ - synchronized public static void dumpSessionDetails() { - - try { - - log.info("serverIdIpPortMapping.size:" + serverIdIpPortMapping.size() + "webSocketSessions.size" - + webSocketSessions.size()); - for (String key : serverIdIpPortMapping.keySet()) { - String val = serverIdIpPortMapping.get(key); - Session sess = webSocketSessions.get(val); - log.info("ServerId:" + key + " IpPort:" + val + " Session:" + sess); - } - for (String serverId : unassignedServerIds) { - log.info("Unassigned ServerId:" + serverId); - } - for (String serverId : serverIdIpPortMapping.keySet()) { - List<String> attachedNoeds = serverIdIpNodeMapping.get(serverId); - if (attachedNoeds != null) { - log.info("ServerId:" + serverId + " attachedNoeds.size:" + attachedNoeds.size() + " nodes:" - + attachedNoeds.toArray()); - } else { - log.info("ServerId:" + serverId + " attachedNoeds:" + null); - } - } - } catch (Exception e) { - log.info("Exception:", e); - } - } + } catch (Exception e) { + log.error("Ignore Exception:", e); + } + serverIdIpNodeMapping.clear(); + } + return "Netconf servers unmounted."; + } catch (Exception eu) { + + log.error("Exception:", eu); + return "Error"; + } + } + + /** + * Used to dump session details. + */ + synchronized public static void dumpSessionDetails() { + + try { + + log.info("serverIdIpPortMapping.size:" + serverIdIpPortMapping.size() + "webSocketSessions.size" + + webSocketSessions.size()); + for (String key : serverIdIpPortMapping.keySet()) { + String val = serverIdIpPortMapping.get(key); + Session sess = webSocketSessions.get(val); + log.info("ServerId:" + key + " IpPort:" + val + " Session:" + sess); + } + for (String serverId : unassignedServerIds) { + log.info("Unassigned ServerId:" + serverId); + } + for (String serverId : serverIdIpPortMapping.keySet()) { + List<String> attachedNoeds = serverIdIpNodeMapping.get(serverId); + if (attachedNoeds != null) { + log.info("ServerId:" + serverId + " attachedNoeds.size:" + attachedNoeds.size() + " nodes:" + + attachedNoeds.toArray()); + } else { + log.info("ServerId:" + serverId + " attachedNoeds:" + null); + } + } + } catch (Exception e) { + log.info("Exception:", e); + } + } } + class KeepWebsockAliveThread extends Thread { - static Logger log = Logger.getLogger(KeepWebsockAliveThread.class.getName()); - RansimControllerServices rsCtrlrServices = null; - - KeepWebsockAliveThread(RansimControllerServices ctrlr) { - rsCtrlrServices = ctrlr; - } - - @Override - public void run() { - log.info("Inside KeepWebsockAliveThread run method"); - while (true) { - for (String ipPort : RansimControllerServices.webSocketSessions.keySet()) { - try { - Session sess = RansimControllerServices.webSocketSessions.get(ipPort); - RansimWebSocketServer.sendPingMessage(sess); - log.debug("Sent ping message to Client ipPort:" + ipPort); - } catch (Exception ex1) { - } - } - try { - Thread.sleep(10000); - } catch (InterruptedException ex) { - log.error("Thread interrupted"); - } - } - } + static Logger log = Logger.getLogger(KeepWebsockAliveThread.class.getName()); + RansimControllerServices rsCtrlrServices = null; + + KeepWebsockAliveThread(RansimControllerServices ctrlr) { + rsCtrlrServices = ctrlr; + } + + @Override + public void run() { + log.info("Inside KeepWebsockAliveThread run method"); + while (true) { + for (String ipPort : RansimControllerServices.webSocketSessions.keySet()) { + try { + Session sess = RansimControllerServices.webSocketSessions.get(ipPort); + RansimWebSocketServer.sendPingMessage(sess); + log.debug("Sent ping message to Client ipPort:" + ipPort); + } catch (Exception ex1) { + } + } + try { + Thread.sleep(10000); + } catch (InterruptedException ex) { + log.error("Thread interrupted"); + } + } + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java index e51af6f..ecc76b3 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java @@ -23,6 +23,7 @@ package org.onap.ransim.rest.api.services; import java.util.ArrayList; import java.util.List; import java.util.Optional; + import org.apache.log4j.Logger; import org.onap.ransim.rest.api.models.CellDetails; import org.onap.ransim.rest.api.models.CellNeighbor; @@ -40,225 +41,241 @@ import org.springframework.stereotype.Service; @Service public class RansimRepositoryService { - static Logger log = Logger.getLogger(RansimRepositoryService.class.getName()); + static Logger log = Logger.getLogger(RansimRepositoryService.class.getName()); - @Autowired - CellDetailsRepo cellDetailsRepo; + @Autowired + CellDetailsRepo cellDetailsRepo; - @Autowired - NetconfServersRepo netconfServersRepo; + @Autowired + NetconfServersRepo netconfServersRepo; - @Autowired - CellNeighborRepo cellNeighborRepo; + @Autowired + CellNeighborRepo cellNeighborRepo; - @Autowired - NeighborDetailsRepo neighborDetailsRepo; + @Autowired + NeighborDetailsRepo neighborDetailsRepo; - @Autowired - OperationLogRepo operationLogRepo; + @Autowired + OperationLogRepo operationLogRepo; - /** - * Method to retrieve cell details - * @param nodeId - * @return - */ - public CellDetails getCellDetail(String nodeId) { - Optional<CellDetails> cd = cellDetailsRepo.findById(nodeId); - CellDetails cellDetails = null; - if (cd.isPresent()) { - cellDetails = cd.get(); - } - return cellDetails; - } + /** + * Method to retrieve cell details + * + * @param nodeId + * @return + */ + public CellDetails getCellDetail(String nodeId) { + Optional<CellDetails> cd = cellDetailsRepo.findById(nodeId); + CellDetails cellDetails = null; + if (cd.isPresent()) { + cellDetails = cd.get(); + } + return cellDetails; + } - /** - * Method to retrieve netconf server details - * @param serverId - * @return - */ - public NetconfServers getNetconfServer(String serverId) { - Optional<NetconfServers> serverDetails = netconfServersRepo.findById(serverId); - NetconfServers server = null; - if (serverDetails.isPresent()) { - server = serverDetails.get(); - } - return server; - } + /** + * Method to retrieve netconf server details + * + * @param serverId + * @return + */ + public NetconfServers getNetconfServer(String serverId) { + Optional<NetconfServers> serverDetails = netconfServersRepo.findById(serverId); + NetconfServers server = null; + if (serverDetails.isPresent()) { + server = serverDetails.get(); + } + return server; + } - /** - * Method to retrieve cell neighbors - * @param nodeId - * @return - */ - public CellNeighbor getCellNeighbor(String nodeId) { - Optional<CellNeighbor> cellNeighborDetails = cellNeighborRepo.findById(nodeId); - CellNeighbor cellNeighbor = null; - if (cellNeighborDetails.isPresent()) { - cellNeighbor = cellNeighborDetails.get(); - } - return cellNeighbor; - } + /** + * Method to retrieve cell neighbors + * + * @param nodeId + * @return + */ + public CellNeighbor getCellNeighbor(String nodeId) { + Optional<CellNeighbor> cellNeighborDetails = cellNeighborRepo.findById(nodeId); + CellNeighbor cellNeighbor = null; + if (cellNeighborDetails.isPresent()) { + cellNeighbor = cellNeighborDetails.get(); + } + return cellNeighbor; + } - /** - * Method to retrieve all cell details - * @return - */ - public List<CellDetails> getCellDetailsList() { - Iterable<CellDetails> cellsList = cellDetailsRepo.findAll(); - if (cellsList != null) { - return (List<CellDetails>) cellsList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve all cell details + * + * @return + */ + public List<CellDetails> getCellDetailsList() { + Iterable<CellDetails> cellsList = cellDetailsRepo.findAll(); + if (cellsList != null) { + return (List<CellDetails>) cellsList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to retrieve cells with no server ids - * @return - */ - public List<CellDetails> getCellsWithNoServerIds() { - List<CellDetails> cellsList = cellDetailsRepo.findCellsWithNoServerId(); - if (cellsList != null) { - return cellsList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve cells with no server ids + * + * @return + */ + public List<CellDetails> getCellsWithNoServerIds() { + List<CellDetails> cellsList = cellDetailsRepo.findCellsWithNoServerId(); + if (cellsList != null) { + return cellsList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to retrieve cell with collision or confusion - * @return - */ - public List<CellDetails> getCellsWithCollisionOrConfusion() { - List<CellDetails> cellsList = cellDetailsRepo.getCellsWithCollisionOrConfusion(); - if (cellsList != null) { - return cellsList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve cell with collision or confusion + * + * @return + */ + public List<CellDetails> getCellsWithCollisionOrConfusion() { + List<CellDetails> cellsList = cellDetailsRepo.getCellsWithCollisionOrConfusion(); + if (cellsList != null) { + return cellsList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to retrieve operation log - * @return - */ - public List<OperationLog> getOperationLogList() { - Iterable<OperationLog> opLogList = operationLogRepo.findAll(); - if (opLogList != null) { - return (List<OperationLog>) opLogList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve operation log + * + * @return + */ + public List<OperationLog> getOperationLogList() { + Iterable<OperationLog> opLogList = operationLogRepo.findAll(); + if (opLogList != null) { + return (List<OperationLog>) opLogList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to retrieve all netconf servers - * @return - */ - public List<NetconfServers> getNetconfServersList() { - Iterable<NetconfServers> serversList = netconfServersRepo.findAll(); - if (serversList != null) { - return (List<NetconfServers>) serversList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve all netconf servers + * + * @return + */ + public List<NetconfServers> getNetconfServersList() { + Iterable<NetconfServers> serversList = netconfServersRepo.findAll(); + if (serversList != null) { + return (List<NetconfServers>) serversList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to retrieve all cell neighbors - * @return - */ - public List<CellNeighbor> getCellNeighborList() { - Iterable<CellNeighbor> cellNeighborList = cellNeighborRepo.findAll(); - if (cellNeighborList != null) { - return (List<CellNeighbor>) cellNeighborList; - } else { - return new ArrayList<>(); - } - } + /** + * Method to retrieve all cell neighbors + * + * @return + */ + public List<CellNeighbor> getCellNeighborList() { + Iterable<CellNeighbor> cellNeighborList = cellNeighborRepo.findAll(); + if (cellNeighborList != null) { + return (List<CellNeighbor>) cellNeighborList; + } else { + return new ArrayList<>(); + } + } - /** - * Method to delete specific cells - * @param deleteCelldetail - */ - public void deleteCellDetails(CellDetails deleteCelldetail) { + /** + * Method to delete specific cells + * + * @param deleteCelldetail + */ + public void deleteCellDetails(CellDetails deleteCelldetail) { - if (deleteCelldetail.getServerId() != null) { - NetconfServers ns = getNetconfServer(deleteCelldetail.getServerId()); - if (ns != null) { - ns.getCells().remove(deleteCelldetail); - netconfServersRepo.save(ns); - } - } - cellDetailsRepo.deleteById(deleteCelldetail.getNodeId()); - } + if (deleteCelldetail.getServerId() != null) { + NetconfServers ns = getNetconfServer(deleteCelldetail.getServerId()); + if (ns != null) { + ns.getCells().remove(deleteCelldetail); + netconfServersRepo.save(ns); + } + } + cellDetailsRepo.deleteById(deleteCelldetail.getNodeId()); + } - /** - * Method to delete cell neighbors - * @param deleteCellNeighbor - */ - public void deleteCellNeighbor(CellNeighbor deleteCellNeighbor) { - cellNeighborRepo.deleteById(deleteCellNeighbor.getNodeId()); - } + /** + * Method to delete cell neighbors + * + * @param deleteCellNeighbor + */ + public void deleteCellNeighbor(CellNeighbor deleteCellNeighbor) { + cellNeighborRepo.deleteById(deleteCellNeighbor.getNodeId()); + } - /** - * Method to delete all netconf servers - */ - public void deleteNetconfServers() { - netconfServersRepo.deleteAll(); - } + /** + * Method to delete all netconf servers + */ + public void deleteNetconfServers() { + netconfServersRepo.deleteAll(); + } - /** - * Method to delete all cell neighbors - */ - public void deleteCellNeighbors() { - cellNeighborRepo.deleteAll(); - } + /** + * Method to delete all cell neighbors + */ + public void deleteCellNeighbors() { + cellNeighborRepo.deleteAll(); + } - /** - * Method to delete all cells - */ - public void deleteAllCellDetails() { - cellDetailsRepo.deleteAll(); - } + /** + * Method to delete all cells + */ + public void deleteAllCellDetails() { + cellDetailsRepo.deleteAll(); + } - /** - * Method to save cells - * @param cellDetail - */ - public void mergeCellDetails(CellDetails cellDetail) { - cellDetailsRepo.save(cellDetail); - } + /** + * Method to save cells + * + * @param cellDetail + */ + public void mergeCellDetails(CellDetails cellDetail) { + cellDetailsRepo.save(cellDetail); + } - /** - * Method to save neighbors - * @param neighborDetails - */ - public void mergeNeighborDetails(NeighborDetails neighborDetails) { - neighborDetailsRepo.save(neighborDetails); - } + /** + * Method to save neighbors + * + * @param neighborDetails + */ + public void mergeNeighborDetails(NeighborDetails neighborDetails) { + neighborDetailsRepo.save(neighborDetails); + } - /** - * Method to save netconf servers - * @param netconfServers - */ - public void mergeNetconfServers(NetconfServers netconfServers) { - netconfServersRepo.save(netconfServers); - } + /** + * Method to save netconf servers + * + * @param netconfServers + */ + public void mergeNetconfServers(NetconfServers netconfServers) { + netconfServersRepo.save(netconfServers); + } - /** - * Method to save cell neighbors - * @param cellNeighbor - */ - public void mergeCellNeighbor(CellNeighbor cellNeighbor) { - cellNeighborRepo.save(cellNeighbor); - } + /** + * Method to save cell neighbors + * + * @param cellNeighbor + */ + public void mergeCellNeighbor(CellNeighbor cellNeighbor) { + cellNeighborRepo.save(cellNeighbor); + } - /** - * Method to save operation log - * @param opLog - */ - public void mergeOperationLog(OperationLog opLog) { - operationLogRepo.save(opLog); - } + /** + * Method to save operation log + * + * @param opLog + */ + public void mergeOperationLog(OperationLog opLog) { + operationLogRepo.save(opLog); + } } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java index c03d439..1a74c25 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java @@ -1,261 +1,259 @@ -/*-
- * ============LICENSE_START=======================================================
- * Ran Simulator Controller
- * ================================================================================
- * Copyright (C) 2021 Wipro Limited.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ransim.rest.api.services;
-import java.util.Collection;
-import java.util.Set;
-
-import java.io.File;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.websocket.Session;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import java.io.ByteArrayOutputStream;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.onap.ransim.rest.api.exceptions.RansimException;
-import org.onap.ransim.rest.api.models.NSSAIConfig;
-import org.onap.ransim.rest.web.mapper.GNBDUModel;
-import org.onap.ransim.rest.web.mapper.NRCellDUModel;
-import org.onap.ransim.rest.web.mapper.NSSAIData;
-import org.onap.ransim.rest.web.mapper.PLMNInfoModel;
-import org.onap.ransim.rest.xml.models.FileFooter;
-import org.onap.ransim.rest.xml.models.FileHeader;
-import org.onap.ransim.rest.xml.models.FileSender;
-import org.onap.ransim.rest.xml.models.GranularityPeriod;
-import org.onap.ransim.rest.xml.models.Job;
-import org.onap.ransim.rest.xml.models.ManagedElement;
-import org.onap.ransim.rest.xml.models.MeasCollec;
-import org.onap.ransim.rest.xml.models.MeasCollecEnd;
-import org.onap.ransim.rest.xml.models.MeasCollecFile;
-import org.onap.ransim.rest.xml.models.MeasData;
-import org.onap.ransim.rest.xml.models.MeasInfo;
-import org.onap.ransim.rest.xml.models.MeasType;
-import org.onap.ransim.rest.xml.models.MeasValue;
-import org.onap.ransim.rest.xml.models.ReportingPeriod;
-import org.onap.ransim.rest.xml.models.Result;
-import org.onap.ransim.websocket.model.SlicingPmMessage;
-import org.onap.ransim.websocket.server.RansimWebSocketServer;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-import com.google.gson.Gson;
-
-@Service
-public class SlicingPMDataGenerator {
-
- static Logger logger = Logger.getLogger(SlicingPMDataGenerator.class.getName());
-
- @Autowired
- RANSliceConfigService ranSliceConfigService;
-
- double ricId11MaxVariation = 0.8;
- double ricId22MaxVariation = 0.2;
-
- /**
- * Generates closed loop PM data for all DU functions Generates PRBs for DUs in
- * the ratio of 80:20 for the same nssai in different RICs
- *
- * @throws RansimException
- */
- public void generateClosedLoopPmData(long startTime) {
- try {
- String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list";
- List<GNBDUModel> duList = sendGetRequestToransimDb(requestUrl).getBody();
- for (GNBDUModel du : duList) {
- logger.info("Generating PM data for DU : " + du.getgNBDUName() + " Id :" + du.getgNBDUId());
- Map<String, NSSAIConfig> activeNssaiDetails = new HashMap<String, NSSAIConfig>();
- List<NRCellDUModel> duCellList = du.getCellDUList();
- int ricId = du.getNearRTRICId();
- List<PLMNInfoModel> plmnInfoList = new ArrayList<>();
- duCellList.forEach(cell -> plmnInfoList.addAll(cell.getpLMNInfoList()));
- List<NSSAIData> nssaiData = new ArrayList<>();
- plmnInfoList.forEach(plmnInfo -> nssaiData.add(plmnInfo.getsNSSAI()));
- nssaiData.stream().filter(nssai -> nssai.getStatus().equalsIgnoreCase("active"))
- .forEach(x -> activeNssaiDetails.put(x.getsNSSAI(), x.getConfigData()));
- produceMeasurementCollectionFile(du, activeNssaiDetails, duCellList, ricId);
- logger.info("PM data generated for DU : " + du.getgNBDUName() + " Id: " + du.getgNBDUId());
- }
- } catch (RansimException e) {
- logger.debug("ERROR in closed lopp PM data generation : ");
- logger.debug(e);
- } catch (Exception exp) {
- logger.debug(exp);
- }
- }
-
- private void produceMeasurementCollectionFile(GNBDUModel du, Map<String, NSSAIConfig> activeNssaiDetails,
- List<NRCellDUModel> duCellList, int ricId) throws RansimException {
- logger.debug("produceing MeasurementCollectionFile ");
- SlicingPmMessage pmMessage = new SlicingPmMessage();
- pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000);
- pmMessage.setSourceName(du.getgNBDUName());
- LocalDateTime beginTime = LocalDateTime.now();
- String beginTimeString = beginTime.toString();
- MeasCollec measCollec = new MeasCollec(beginTimeString);
- FileSender fileSender = new FileSender(du.getgNBDUName());
- FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender);
- Random r = new Random();
- int jobId = r.nextInt((9999 - 1000) + 1) + 1000;
- Job job = new Job(String.valueOf(jobId));
- ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S");
-
- List<MeasType> measTypeList = setMeasurementTypes(activeNssaiDetails);
- List<MeasValue> measValueList = setMeasurementValues(duCellList, getMaxVariation(ricId), measTypeList);
-
- ManagedElement managedElement = new ManagedElement("r0.1", du.getgNBDUName());
- LocalDateTime grabularityEndTime = LocalDateTime.now();
- String grabularityEndTimeString = grabularityEndTime.toString();
- GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S");
- MeasInfo measInfo = new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList,
- measValueList);
- List<MeasInfo> measInfoList = new ArrayList<MeasInfo>();
- measInfoList.add(measInfo);
- MeasData measData = new MeasData(managedElement, measInfoList);
- List<MeasData> measDataList = new ArrayList<MeasData>();
- measDataList.add(measData);
- LocalDateTime endTime = LocalDateTime.now();
- String endTimeString = endTime.toString();
- pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000);
- MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString);
- FileFooter fileFooter = new FileFooter(measCollecEnd);
- MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter,
- "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec");
-
- try {
- String startDate = beginTimeString.replace(':', '-');
- String endDate = endTimeString.replace(':', '-');
- String fileName = "A" + startDate + "-" + endDate + "-" + String.valueOf(jobId) + "-"
- + du.getgNBDUName() + ".xml";
- pmMessage.setFileName(fileName);
- Gson gson = new Gson();
- String pmData = gson.toJson(measCollecFile);
- pmMessage.setPmData(pmData);
- closedLoopPmData(pmMessage);
- } catch (Exception exp) {
- logger.debug(exp);
- }
-
- }
-
- private List<MeasValue> setMeasurementValues(List<NRCellDUModel> duCellList, double ricIdVariation,
- List<MeasType> measTypeList) {
- logger.debug("setting MeasurementValues");
- List<MeasValue> measValueList = new ArrayList<MeasValue>();
- duCellList.forEach(cell -> {
- AtomicInteger pValue = new AtomicInteger(1);
- List<Result> resultList = new ArrayList<>();
- int prbs = cell.getPrbs();
- measTypeList.forEach(meas -> {
- int prbsUsed = (int) (Math.random() * ricIdVariation * prbs);
- Result result = new Result(pValue.getAndIncrement(), prbsUsed);
- resultList.add(result);
- });
- MeasValue measValue = new MeasValue(cell.getCellLocalId(), resultList, false);
- measValueList.add(measValue);
-
- });
- return measValueList;
- }
-
- private double getMaxVariation(int ricId) throws RansimException {
- switch (ricId) {
- case 11:
- // ricId11MaxVariation =
- // Double.parseDouble(System.getProperty("RIC_11_VARIATION"));
- return ricId11MaxVariation;
- case 22:
- return ricId22MaxVariation;
- default:
- throw new RansimException("Invalid RIC ID : valid Ids : [11,22] ");
- }
- }
-
- private List<MeasType> setMeasurementTypes(Map<String, NSSAIConfig> activeNssaiDetails) {
- logger.debug("setting MeasurementTypes");
- List<MeasType> measTypeList = new ArrayList<MeasType>();
- AtomicInteger pValue = new AtomicInteger(1);
- activeNssaiDetails.forEach((nssai, configData) -> {
- MeasType mesType1 = new MeasType("SM.PrbUsedDl." + nssai, pValue.getAndIncrement());
- MeasType mesType2 = new MeasType("SM.PrbUsedUl." + nssai, pValue.getAndIncrement());
- measTypeList.add(mesType1);
- measTypeList.add(mesType2);
- });
- return measTypeList;
- }
-
- public static <T> ResponseEntity<List<GNBDUModel>> sendGetRequestToransimDb(String requestUrl) {
- HttpHeaders headers = new HttpHeaders();
- logger.info("sending request to ransimdb : " + requestUrl);
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
- try {
- RestTemplate restTemplate = new RestTemplate();
- return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity,
- new ParameterizedTypeReference<List<GNBDUModel>>() {
- });
- } catch (Exception e) {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
- }
- }
-
- public void closedLoopPmData(SlicingPmMessage pmMessage) {
- Gson gson = new Gson();
- String jsonStr = gson.toJson(pmMessage);
- logger.info("ClosedPmData " + jsonStr);
- String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName());
- if (ipPort != null && !ipPort.trim().equals("")) {
- logger.info("Connection estabilished with ip: " + ipPort);
- if (ipPort != null && !ipPort.trim().equals("")) {
- Session clSess = RansimControllerServices.webSocketSessions.get(ipPort);
- if (clSess != null) {
- logger.info("PM Data message sent.");
- RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess);
- } else {
- logger.info("No client session for " + ipPort);
- }
- } else {
- logger.info("No client for this serverId");
- }
- } else {
- logger.info("No client for ");
- }
- }
-}
-
+/*- + * ============LICENSE_START======================================================= + * Ran Simulator Controller + * ================================================================================ + * Copyright (C) 2021 Wipro Limited. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ransim.rest.api.services; + +import com.google.gson.Gson; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.websocket.Session; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.log4j.Logger; +import org.onap.ransim.rest.api.exceptions.RansimException; +import org.onap.ransim.rest.api.models.NSSAIConfig; +import org.onap.ransim.rest.web.mapper.GNBDUModel; +import org.onap.ransim.rest.web.mapper.NRCellDUModel; +import org.onap.ransim.rest.web.mapper.NSSAIData; +import org.onap.ransim.rest.web.mapper.PLMNInfoModel; +import org.onap.ransim.rest.xml.models.FileFooter; +import org.onap.ransim.rest.xml.models.FileHeader; +import org.onap.ransim.rest.xml.models.FileSender; +import org.onap.ransim.rest.xml.models.GranularityPeriod; +import org.onap.ransim.rest.xml.models.Job; +import org.onap.ransim.rest.xml.models.ManagedElement; +import org.onap.ransim.rest.xml.models.MeasCollec; +import org.onap.ransim.rest.xml.models.MeasCollecEnd; +import org.onap.ransim.rest.xml.models.MeasCollecFile; +import org.onap.ransim.rest.xml.models.MeasData; +import org.onap.ransim.rest.xml.models.MeasInfo; +import org.onap.ransim.rest.xml.models.MeasType; +import org.onap.ransim.rest.xml.models.MeasValue; +import org.onap.ransim.rest.xml.models.ReportingPeriod; +import org.onap.ransim.rest.xml.models.Result; +import org.onap.ransim.websocket.model.SlicingPmMessage; +import org.onap.ransim.websocket.server.RansimWebSocketServer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class SlicingPMDataGenerator { + + static Logger logger = Logger.getLogger(SlicingPMDataGenerator.class.getName()); + + @Autowired + RANSliceConfigService ranSliceConfigService; + + double ricId11MaxVariation = 0.8; + double ricId22MaxVariation = 0.2; + + /** + * Generates closed loop PM data for all DU functions Generates PRBs for DUs in + * the ratio of 80:20 for the same nssai in different RICs + * + * @throws RansimException + */ + public void generateClosedLoopPmData(long startTime) { + try { + String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list"; + List<GNBDUModel> duList = sendGetRequestToransimDb(requestUrl).getBody(); + for (GNBDUModel du : duList) { + logger.info("Generating PM data for DU : " + du.getgNBDUName() + " Id :" + du.getgNBDUId()); + Map<String, NSSAIConfig> activeNssaiDetails = new HashMap<String, NSSAIConfig>(); + List<NRCellDUModel> duCellList = du.getCellDUList(); + int ricId = du.getNearRTRICId(); + List<PLMNInfoModel> plmnInfoList = new ArrayList<>(); + duCellList.forEach(cell -> plmnInfoList.addAll(cell.getpLMNInfoList())); + List<NSSAIData> nssaiData = new ArrayList<>(); + plmnInfoList.forEach(plmnInfo -> nssaiData.add(plmnInfo.getsNSSAI())); + nssaiData.stream().filter(nssai -> nssai.getStatus().equalsIgnoreCase("active")) + .forEach(x -> activeNssaiDetails.put(x.getsNSSAI(), x.getConfigData())); + produceMeasurementCollectionFile(du, activeNssaiDetails, duCellList, ricId); + logger.info("PM data generated for DU : " + du.getgNBDUName() + " Id: " + du.getgNBDUId()); + } + } catch (RansimException e) { + logger.debug("ERROR in closed lopp PM data generation : "); + logger.debug(e); + } catch (Exception exp) { + logger.debug(exp); + } + } + + private void produceMeasurementCollectionFile(GNBDUModel du, Map<String, NSSAIConfig> activeNssaiDetails, + List<NRCellDUModel> duCellList, int ricId) throws RansimException { + logger.debug("produceing MeasurementCollectionFile "); + SlicingPmMessage pmMessage = new SlicingPmMessage(); + pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + pmMessage.setSourceName(du.getgNBDUName()); + LocalDateTime beginTime = LocalDateTime.now(); + String beginTimeString = beginTime.toString(); + MeasCollec measCollec = new MeasCollec(beginTimeString); + FileSender fileSender = new FileSender(du.getgNBDUName()); + FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender); + Random r = new Random(); + int jobId = r.nextInt((9999 - 1000) + 1) + 1000; + Job job = new Job(String.valueOf(jobId)); + ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S"); + + List<MeasType> measTypeList = setMeasurementTypes(activeNssaiDetails); + List<MeasValue> measValueList = setMeasurementValues(duCellList, getMaxVariation(ricId), measTypeList); + + ManagedElement managedElement = new ManagedElement("r0.1", du.getgNBDUName()); + LocalDateTime grabularityEndTime = LocalDateTime.now(); + String grabularityEndTimeString = grabularityEndTime.toString(); + GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S"); + MeasInfo measInfo = + new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList, measValueList); + List<MeasInfo> measInfoList = new ArrayList<MeasInfo>(); + measInfoList.add(measInfo); + MeasData measData = new MeasData(managedElement, measInfoList); + List<MeasData> measDataList = new ArrayList<MeasData>(); + measDataList.add(measData); + LocalDateTime endTime = LocalDateTime.now(); + String endTimeString = endTime.toString(); + pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString); + FileFooter fileFooter = new FileFooter(measCollecEnd); + MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter, + "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"); + + try { + String startDate = beginTimeString.replace(':', '-'); + String endDate = endTimeString.replace(':', '-'); + String fileName = + "A" + startDate + "-" + endDate + "-" + String.valueOf(jobId) + "-" + du.getgNBDUName() + ".xml"; + pmMessage.setFileName(fileName); + Gson gson = new Gson(); + String pmData = gson.toJson(measCollecFile); + pmMessage.setPmData(pmData); + closedLoopPmData(pmMessage); + } catch (Exception exp) { + logger.debug(exp); + } + + } + + private List<MeasValue> setMeasurementValues(List<NRCellDUModel> duCellList, double ricIdVariation, + List<MeasType> measTypeList) { + logger.debug("setting MeasurementValues"); + List<MeasValue> measValueList = new ArrayList<MeasValue>(); + duCellList.forEach(cell -> { + AtomicInteger pValue = new AtomicInteger(1); + List<Result> resultList = new ArrayList<>(); + int prbs = cell.getPrbs(); + measTypeList.forEach(meas -> { + int prbsUsed = (int) (Math.random() * ricIdVariation * prbs); + Result result = new Result(pValue.getAndIncrement(), prbsUsed); + resultList.add(result); + }); + MeasValue measValue = new MeasValue(cell.getCellLocalId(), resultList, false); + measValueList.add(measValue); + + }); + return measValueList; + } + + private double getMaxVariation(int ricId) throws RansimException { + switch (ricId) { + case 11: + // ricId11MaxVariation = + // Double.parseDouble(System.getProperty("RIC_11_VARIATION")); + return ricId11MaxVariation; + case 22: + return ricId22MaxVariation; + default: + throw new RansimException("Invalid RIC ID : valid Ids : [11,22] "); + } + } + + private List<MeasType> setMeasurementTypes(Map<String, NSSAIConfig> activeNssaiDetails) { + logger.debug("setting MeasurementTypes"); + List<MeasType> measTypeList = new ArrayList<MeasType>(); + AtomicInteger pValue = new AtomicInteger(1); + activeNssaiDetails.forEach((nssai, configData) -> { + MeasType mesType1 = new MeasType("SM.PrbUsedDl." + nssai, pValue.getAndIncrement()); + MeasType mesType2 = new MeasType("SM.PrbUsedUl." + nssai, pValue.getAndIncrement()); + measTypeList.add(mesType1); + measTypeList.add(mesType2); + }); + return measTypeList; + } + + public static <T> ResponseEntity<List<GNBDUModel>> sendGetRequestToransimDb(String requestUrl) { + HttpHeaders headers = new HttpHeaders(); + logger.info("sending request to ransimdb : " + requestUrl); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity<Void> requestEntity = new HttpEntity<>(headers); + try { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, + new ParameterizedTypeReference<List<GNBDUModel>>() {}); + } catch (Exception e) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + public void closedLoopPmData(SlicingPmMessage pmMessage) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(pmMessage); + logger.info("ClosedPmData " + jsonStr); + String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName()); + if (ipPort != null && !ipPort.trim().equals("")) { + logger.info("Connection estabilished with ip: " + ipPort); + if (ipPort != null && !ipPort.trim().equals("")) { + Session clSess = RansimControllerServices.webSocketSessions.get(ipPort); + if (clSess != null) { + logger.info("PM Data message sent."); + RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess); + } else { + logger.info("No client session for " + ipPort); + } + } else { + logger.info("No client for this serverId"); + } + } else { + logger.info("No client for "); + } + } +} |