aboutsummaryrefslogtreecommitdiffstats
path: root/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller
diff options
context:
space:
mode:
authorNiranjana <niranjana.y60@wipro.com>2021-03-22 11:39:08 +0000
committerNiranjana <niranjana.y60@wipro.com>2021-03-24 11:31:03 +0000
commit9764b6bb545a8edd4979c481627c38c1892f207e (patch)
treec6b6133144fa7812710f76ced95bbcb243bb9446 /ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller
parent43e39ceab8e35a0a54ae72252b46491f362a0749 (diff)
Update schema and format java files
Issue-ID: INT-1892 Signed-off-by: Niranjana <niranjana.y60@wipro.com> Change-Id: Ib35c35cf7ac7a858311618e741c9327d7630aed6
Diffstat (limited to 'ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller')
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/FileController.java66
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RANSliceConfigController.java1119
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java1345
3 files changed, 1289 insertions, 1241 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);
+ }
- }
+ }
}