aboutsummaryrefslogtreecommitdiffstats
path: root/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services
diff options
context:
space:
mode:
Diffstat (limited to 'ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services')
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java1164
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java2732
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java409
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java520
4 files changed, 2419 insertions, 2406 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java
index d7e4b5d..7e2172b 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RANSliceConfigService.java
@@ -32,9 +32,6 @@ import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
import org.onap.ransim.rest.api.models.GNBCUCPFunction;
import org.onap.ransim.rest.api.models.GNBCUUPFunction;
import org.onap.ransim.rest.api.models.GNBDUFunction;
@@ -63,574 +60,601 @@ import org.onap.ransim.rest.web.mapper.NRCellDUModel;
import org.onap.ransim.rest.web.mapper.NearRTRICModel;
import org.onap.ransim.rest.web.mapper.RANSliceInfoModel;
import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
@Service
public class RANSliceConfigService {
- private static Logger logger = Logger.getLogger(RANSliceConfigService.class.getName());
- @Autowired
- private NRCellCURepository nRCellCURepository;
-
- @Autowired
- private GNBCUCPRepository gNBCUCPRepository;
-
- @Autowired
- private GNBCUUPRepository gNBCUUPRepository;
-
- @Autowired
- private GNBDURepository gNBDURepository;
-
- @Autowired
- private NearRTRICRepository nearRTRICRepository;
-
- @Autowired
- private RRMPolicyRepository rRMPolicyRepository;
-
- @Autowired
- private RANInventoryRepository ranInventoryRepo;
-
- @Autowired
- private TACellRepository tACellRepository;
-
- private ModelMapper modelMapper = new ModelMapper();
-
- /**
- * To store/update the NRCEllCU details
- *
- * @param nRCellCUModel
- * @return NRCellCUModel
- */
- public NRCellCUModel saveNRcellCU(NRCellCUModel nRCellCUModel) {
- logger.debug("Request received to save NRcellCU: id::"+ nRCellCUModel.getCellLocalId());
- NRCellCU cellCUEntity = new NRCellCU();
- modelMapper.map(nRCellCUModel, cellCUEntity);
- if(!cellCUEntity.getpLMNInfoList().isEmpty()) {
- for(PLMNInfo plmn:cellCUEntity.getpLMNInfoList()) {
- //plmn.setnRCellCU(cellCUEntity);
- }
- }
- NRCellCU cellCUEntityResponse = nRCellCURepository.save(cellCUEntity);
- modelMapper.map(cellCUEntityResponse,nRCellCUModel);
- return nRCellCUModel;
- }
-
- /**
- * To fetch the NRCellCU details
- *
- * @param cellLocalId
- * @return NRCellCUModel
- */
- public NRCellCUModel fetchNRCellCUDetails(Integer cellLocalId) {
- logger.debug("Request received to fetchNRCellCUDetails: id::"+ cellLocalId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- NRCellCU cellCUEntity = nRCellCURepository.findById(cellLocalId).isPresent()?nRCellCURepository.findById(cellLocalId).get():null;
- NRCellCUModel nRCellCUModel = new NRCellCUModel();
- modelMapper.map(cellCUEntity,nRCellCUModel);
- return nRCellCUModel;
- }
-
- /**
- * To store the slice / config details of GNBCUCPFunction
- * @param gNBCUCPModel
- * @return
- */
- public GNBCUCPModel saveGNBCUCP(GNBCUCPModel gNBCUCPModel) {
- logger.debug("Request received to save GNBCUCPModel: id::"+ gNBCUCPModel.getgNBCUName());
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBCUCPFunction gNBCUCPFunction=new GNBCUCPFunction(); NearRTRIC nearRTRICRef = new NearRTRIC();
- try {
- modelMapper.map(gNBCUCPModel, gNBCUCPFunction);
- if(gNBCUCPModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).isPresent()) {
- gNBCUCPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).get());
- }
- if(gNBCUCPFunction!=null && !gNBCUCPFunction.getCellCUList().isEmpty()) {
- gNBCUCPFunction.getCellCUList().forEach(cellCU->{
- cellCU.setgNBCUCPFunction(gNBCUCPFunction);
- });
- }
- GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.save(gNBCUCPFunction);
- modelMapper.map(gNBCUCPEntity,gNBCUCPModel);
- }catch(Exception e) {
- logger.debug("Error occured during saveGNBCUCP"+e.getMessage());
- return null;
- }
- return gNBCUCPModel;
- }
-
- /**
- * To fetch the gNBCUCP details
- *
- * @param cucpName
- * @return GNBCUCPModel
- */
- public GNBCUCPModel fetchGNBCUCPData(String cucpName) {
- logger.debug("Request received to fetch GNBCUCPFunction: name::"+ cucpName);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.findById(cucpName).isPresent()?gNBCUCPRepository.findById(cucpName).get():null;
- GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
- modelMapper.map(gNBCUCPEntity,gNBCUCPModel);
- return gNBCUCPModel;
- }
-
- /**
- * To store the slice / config details of GNBCUCPFunction
- * @param gNBCUCPModel
- * @return
- */
- public GNBCUUPModel saveGNBCUUP(GNBCUUPModel gNBCUUPModel) {
- logger.debug("Request received to save GNBCUUPModel: id::"+ gNBCUUPModel.getgNBCUUPId());
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBCUUPFunction gNBCUUPFunction=new GNBCUUPFunction();
- modelMapper.map(gNBCUUPModel, gNBCUUPFunction);
- if(gNBCUUPModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).isPresent()) {
- gNBCUUPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).get());
- }
- if(gNBCUUPFunction!=null && !gNBCUUPFunction.getpLMNInfoList().isEmpty()) {
- gNBCUUPFunction.getpLMNInfoList().forEach(plmn->{
- //plmn.setgNBCUUPFunction(gNBCUUPFunction);
- });
- }
- GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.save(gNBCUUPFunction);
- modelMapper.map(gNBCUUPEntity,gNBCUUPModel);
- return gNBCUUPModel;
- }
-
- /**
- * To fetch the gNBCUUP details
- *
- * @param cucpName
- * @return GNBCUUPModel
- */
- public GNBCUUPModel fetchGNBCUUPData(Integer gNBCUUPId) {
- logger.debug("Request received to fetch GNBCUUPFunction: id::"+ gNBCUUPId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.findById(gNBCUUPId).isPresent()?gNBCUUPRepository.findById(gNBCUUPId).get():null;
- GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
- modelMapper.map(gNBCUUPEntity,gNBCUUPModel);
- return gNBCUUPModel;
- }
-
- /**
- * To store the slice / config details of GNBDUFunction
- * @param GNBDUModel
- * @return
- */
- public GNBDUModel saveGNBDU(GNBDUModel gNBDUModel) {
- logger.debug("Request received to save GNBDUModel: id::"+ gNBDUModel.getgNBDUId());
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBDUFunction gNBDUFunction=new GNBDUFunction();NearRTRIC nearRTRICRef = new NearRTRIC();
- modelMapper.map(gNBDUModel, gNBDUFunction);
- if(gNBDUModel.getNearRTRICId()!=null && nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).isPresent()) {
- nearRTRICRef = nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).get();
- gNBDUFunction.setNearRTRIC(nearRTRICRef);
- }
- NearRTRIC nearRTRICRefNew = nearRTRICRef;
- nearRTRICRefNew.setNearRTRICId(gNBDUModel.getNearRTRICId());
- if(gNBDUFunction!=null && !gNBDUFunction.getCellDUList().isEmpty()) {
- gNBDUFunction.getCellDUList().forEach(cellDU->{
- cellDU.setgNBDUFunction(gNBDUFunction);
- });
- }
- GNBDUFunction gNBDUEntity = gNBDURepository.save(gNBDUFunction);
- modelMapper.map(gNBDUEntity,gNBDUModel);
- return gNBDUModel;
- }
-
- /**
- * To fetch the gNBDU details
- *
- * @param gNBDUId
- * @return GNBDUModel
- */
- public GNBDUModel fetchGNBDUData(Integer gNBDUId) {
- logger.debug("Request received to fetch GNBDUFunction: id::"+ gNBDUId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- GNBDUFunction gNBDUEntity = gNBDURepository.findById(gNBDUId).isPresent()?gNBDURepository.findById(gNBDUId).get():null;
- GNBDUModel gNBDUModel = new GNBDUModel();
- modelMapper.map(gNBDUEntity,gNBDUModel);
- return gNBDUModel;
- }
-
- /**
- * Stored NearRTRIC
- *
- * @param nearRTRIC
- * @return
- */
- public NearRTRICModel saveNearRTRIC(NearRTRICModel nearRTRIC) {
- logger.debug("Request received to store NearRTRIC: id::"+ nearRTRIC.getNearRTRICId());
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- NearRTRIC nearRTRICEntity = new NearRTRIC();
- modelMapper.map(nearRTRIC, nearRTRICEntity);
- NearRTRIC nearRTRICEntityEResponse = nearRTRICRepository.save(nearRTRICEntity);
- modelMapper.map(nearRTRICEntityEResponse,nearRTRIC);
- return nearRTRIC;
- }
-
- /**
- * To fetch the nearRTRIC details
- *
- * @param nearRTRICId
- * @return NearRTRICModel
- */
- public NearRTRICModel fetchNearRTRICData(Integer nearRTRICId) {
- logger.debug("Request received to fetch GNBDUFunction: id::"+ nearRTRICId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- NearRTRIC nearRTRICEntity = nearRTRICRepository.findById(nearRTRICId).isPresent()?nearRTRICRepository.findById(nearRTRICId).get():null;
- NearRTRICModel nearRTRICModel = new NearRTRICModel();
- modelMapper.map(nearRTRICEntity,nearRTRICModel);
- return nearRTRICModel;
- }
-
- /**
- * To retrieve the RRMPolicy of a network function
- *
- * @param resourceType
- * @param resourceID
- * @return
- */
- public RRMPolicyRatioModel fetchRRMPolicyOfNE(String resourceType, String resourceID) {
- logger.debug("Request received to fetch RRMPolicy:"+ resourceType+"--"+resourceID);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- RRMPolicyRatioModel rrmPolicyResponse = new RRMPolicyRatioModel();
- RRMPolicyRatio rrmPolicyEntity = rRMPolicyRepository.findByResourceTypeAndId(resourceType, resourceID);
- modelMapper.map(rrmPolicyEntity, rrmPolicyResponse);
- return rrmPolicyResponse;
- }
-
- /**
- * To update RRM policy of NF
- *
- * @param rrmPolicy
- * @return
- */
- public RRMPolicyRatioModel updateRRMPolicy(RRMPolicyRatioModel rrmPolicy) {
- logger.debug("Request received to update RRMPolicy:"+ rrmPolicy.getRrmPolicyID());
- RRMPolicyRatio rrmPolicyEntity = new RRMPolicyRatio();
- modelMapper.map(rrmPolicy, rrmPolicyEntity);
- rrmPolicyEntity = rRMPolicyRepository.save(rrmPolicyEntity);
- modelMapper.map(rrmPolicyEntity, rrmPolicy);
- return rrmPolicy;
- }
-
- /**
- * @param trackingArea
- * @return List<NearRTRICModel>
- */
- public List<NearRTRICModel> findRICsInTA(String trackingArea) {
- logger.debug("Request received to find the NearRTRICs in Tracking Area::"+ trackingArea);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<NearRTRIC> nearRTRICsList = nearRTRICRepository.getListOfRICsInTrackingArea(trackingArea);
- List<NearRTRICModel> ricModelList = nearRTRICsList.stream()
- .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList());
- return ricModelList;
- }
-
- /**
- * @param cellsList
- * @return
- */
- public List<NearRTRICModel> findNearRTRICofCells(List<Integer> cellsList){
- List<NearRTRIC> ricEntitiesList = new ArrayList<>();
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<String> cucpNames = gNBCUCPRepository.findCUCPByCellIds(cellsList);
- cucpNames.forEach(cucpName -> {
- List<NearRTRIC> ricEntities = new ArrayList<>();
- ricEntities = nearRTRICRepository.findNearRTRICByCUCPName(cucpName);
- ricEntitiesList.addAll(ricEntities);
- });
- List<NearRTRICModel> ricModelList = ricEntitiesList.stream()
- .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList());
- return ricModelList;
- }
-
-
- /**
- * To update the RAN Slice details
- *
- * @param rANSliceInfoModel
- * @return RANSliceInfoModel
- */
- public RANSliceInfoModel updateRANInventory(RANSliceInfoModel rANSliceInfoModel) {
- logger.debug("Request received to update inventory for id::"+ rANSliceInfoModel.getRanNFNSSIId());
- RANSliceInfo rANSliceInfoEntity = new RANSliceInfo();
- modelMapper.map(rANSliceInfoModel, rANSliceInfoEntity);
- if(ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).isPresent()) {
- RANSliceInfo ranInfo = ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).get();
- List<String> ranNSSIList = ranInfo.getRanNSSIList();
- ranNSSIList.addAll(rANSliceInfoEntity.getRanNSSIList());
- rANSliceInfoEntity.setRanNSSIList(ranNSSIList);
-
- List<String> nSSAIList = ranInfo.getnSSAIList();
- nSSAIList.addAll(rANSliceInfoEntity.getnSSAIList());
- rANSliceInfoEntity.setnSSAIList(nSSAIList);
-
- List<SliceProfile> sliceProfilesList = ranInfo.getSliceProfilesList();
- sliceProfilesList.addAll(rANSliceInfoEntity.getSliceProfilesList());
- rANSliceInfoEntity.setSliceProfilesList(sliceProfilesList);
- }
- else {
- if(!rANSliceInfoEntity.getSliceProfilesList().isEmpty()) {
- for(SliceProfile profile:rANSliceInfoEntity.getSliceProfilesList()) {
- profile.setrANSliceInventory(rANSliceInfoEntity);
- }
- }
- }
- rANSliceInfoEntity = ranInventoryRepo.save(rANSliceInfoEntity);
- modelMapper.map(rANSliceInfoEntity, rANSliceInfoModel);
- return rANSliceInfoModel;
- }
-
- /**
- * @param ranNFNSSIId
- * @return RANSliceInfoModel
- */
- public RANSliceInfoModel fetchRANSlice(String ranNFNSSIId) {
- logger.debug("Request received to read inventory details for id::"+ ranNFNSSIId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- RANSliceInfo ranSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()?ranInventoryRepo.findById(ranNFNSSIId).get():null;
- RANSliceInfoModel rANSliceInfoModel = new RANSliceInfoModel();
- modelMapper.map(ranSliceInfo, rANSliceInfoModel);
- return rANSliceInfoModel;
- }
-
- /**
- * @param trackingArea
- * @return List<String>
- */
- public List<String> fetchCellsofTA(String trackingArea) {
- logger.debug("Request recieved to fetch the cell details of TA:"+ trackingArea);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- String cells = tACellRepository.findById(trackingArea).isPresent()?tACellRepository.findById(trackingArea).get().getCellsList():null;
- return cells!=null? Arrays.asList(cells.split(",")):null;
-
- }
-
- public Iterable<TACells> fetchAllTA()
- {
- logger.info("Request recieved to fetch all TA:");
- return tACellRepository.findAll();
- }
-
- /**
- * @param nearRTRICId
- * @return List<NRCellCUModel>
- */
- public List<NRCellCUModel> fetchCUCellsofRIC(Integer nearRTRICId) {
- logger.debug("Request recieved to fetch the cell (CU) details of nearRTRICId:"+ nearRTRICId);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<NRCellCU> cellCUEntities = new ArrayList<NRCellCU>();
- NearRTRIC nearRTRIC = nearRTRICRepository.findById(nearRTRICId).isPresent()?nearRTRICRepository.findById(nearRTRICId).get():null;
- if(nearRTRIC!=null) {
- List<GNBCUCPFunction> cucpFunctions = nearRTRIC.getgNBCUCPList();
- cucpFunctions.forEach(cucpFunction->{
- List<NRCellCU> cellCUList = new ArrayList<NRCellCU>();
- cellCUList.addAll(cucpFunction.getCellCUList());
- cellCUEntities.addAll(cellCUList);
- });
- List<NRCellCUModel> cuCellModels = cellCUEntities.stream()
- .map(cellCUEntity -> modelMapper.map(cellCUEntity, NRCellCUModel.class)).collect(Collectors.toList());
- return cuCellModels;
- }
- return new ArrayList<NRCellCUModel>();
- }
-
- /**
- * @param trackingArea
- * @return List<NRCellDUModel>
- */
- public Map<Integer, List<NRCellDUModel>> fetchDUCellsofRIC(String sNSSAI) {
- logger.debug("Request recieved to fetch the cell (DU) details of sNSSAI:"+ sNSSAI);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- Set<NRCellDU> cellDUEntities = new HashSet<NRCellDU>();Set<NRCellDU> cellDUs = new HashSet<NRCellDU>();
- List<NearRTRICModel> ricModels = findRICsByNSSAI(sNSSAI);
- Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>();
- List<NearRTRIC> ricEntities = ricModels.stream()
- .map(ric -> modelMapper.map(ric, NearRTRIC.class)).collect(Collectors.toList());
- ricEntities.forEach(ricEntity -> {
- List<GNBDUFunction> duFunctions = ricEntity.getgNBDUList();
- duFunctions.forEach(duFunction -> {
- List<NRCellDU> cellDUList =duFunction.getCellDUList();
- cellDUList.forEach(cellDU->{
- List<PLMNInfo> plmnList = cellDU.getpLMNInfoList();
- plmnList.forEach(plmn->{
- if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())){
- cellDUs.add(cellDU);
- }
- });
- });
- //cellDUList.addAll(duFunction.getCellDUList());
- cellDUEntities.addAll(cellDUs);
- });
- List<NRCellDUModel> duCellModels = cellDUEntities.stream()
- .map(cellDUEntity -> modelMapper.map(cellDUEntity, NRCellDUModel.class)).collect(Collectors.toList());
- cellsMap.put(ricEntity.getNearRTRICId(), duCellModels);
- });
-
- return cellsMap;
- }
-
- /**
- * @param ranNFNSSIID
- * @return List<NearRTRICModel>
- */
- public List<NearRTRICModel> findNearRTRICByNSSI(String ranNFNSSIID) {
- logger.debug("Request recieved to fetch nearRTRIC of NSSI:"+ ranNFNSSIID);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSI(ranNFNSSIID);
- List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream()
- .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class)).collect(Collectors.toList());
- return nearRTRICModels;
- }
-
- /**
- * @param sNSSAI
- * @return List<NearRTRICModel>
- */
- public List<NearRTRICModel> findRICsByNSSAI(String sNSSAI){
- logger.debug("Request recieved to fetch nearRTRIC of NSSAI:"+ sNSSAI);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- Set<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSAI(sNSSAI);
- List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream()
- .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class))
- .collect(Collectors.toList());
- return nearRTRICModels;
- }
-
- /**
- * @param sNSSAI
- * @return config Details
- */
- public Map<String,Integer> findSliceProfileconfig(String sNSSAI){
- logger.debug("Request recieved to fetch Config requested for a slice:"+ sNSSAI);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- Map<String,Integer> configDetails = new HashMap<String, Integer>();
- String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI);
- RANSliceInfo rANSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()? ranInventoryRepo.findById(ranNFNSSIId).get():null;
- if(rANSliceInfo.getSliceProfilesList().size()>0) {
- rANSliceInfo.getSliceProfilesList().forEach(sliceProfile->{
- if(sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())){
- //configDetails.put("maxNoOfConns",sliceProfile.getMaxNumberofConns());
- configDetails.put("dLThptPerSlice",sliceProfile.getdLThptPerSlice());
- configDetails.put("uLThptPerSlice",sliceProfile.getuLThptPerSlice());
- }
- });
- }
- return configDetails;
- }
-
- /**
- * @param sNSSAI
- * @return RIC Config for a slice
- */
- public Map<Integer, NSSAIConfig> findSliceConfig(String sNSSAI){
- logger.debug("Request recieved to fetch Slice config Details at RICs:"+ sNSSAI);
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI);
- Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>();
- nearRTRICModels.forEach(nearRTRIC->{
- nearRTRIC.getpLMNInfoList().forEach(plmn->{
- if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) {
- configMap.put(nearRTRIC.getNearRTRICId(),plmn.getsNSSAI().getConfigData());
- }
- });
- });
- return configMap;
- }
-
- /**
- * @param sNSSAI
- * @return List<GNBDUModel>
- */
- public List<GNBDUModel> findDUsofSNssai(String sNSSAI){
- logger.debug("Request recieved to fetch all DUs of NSSAI");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findDUsByNSSAI(sNSSAI);
- List<GNBDUModel> duModels = duList.stream()
- .map(duEntity -> modelMapper.map(duEntity, GNBDUModel.class)).collect(Collectors.toList());
- return duModels;
- }
-
- /**
- * @param sNSSAI
- * @return List<GNBCUCPModel>
- */
- public List<GNBCUCPModel> findCUsofSNssai(String sNSSAI){
- logger.debug("Request recieved to fetch all CUs of NSSAI");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<GNBCUCPFunction> cuList = (List<GNBCUCPFunction>) gNBCUCPRepository.findCUCPsByNSSAI(sNSSAI);
- List<GNBCUCPModel> cuModels = cuList.stream()
- .map(cuEntity -> modelMapper.map(cuEntity, GNBCUCPModel.class)).collect(Collectors.toList());
- return cuModels;
- }
-
- /**
- * @param sNSSAI
- * @return Map<String, String>
- */
- public Map<String, String> getSubscriberDetails(String sNSSAI){
- logger.debug("Request recieved to fetch SubscriberDetails");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- Map<String, String> details = new HashMap<String, String>();
- String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI);
- details.put("ranNFNSSIId", ranNFNSSIId);
- details.put("sNSSAI", sNSSAI);
- RANSliceInfo rANSliceInfo = ranInventoryRepo.findById(ranNFNSSIId).isPresent()? ranInventoryRepo.findById(ranNFNSSIId).get():null;
- if(rANSliceInfo.getSliceProfilesList().size()>0) {
- rANSliceInfo.getSliceProfilesList().forEach(sliceProfile->{
- if(sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())){
- details.put("sliceProfileId",sliceProfile.getSliceProfileId());
- }
- });
- }
- List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI);
- nearRTRICModels.forEach(nearRTRIC->{
- nearRTRIC.getpLMNInfoList().forEach(plmn->{
- if(sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) {
- details.put("subscriptionServiceType",plmn.getsNSSAI().getSubscriptionServiceType());
- details.put("globalSubscriberId",plmn.getsNSSAI().getGlobalSubscriberId());
- }
- });
- });
-
- return details;
- }
-
- // Data required for PM data Simulation
- /**
- * @return List<GNBCUCPModel>
- */
- public List<GNBCUCPModel> findAllCUCPFunctions(){
- logger.debug("Request recieved to fetch all CUCPs");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<GNBCUCPFunction> cucpsList = (List<GNBCUCPFunction>) gNBCUCPRepository.findAll();
- List<GNBCUCPModel> cucpModels = cucpsList.stream()
- .map(cucpEntity -> modelMapper.map(cucpEntity, GNBCUCPModel.class)).collect(Collectors.toList());
- return cucpModels;
- }
-
- /**
- * @return List<GNBDUModel>
- */
- public List<GNBDUModel> findAllDUFunctions(){
- logger.debug("Request recieved to fetch all DUs");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findAll();
- List<GNBDUModel> duModels = duList.stream().map(duEntity -> {
- GNBDUModel gnbDuModel = modelMapper.map(duEntity, GNBDUModel.class);
- gnbDuModel.setNearRTRICId(duEntity.getNearRTRIC().getNearRTRICId());
- return gnbDuModel;
- }).collect(Collectors.toList());
- return duModels;
- }
-
- public List<NearRTRICModel> findAllNearRTRIC()
- {
- logger.debug("Request received to fetch all NearRTRICModel");
- modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
- List<NearRTRIC> rtricList = (List<NearRTRIC>) nearRTRICRepository.findAll();
- List<NearRTRICModel> rtricmodels = rtricList.stream()
- .map(rtricEntity -> modelMapper.map(rtricEntity, NearRTRICModel.class)).collect(Collectors.toList());
- return rtricmodels;
- }
-
+ private static Logger logger = Logger.getLogger(RANSliceConfigService.class.getName());
+ @Autowired
+ private NRCellCURepository nRCellCURepository;
+
+ @Autowired
+ private GNBCUCPRepository gNBCUCPRepository;
+
+ @Autowired
+ private GNBCUUPRepository gNBCUUPRepository;
+
+ @Autowired
+ private GNBDURepository gNBDURepository;
+
+ @Autowired
+ private NearRTRICRepository nearRTRICRepository;
+
+ @Autowired
+ private RRMPolicyRepository rRMPolicyRepository;
+
+ @Autowired
+ private RANInventoryRepository ranInventoryRepo;
+
+ @Autowired
+ private TACellRepository tACellRepository;
+
+ private ModelMapper modelMapper = new ModelMapper();
+
+ /**
+ * To store/update the NRCEllCU details
+ *
+ * @param nRCellCUModel
+ * @return NRCellCUModel
+ */
+ public NRCellCUModel saveNRcellCU(NRCellCUModel nRCellCUModel) {
+ logger.debug("Request received to save NRcellCU: id::" + nRCellCUModel.getCellLocalId());
+ NRCellCU cellCUEntity = new NRCellCU();
+ modelMapper.map(nRCellCUModel, cellCUEntity);
+ if (!cellCUEntity.getpLMNInfoList().isEmpty()) {
+ for (PLMNInfo plmn : cellCUEntity.getpLMNInfoList()) {
+ // plmn.setnRCellCU(cellCUEntity);
+ }
+ }
+ NRCellCU cellCUEntityResponse = nRCellCURepository.save(cellCUEntity);
+ modelMapper.map(cellCUEntityResponse, nRCellCUModel);
+ return nRCellCUModel;
+ }
+
+ /**
+ * To fetch the NRCellCU details
+ *
+ * @param cellLocalId
+ * @return NRCellCUModel
+ */
+ public NRCellCUModel fetchNRCellCUDetails(Integer cellLocalId) {
+ logger.debug("Request received to fetchNRCellCUDetails: id::" + cellLocalId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ NRCellCU cellCUEntity =
+ nRCellCURepository.findById(cellLocalId).isPresent() ? nRCellCURepository.findById(cellLocalId).get()
+ : null;
+ NRCellCUModel nRCellCUModel = new NRCellCUModel();
+ modelMapper.map(cellCUEntity, nRCellCUModel);
+ return nRCellCUModel;
+ }
+
+ /**
+ * To store the slice / config details of GNBCUCPFunction
+ *
+ * @param gNBCUCPModel
+ * @return
+ */
+ public GNBCUCPModel saveGNBCUCP(GNBCUCPModel gNBCUCPModel) {
+ logger.debug("Request received to save GNBCUCPModel: id::" + gNBCUCPModel.getgNBCUName());
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBCUCPFunction gNBCUCPFunction = new GNBCUCPFunction();
+ NearRTRIC nearRTRICRef = new NearRTRIC();
+ try {
+ modelMapper.map(gNBCUCPModel, gNBCUCPFunction);
+ if (gNBCUCPModel.getNearRTRICId() != null
+ && nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).isPresent()) {
+ gNBCUCPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUCPModel.getNearRTRICId()).get());
+ }
+ if (gNBCUCPFunction != null && !gNBCUCPFunction.getCellCUList().isEmpty()) {
+ gNBCUCPFunction.getCellCUList().forEach(cellCU -> {
+ cellCU.setgNBCUCPFunction(gNBCUCPFunction);
+ });
+ }
+ GNBCUCPFunction gNBCUCPEntity = gNBCUCPRepository.save(gNBCUCPFunction);
+ modelMapper.map(gNBCUCPEntity, gNBCUCPModel);
+ } catch (Exception e) {
+ logger.debug("Error occured during saveGNBCUCP" + e.getMessage());
+ return null;
+ }
+ return gNBCUCPModel;
+ }
+
+ /**
+ * To fetch the gNBCUCP details
+ *
+ * @param cucpName
+ * @return GNBCUCPModel
+ */
+ public GNBCUCPModel fetchGNBCUCPData(String cucpName) {
+ logger.debug("Request received to fetch GNBCUCPFunction: name::" + cucpName);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBCUCPFunction gNBCUCPEntity =
+ gNBCUCPRepository.findById(cucpName).isPresent() ? gNBCUCPRepository.findById(cucpName).get() : null;
+ GNBCUCPModel gNBCUCPModel = new GNBCUCPModel();
+ modelMapper.map(gNBCUCPEntity, gNBCUCPModel);
+ return gNBCUCPModel;
+ }
+
+ /**
+ * To store the slice / config details of GNBCUCPFunction
+ *
+ * @param gNBCUCPModel
+ * @return
+ */
+ public GNBCUUPModel saveGNBCUUP(GNBCUUPModel gNBCUUPModel) {
+ logger.debug("Request received to save GNBCUUPModel: id::" + gNBCUUPModel.getgNBCUUPId());
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction();
+ modelMapper.map(gNBCUUPModel, gNBCUUPFunction);
+ if (gNBCUUPModel.getNearRTRICId() != null
+ && nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).isPresent()) {
+ gNBCUUPFunction.setNearRTRIC(nearRTRICRepository.findById(gNBCUUPModel.getNearRTRICId()).get());
+ }
+ if (gNBCUUPFunction != null && !gNBCUUPFunction.getpLMNInfoList().isEmpty()) {
+ gNBCUUPFunction.getpLMNInfoList().forEach(plmn -> {
+ // plmn.setgNBCUUPFunction(gNBCUUPFunction);
+ });
+ }
+ GNBCUUPFunction gNBCUUPEntity = gNBCUUPRepository.save(gNBCUUPFunction);
+ modelMapper.map(gNBCUUPEntity, gNBCUUPModel);
+ return gNBCUUPModel;
+ }
+
+ /**
+ * To fetch the gNBCUUP details
+ *
+ * @param cucpName
+ * @return GNBCUUPModel
+ */
+ public GNBCUUPModel fetchGNBCUUPData(Integer gNBCUUPId) {
+ logger.debug("Request received to fetch GNBCUUPFunction: id::" + gNBCUUPId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBCUUPFunction gNBCUUPEntity =
+ gNBCUUPRepository.findById(gNBCUUPId).isPresent() ? gNBCUUPRepository.findById(gNBCUUPId).get() : null;
+ GNBCUUPModel gNBCUUPModel = new GNBCUUPModel();
+ modelMapper.map(gNBCUUPEntity, gNBCUUPModel);
+ return gNBCUUPModel;
+ }
+
+ /**
+ * To store the slice / config details of GNBDUFunction
+ *
+ * @param GNBDUModel
+ * @return
+ */
+ public GNBDUModel saveGNBDU(GNBDUModel gNBDUModel) {
+ logger.debug("Request received to save GNBDUModel: id::" + gNBDUModel.getgNBDUId());
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBDUFunction gNBDUFunction = new GNBDUFunction();
+ NearRTRIC nearRTRICRef = new NearRTRIC();
+ modelMapper.map(gNBDUModel, gNBDUFunction);
+ if (gNBDUModel.getNearRTRICId() != null
+ && nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).isPresent()) {
+ nearRTRICRef = nearRTRICRepository.findById(gNBDUModel.getNearRTRICId()).get();
+ gNBDUFunction.setNearRTRIC(nearRTRICRef);
+ }
+ NearRTRIC nearRTRICRefNew = nearRTRICRef;
+ nearRTRICRefNew.setNearRTRICId(gNBDUModel.getNearRTRICId());
+ if (gNBDUFunction != null && !gNBDUFunction.getCellDUList().isEmpty()) {
+ gNBDUFunction.getCellDUList().forEach(cellDU -> {
+ cellDU.setgNBDUFunction(gNBDUFunction);
+ });
+ }
+ GNBDUFunction gNBDUEntity = gNBDURepository.save(gNBDUFunction);
+ modelMapper.map(gNBDUEntity, gNBDUModel);
+ return gNBDUModel;
+ }
+
+ /**
+ * To fetch the gNBDU details
+ *
+ * @param gNBDUId
+ * @return GNBDUModel
+ */
+ public GNBDUModel fetchGNBDUData(Integer gNBDUId) {
+ logger.debug("Request received to fetch GNBDUFunction: id::" + gNBDUId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ GNBDUFunction gNBDUEntity =
+ gNBDURepository.findById(gNBDUId).isPresent() ? gNBDURepository.findById(gNBDUId).get() : null;
+ GNBDUModel gNBDUModel = new GNBDUModel();
+ modelMapper.map(gNBDUEntity, gNBDUModel);
+ return gNBDUModel;
+ }
+
+ /**
+ * Stored NearRTRIC
+ *
+ * @param nearRTRIC
+ * @return
+ */
+ public NearRTRICModel saveNearRTRIC(NearRTRICModel nearRTRIC) {
+ logger.debug("Request received to store NearRTRIC: id::" + nearRTRIC.getNearRTRICId());
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ NearRTRIC nearRTRICEntity = new NearRTRIC();
+ modelMapper.map(nearRTRIC, nearRTRICEntity);
+ NearRTRIC nearRTRICEntityEResponse = nearRTRICRepository.save(nearRTRICEntity);
+ modelMapper.map(nearRTRICEntityEResponse, nearRTRIC);
+ return nearRTRIC;
+ }
+
+ /**
+ * To fetch the nearRTRIC details
+ *
+ * @param nearRTRICId
+ * @return NearRTRICModel
+ */
+ public NearRTRICModel fetchNearRTRICData(Integer nearRTRICId) {
+ logger.debug("Request received to fetch GNBDUFunction: id::" + nearRTRICId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ NearRTRIC nearRTRICEntity =
+ nearRTRICRepository.findById(nearRTRICId).isPresent() ? nearRTRICRepository.findById(nearRTRICId).get()
+ : null;
+ NearRTRICModel nearRTRICModel = new NearRTRICModel();
+ modelMapper.map(nearRTRICEntity, nearRTRICModel);
+ return nearRTRICModel;
+ }
+
+ /**
+ * To retrieve the RRMPolicy of a network function
+ *
+ * @param resourceType
+ * @param resourceID
+ * @return
+ */
+ public RRMPolicyRatioModel fetchRRMPolicyOfNE(String resourceType, String resourceID) {
+ logger.debug("Request received to fetch RRMPolicy:" + resourceType + "--" + resourceID);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ RRMPolicyRatioModel rrmPolicyResponse = new RRMPolicyRatioModel();
+ RRMPolicyRatio rrmPolicyEntity = rRMPolicyRepository.findByResourceTypeAndId(resourceType, resourceID);
+ modelMapper.map(rrmPolicyEntity, rrmPolicyResponse);
+ return rrmPolicyResponse;
+ }
+
+ /**
+ * To update RRM policy of NF
+ *
+ * @param rrmPolicy
+ * @return
+ */
+ public RRMPolicyRatioModel updateRRMPolicy(RRMPolicyRatioModel rrmPolicy) {
+ logger.debug("Request received to update RRMPolicy:" + rrmPolicy.getRrmPolicyID());
+ RRMPolicyRatio rrmPolicyEntity = new RRMPolicyRatio();
+ modelMapper.map(rrmPolicy, rrmPolicyEntity);
+ rrmPolicyEntity = rRMPolicyRepository.save(rrmPolicyEntity);
+ modelMapper.map(rrmPolicyEntity, rrmPolicy);
+ return rrmPolicy;
+ }
+
+ /**
+ * @param trackingArea
+ * @return List<NearRTRICModel>
+ */
+ public List<NearRTRICModel> findRICsInTA(String trackingArea) {
+ logger.debug("Request received to find the NearRTRICs in Tracking Area::" + trackingArea);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<NearRTRIC> nearRTRICsList = nearRTRICRepository.getListOfRICsInTrackingArea(trackingArea);
+ List<NearRTRICModel> ricModelList = nearRTRICsList.stream()
+ .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList());
+ return ricModelList;
+ }
+
+ /**
+ * @param cellsList
+ * @return
+ */
+ public List<NearRTRICModel> findNearRTRICofCells(List<Integer> cellsList) {
+ List<NearRTRIC> ricEntitiesList = new ArrayList<>();
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<String> cucpNames = gNBCUCPRepository.findCUCPByCellIds(cellsList);
+ cucpNames.forEach(cucpName -> {
+ List<NearRTRIC> ricEntities = new ArrayList<>();
+ ricEntities = nearRTRICRepository.findNearRTRICByCUCPName(cucpName);
+ ricEntitiesList.addAll(ricEntities);
+ });
+ List<NearRTRICModel> ricModelList = ricEntitiesList.stream()
+ .map(ricEntity -> modelMapper.map(ricEntity, NearRTRICModel.class)).collect(Collectors.toList());
+ return ricModelList;
+ }
+
+ /**
+ * To update the RAN Slice details
+ *
+ * @param rANSliceInfoModel
+ * @return RANSliceInfoModel
+ */
+ public RANSliceInfoModel updateRANInventory(RANSliceInfoModel rANSliceInfoModel) {
+ logger.debug("Request received to update inventory for id::" + rANSliceInfoModel.getRanNFNSSIId());
+ RANSliceInfo rANSliceInfoEntity = new RANSliceInfo();
+ modelMapper.map(rANSliceInfoModel, rANSliceInfoEntity);
+ if (ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).isPresent()) {
+ RANSliceInfo ranInfo = ranInventoryRepo.findById(rANSliceInfoModel.getRanNFNSSIId()).get();
+ List<String> ranNSSIList = ranInfo.getRanNSSIList();
+ ranNSSIList.addAll(rANSliceInfoEntity.getRanNSSIList());
+ rANSliceInfoEntity.setRanNSSIList(ranNSSIList);
+
+ List<String> nSSAIList = ranInfo.getnSSAIList();
+ nSSAIList.addAll(rANSliceInfoEntity.getnSSAIList());
+ rANSliceInfoEntity.setnSSAIList(nSSAIList);
+
+ List<SliceProfile> sliceProfilesList = ranInfo.getSliceProfilesList();
+ sliceProfilesList.addAll(rANSliceInfoEntity.getSliceProfilesList());
+ rANSliceInfoEntity.setSliceProfilesList(sliceProfilesList);
+ } else {
+ if (!rANSliceInfoEntity.getSliceProfilesList().isEmpty()) {
+ for (SliceProfile profile : rANSliceInfoEntity.getSliceProfilesList()) {
+ profile.setrANSliceInventory(rANSliceInfoEntity);
+ }
+ }
+ }
+ rANSliceInfoEntity = ranInventoryRepo.save(rANSliceInfoEntity);
+ modelMapper.map(rANSliceInfoEntity, rANSliceInfoModel);
+ return rANSliceInfoModel;
+ }
+
+ /**
+ * @param ranNFNSSIId
+ * @return RANSliceInfoModel
+ */
+ public RANSliceInfoModel fetchRANSlice(String ranNFNSSIId) {
+ logger.debug("Request received to read inventory details for id::" + ranNFNSSIId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ RANSliceInfo ranSliceInfo =
+ ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get()
+ : null;
+ RANSliceInfoModel rANSliceInfoModel = new RANSliceInfoModel();
+ modelMapper.map(ranSliceInfo, rANSliceInfoModel);
+ return rANSliceInfoModel;
+ }
+
+ /**
+ * @param trackingArea
+ * @return List<String>
+ */
+ public List<String> fetchCellsofTA(String trackingArea) {
+ logger.debug("Request recieved to fetch the cell details of TA:" + trackingArea);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ String cells = tACellRepository.findById(trackingArea).isPresent()
+ ? tACellRepository.findById(trackingArea).get().getCellsList()
+ : null;
+ return cells != null ? Arrays.asList(cells.split(",")) : null;
+
+ }
+
+ public Iterable<TACells> fetchAllTA() {
+ logger.info("Request recieved to fetch all TA:");
+ return tACellRepository.findAll();
+ }
+
+ /**
+ * @param nearRTRICId
+ * @return List<NRCellCUModel>
+ */
+ public List<NRCellCUModel> fetchCUCellsofRIC(Integer nearRTRICId) {
+ logger.debug("Request recieved to fetch the cell (CU) details of nearRTRICId:" + nearRTRICId);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<NRCellCU> cellCUEntities = new ArrayList<NRCellCU>();
+ NearRTRIC nearRTRIC =
+ nearRTRICRepository.findById(nearRTRICId).isPresent() ? nearRTRICRepository.findById(nearRTRICId).get()
+ : null;
+ if (nearRTRIC != null) {
+ List<GNBCUCPFunction> cucpFunctions = nearRTRIC.getgNBCUCPList();
+ cucpFunctions.forEach(cucpFunction -> {
+ List<NRCellCU> cellCUList = new ArrayList<NRCellCU>();
+ cellCUList.addAll(cucpFunction.getCellCUList());
+ cellCUEntities.addAll(cellCUList);
+ });
+ List<NRCellCUModel> cuCellModels =
+ cellCUEntities.stream().map(cellCUEntity -> modelMapper.map(cellCUEntity, NRCellCUModel.class))
+ .collect(Collectors.toList());
+ return cuCellModels;
+ }
+ return new ArrayList<NRCellCUModel>();
+ }
+
+ /**
+ * @param trackingArea
+ * @return List<NRCellDUModel>
+ */
+ public Map<Integer, List<NRCellDUModel>> fetchDUCellsofRIC(String sNSSAI) {
+ logger.debug("Request recieved to fetch the cell (DU) details of sNSSAI:" + sNSSAI);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ Set<NRCellDU> cellDUEntities = new HashSet<NRCellDU>();
+ Set<NRCellDU> cellDUs = new HashSet<NRCellDU>();
+ List<NearRTRICModel> ricModels = findRICsByNSSAI(sNSSAI);
+ Map<Integer, List<NRCellDUModel>> cellsMap = new HashMap<Integer, List<NRCellDUModel>>();
+ List<NearRTRIC> ricEntities =
+ ricModels.stream().map(ric -> modelMapper.map(ric, NearRTRIC.class)).collect(Collectors.toList());
+ ricEntities.forEach(ricEntity -> {
+ List<GNBDUFunction> duFunctions = ricEntity.getgNBDUList();
+ duFunctions.forEach(duFunction -> {
+ List<NRCellDU> cellDUList = duFunction.getCellDUList();
+ cellDUList.forEach(cellDU -> {
+ List<PLMNInfo> plmnList = cellDU.getpLMNInfoList();
+ plmnList.forEach(plmn -> {
+ if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) {
+ cellDUs.add(cellDU);
+ }
+ });
+ });
+ // cellDUList.addAll(duFunction.getCellDUList());
+ cellDUEntities.addAll(cellDUs);
+ });
+ List<NRCellDUModel> duCellModels =
+ cellDUEntities.stream().map(cellDUEntity -> modelMapper.map(cellDUEntity, NRCellDUModel.class))
+ .collect(Collectors.toList());
+ cellsMap.put(ricEntity.getNearRTRICId(), duCellModels);
+ });
+
+ return cellsMap;
+ }
+
+ /**
+ * @param ranNFNSSIID
+ * @return List<NearRTRICModel>
+ */
+ public List<NearRTRICModel> findNearRTRICByNSSI(String ranNFNSSIID) {
+ logger.debug("Request recieved to fetch nearRTRIC of NSSI:" + ranNFNSSIID);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSI(ranNFNSSIID);
+ List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream()
+ .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class))
+ .collect(Collectors.toList());
+ return nearRTRICModels;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return List<NearRTRICModel>
+ */
+ public List<NearRTRICModel> findRICsByNSSAI(String sNSSAI) {
+ logger.debug("Request recieved to fetch nearRTRIC of NSSAI:" + sNSSAI);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ Set<NearRTRIC> nearRTRICEntities = nearRTRICRepository.findNearRTRICByNSSAI(sNSSAI);
+ List<NearRTRICModel> nearRTRICModels = nearRTRICEntities.stream()
+ .map(nearRTRICEntity -> modelMapper.map(nearRTRICEntity, NearRTRICModel.class))
+ .collect(Collectors.toList());
+ return nearRTRICModels;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return config Details
+ */
+ public Map<String, Integer> findSliceProfileconfig(String sNSSAI) {
+ logger.debug("Request recieved to fetch Config requested for a slice:" + sNSSAI);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ Map<String, Integer> configDetails = new HashMap<String, Integer>();
+ String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI);
+ RANSliceInfo rANSliceInfo =
+ ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get()
+ : null;
+ if (rANSliceInfo.getSliceProfilesList().size() > 0) {
+ rANSliceInfo.getSliceProfilesList().forEach(sliceProfile -> {
+ if (sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())) {
+ // configDetails.put("maxNoOfConns",sliceProfile.getMaxNumberofConns());
+ configDetails.put("dLThptPerSlice", sliceProfile.getdLThptPerSlice());
+ configDetails.put("uLThptPerSlice", sliceProfile.getuLThptPerSlice());
+ }
+ });
+ }
+ return configDetails;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return RIC Config for a slice
+ */
+ public Map<Integer, NSSAIConfig> findSliceConfig(String sNSSAI) {
+ logger.debug("Request recieved to fetch Slice config Details at RICs:" + sNSSAI);
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI);
+ Map<Integer, NSSAIConfig> configMap = new HashMap<Integer, NSSAIConfig>();
+ nearRTRICModels.forEach(nearRTRIC -> {
+ nearRTRIC.getpLMNInfoList().forEach(plmn -> {
+ if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) {
+ configMap.put(nearRTRIC.getNearRTRICId(), plmn.getsNSSAI().getConfigData());
+ }
+ });
+ });
+ return configMap;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return List<GNBDUModel>
+ */
+ public List<GNBDUModel> findDUsofSNssai(String sNSSAI) {
+ logger.debug("Request recieved to fetch all DUs of NSSAI");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findDUsByNSSAI(sNSSAI);
+ List<GNBDUModel> duModels = duList.stream().map(duEntity -> modelMapper.map(duEntity, GNBDUModel.class))
+ .collect(Collectors.toList());
+ return duModels;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return List<GNBCUCPModel>
+ */
+ public List<GNBCUCPModel> findCUsofSNssai(String sNSSAI) {
+ logger.debug("Request recieved to fetch all CUs of NSSAI");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<GNBCUCPFunction> cuList = (List<GNBCUCPFunction>) gNBCUCPRepository.findCUCPsByNSSAI(sNSSAI);
+ List<GNBCUCPModel> cuModels = cuList.stream().map(cuEntity -> modelMapper.map(cuEntity, GNBCUCPModel.class))
+ .collect(Collectors.toList());
+ return cuModels;
+ }
+
+ /**
+ * @param sNSSAI
+ * @return Map<String, String>
+ */
+ public Map<String, String> getSubscriberDetails(String sNSSAI) {
+ logger.debug("Request recieved to fetch SubscriberDetails");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ Map<String, String> details = new HashMap<String, String>();
+ String ranNFNSSIId = ranInventoryRepo.findRANNFNSSIofNSSAI(sNSSAI);
+ details.put("ranNFNSSIId", ranNFNSSIId);
+ details.put("sNSSAI", sNSSAI);
+ RANSliceInfo rANSliceInfo =
+ ranInventoryRepo.findById(ranNFNSSIId).isPresent() ? ranInventoryRepo.findById(ranNFNSSIId).get()
+ : null;
+ if (rANSliceInfo.getSliceProfilesList().size() > 0) {
+ rANSliceInfo.getSliceProfilesList().forEach(sliceProfile -> {
+ if (sNSSAI.equalsIgnoreCase(sliceProfile.getsNSSAI())) {
+ details.put("sliceProfileId", sliceProfile.getSliceProfileId());
+ }
+ });
+ }
+ List<NearRTRICModel> nearRTRICModels = findRICsByNSSAI(sNSSAI);
+ nearRTRICModels.forEach(nearRTRIC -> {
+ nearRTRIC.getpLMNInfoList().forEach(plmn -> {
+ if (sNSSAI.equalsIgnoreCase(plmn.getsNSSAI().getsNSSAI())) {
+ details.put("subscriptionServiceType", plmn.getsNSSAI().getSubscriptionServiceType());
+ details.put("globalSubscriberId", plmn.getsNSSAI().getGlobalSubscriberId());
+ }
+ });
+ });
+
+ return details;
+ }
+
+ // Data required for PM data Simulation
+ /**
+ * @return List<GNBCUCPModel>
+ */
+ public List<GNBCUCPModel> findAllCUCPFunctions() {
+ logger.debug("Request recieved to fetch all CUCPs");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<GNBCUCPFunction> cucpsList = (List<GNBCUCPFunction>) gNBCUCPRepository.findAll();
+ List<GNBCUCPModel> cucpModels = cucpsList.stream()
+ .map(cucpEntity -> modelMapper.map(cucpEntity, GNBCUCPModel.class)).collect(Collectors.toList());
+ return cucpModels;
+ }
+
+ /**
+ * @return List<GNBDUModel>
+ */
+ public List<GNBDUModel> findAllDUFunctions() {
+ logger.debug("Request recieved to fetch all DUs");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<GNBDUFunction> duList = (List<GNBDUFunction>) gNBDURepository.findAll();
+ List<GNBDUModel> duModels = duList.stream().map(duEntity -> {
+ GNBDUModel gnbDuModel = modelMapper.map(duEntity, GNBDUModel.class);
+ gnbDuModel.setNearRTRICId(duEntity.getNearRTRIC().getNearRTRICId());
+ return gnbDuModel;
+ }).collect(Collectors.toList());
+ return duModels;
+ }
+
+ public List<NearRTRICModel> findAllNearRTRIC() {
+ logger.debug("Request received to fetch all NearRTRICModel");
+ modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
+ List<NearRTRIC> rtricList = (List<NearRTRIC>) nearRTRICRepository.findAll();
+ List<NearRTRICModel> rtricmodels = rtricList.stream()
+ .map(rtricEntity -> modelMapper.map(rtricEntity, NearRTRICModel.class)).collect(Collectors.toList());
+ return rtricmodels;
+ }
+
}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java
index a06f3c7..6197751 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java
@@ -20,6 +20,8 @@
package org.onap.ransim.rest.api.services;
+import com.google.gson.Gson;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -42,1039 +44,1016 @@ import javax.annotation.PostConstruct;
import javax.websocket.Session;
import org.apache.log4j.Logger;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.onap.ransim.netconf.NetconfClient;
import org.onap.ransim.rest.api.handler.RansimPciHandler;
import org.onap.ransim.rest.api.models.CellData;
import org.onap.ransim.rest.api.models.CellDetails;
import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.NSSAIConfig;
import org.onap.ransim.rest.api.models.NbrDump;
import org.onap.ransim.rest.api.models.NeighborDetails;
import org.onap.ransim.rest.api.models.NeihborId;
import org.onap.ransim.rest.api.models.NetconfServers;
import org.onap.ransim.rest.api.models.PLMNInfo;
-import org.onap.ransim.rest.api.models.TopologyDump;
-import org.onap.ransim.rest.api.models.RRMPolicyRatio;
import org.onap.ransim.rest.api.models.RRMPolicyMember;
+import org.onap.ransim.rest.api.models.RRMPolicyRatio;
import org.onap.ransim.rest.api.models.SliceProfile;
+import org.onap.ransim.rest.api.models.TopologyDump;
import org.onap.ransim.rest.api.repository.GNBCUUPRepository;
import org.onap.ransim.rest.api.repository.NRCellCURepository;
import org.onap.ransim.rest.api.repository.NRCellDURepository;
-//import org.onap.ransim.rest.api.repository.PLMNInfoRepo;
import org.onap.ransim.rest.api.repository.RRMPolicyRepository;
import org.onap.ransim.rest.api.repository.SliceProfileRepository;
import org.onap.ransim.rest.client.RestClient;
+import org.onap.ransim.rest.web.mapper.GNBCUCPModel;
+import org.onap.ransim.rest.web.mapper.GNBCUUPModel;
+import org.onap.ransim.rest.web.mapper.GNBDUModel;
+import org.onap.ransim.rest.web.mapper.NRCellCUModel;
+import org.onap.ransim.rest.web.mapper.NRCellDUModel;
+import org.onap.ransim.rest.web.mapper.NSSAIData;
+import org.onap.ransim.rest.web.mapper.NearRTRICModel;
+import org.onap.ransim.rest.web.mapper.PLMNInfoModel;
+import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel;
import org.onap.ransim.utilities.RansimUtilities;
+import org.onap.ransim.websocket.model.*;
+import org.onap.ransim.websocket.model.ConfigData;
+import org.onap.ransim.websocket.model.ConfigPLMNInfo;
import org.onap.ransim.websocket.model.ModifyNeighbor;
import org.onap.ransim.websocket.model.ModifyPci;
import org.onap.ransim.websocket.model.Neighbor;
+import org.onap.ransim.websocket.model.SNSSAI;
import org.onap.ransim.websocket.model.SetConfigTopology;
import org.onap.ransim.websocket.model.Topology;
import org.onap.ransim.websocket.model.UpdateCell;
-import org.onap.ransim.websocket.model.ConfigPLMNInfo;
-import org.onap.ransim.websocket.model.SNSSAI;
-import org.onap.ransim.websocket.model.ConfigData;
import org.onap.ransim.websocket.server.RansimWebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import org.onap.ransim.rest.web.mapper.NearRTRICModel;
-import org.onap.ransim.rest.web.mapper.GNBCUCPModel;
-import org.onap.ransim.rest.web.mapper.GNBCUUPModel;
-import org.onap.ransim.rest.web.mapper.GNBDUModel;
-import org.onap.ransim.rest.web.mapper.NRCellDUModel;
-import org.onap.ransim.rest.web.mapper.NRCellCUModel;
-import org.onap.ransim.rest.web.mapper.PLMNInfoModel;
-import org.onap.ransim.rest.web.mapper.RRMPolicyRatioModel;
-import org.onap.ransim.rest.web.mapper.NSSAIData;
-import org.onap.ransim.rest.api.models.NSSAIConfig;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
-import com.google.gson.Gson;
-import org.onap.ransim.websocket.model.*;
-import org.onap.ransim.netconf.NetconfClient;
-
@Service
public class RansimControllerServices {
- static Logger log = Logger.getLogger(RansimControllerServices.class.getName());
-
- Properties netconfConstants = new Properties();
- public int gridSize = 10;
- boolean collision = false;
- String serverIdPrefix = "";
- public static String useCaseType = "";
- static int numberOfCellsPerNcServer = 15;
- int numberOfMachines = 1;
- int numberOfProcessPerMc = 5;
- boolean strictValidateRansimAgentsAvailability = false;
- static public Map<String, Session> webSocketSessions = new ConcurrentHashMap<String, Session>();
- public static Map<String, String> serverIdIpPortMapping = new ConcurrentHashMap<String, String>();
-
- static Map<String, String> globalNcServerUuidMap = new ConcurrentHashMap<String, String>();
- static List<String> unassignedServerIds = Collections.synchronizedList(new ArrayList<String>());
- static Map<String, List<String>> serverIdIpNodeMapping = new ConcurrentHashMap<String, List<String>>();
- static Map<String, List<String>> ricIdFunctionMapping = new ConcurrentHashMap<String, List<String>>();
- static List<String> unassignedgNBIds = Collections.synchronizedList(new ArrayList<String>());
- static List<String> unassignedrtRicIds = Collections.synchronizedList(new ArrayList<String>());
+ static Logger log = Logger.getLogger(RansimControllerServices.class.getName());
+
+ Properties netconfConstants = new Properties();
+ public int gridSize = 10;
+ boolean collision = false;
+ String serverIdPrefix = "";
+ public static String useCaseType = "";
+ static int numberOfCellsPerNcServer = 15;
+ int numberOfMachines = 1;
+ int numberOfProcessPerMc = 5;
+ boolean strictValidateRansimAgentsAvailability = false;
+ static public Map<String, Session> webSocketSessions = new ConcurrentHashMap<String, Session>();
+ public static Map<String, String> serverIdIpPortMapping = new ConcurrentHashMap<String, String>();
+
+ static Map<String, String> globalNcServerUuidMap = new ConcurrentHashMap<String, String>();
+ static List<String> unassignedServerIds = Collections.synchronizedList(new ArrayList<String>());
+ static Map<String, List<String>> serverIdIpNodeMapping = new ConcurrentHashMap<String, List<String>>();
+ static Map<String, List<String>> ricIdFunctionMapping = new ConcurrentHashMap<String, List<String>>();
+ static List<String> unassignedgNBIds = Collections.synchronizedList(new ArrayList<String>());
+ static List<String> unassignedrtRicIds = Collections.synchronizedList(new ArrayList<String>());
static List<NearRTRICModel> rtricModelList = Collections.synchronizedList(new ArrayList<>());
- int nextServerIdNumber = 1001;
- String sdnrServerIp = "";
- int sdnrServerPort = 0;
- static String sdnrServerUserid = "";
- static String sdnrServerPassword = "";
- private static final String fileBasePath = "/tmp/ransim-install/config/";
- public static String dumpFileName = "";
- public static long maxPciValueAllowed = 503;
-
- @Autowired
- RansimPciHandler rsPciHdlr;
-
- @Autowired
- RansimRepositoryService ransimRepo;
-
- @Autowired
- RANSliceConfigService ranSliceConfigService;
-
- @Autowired
- RRMPolicyRepository rrmPolicyRepository;
-
- @Autowired
- NRCellDURepository nRCellDURepository;
-
- @Autowired
- NRCellCURepository nRCellCURepository;
-
- @Autowired
- GNBCUUPRepository gNBCUUPRepository;
-/*
- @Autowired
- PLMNInfoRepo pLMNInfoRepo;
-
- */ @Autowired
- SliceProfileRepository sliceProfileRepository;
-
- @PostConstruct
- private void startWSTheread() {
- new KeepWebsockAliveThread(this).start();
- }
-
- private String checkIpPortAlreadyExists(String ipPort, Map<String, String> serverIdIpPortMapping) {
- String serverId = null;
- for (String key : serverIdIpPortMapping.keySet()) {
- String value = serverIdIpPortMapping.get(key);
- if (value.equals(ipPort)) {
- serverId = key;
- break;
- }
- }
- return serverId;
- }
-
- /**
- * Add web socket sessions.
- * * @param ipPort ip address for the session
- * @param wsSession session details
- */
- public synchronized String addWebSocketSessions(String ipPort, Session wsSession) {
- loadProperties();
- if (webSocketSessions.containsKey(ipPort)) {
- log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
- + " already exist. Removing old session.");
- webSocketSessions.remove(ipPort);
- }
-
- log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort);
- webSocketSessions.put(ipPort, wsSession);
- String serverId = null;
- if (!serverIdIpPortMapping.containsValue(ipPort)) {
- if (unassignedServerIds.size() > 0) {
- log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
- serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
- if (serverId == null) {
- serverId = unassignedServerIds.remove(0);
- } else {
- if (unassignedServerIds.contains(serverId)) {
- unassignedServerIds.remove(serverId);
- }
- }
- log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedServerIds);
- log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort);
- serverIdIpPortMapping.put(serverId, ipPort);
- log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
- mapServerIdToNodes(serverId);
- try {
-
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- if (server != null) {
- server.setIp(ipPort.split(":")[0]);
- server.setNetconfPort(ipPort.split(":")[1]);
- ransimRepo.mergeNetconfServers(server);
- }
-
- } catch (Exception e1) {
- log.error("Exception mapServerIdToNodes :", e1);
- }
- } else {
- log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
- }
- } else {
- for (String key : serverIdIpPortMapping.keySet()) {
- if (serverIdIpPortMapping.get(key).equals(ipPort)) {
- log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already");
- serverId = key;
- break;
- }
- }
- }
- return serverId;
- }
-
- public synchronized String addRanWebSocketSessions(String ipPort, Session wsSession) {
- if (webSocketSessions.containsKey(ipPort)) {
- log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
- + " already exist. Removing old session.");
- webSocketSessions.remove(ipPort);
- }
-
- log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort);
- webSocketSessions.put(ipPort, wsSession);
- String serverId = null;
- if (!serverIdIpPortMapping.containsValue(ipPort)) {
- if(!ricIdFunctionMapping.isEmpty()){
- if (unassignedgNBIds.size() > 0) {
- log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
- serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
- if (serverId == null) {
- serverId = unassignedgNBIds.remove(0);
- } else {
- if (unassignedgNBIds.contains(serverId)) {
- unassignedgNBIds.remove(serverId);
- }
- }
- log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedgNBIds);
- log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort);
- serverIdIpPortMapping.put(serverId, ipPort);
- log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
- try {
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- if (server != null) {
- server.setIp(ipPort.split(":")[0]);
- server.setNetconfPort(ipPort.split(":")[1]);
- ransimRepo.mergeNetconfServers(server);
- }
-
- } catch (Exception e1) {
- log.error("Exception mapServerIdToNodes :", e1);
- }
- } else
- {
- if(unassignedrtRicIds.size() > 0)
- {
- unassignedgNBIds.addAll(ricIdFunctionMapping.get(unassignedrtRicIds.get(0)));
+ int nextServerIdNumber = 1001;
+ String sdnrServerIp = "";
+ int sdnrServerPort = 0;
+ static String sdnrServerUserid = "";
+ static String sdnrServerPassword = "";
+ private static final String fileBasePath = "/tmp/ransim-install/config/";
+ public static String dumpFileName = "";
+ public static long maxPciValueAllowed = 503;
+
+ @Autowired
+ RansimPciHandler rsPciHdlr;
+
+ @Autowired
+ RansimRepositoryService ransimRepo;
+
+ @Autowired
+ RANSliceConfigService ranSliceConfigService;
+
+ @Autowired
+ RRMPolicyRepository rrmPolicyRepository;
+
+ @Autowired
+ NRCellDURepository nRCellDURepository;
+
+ @Autowired
+ NRCellCURepository nRCellCURepository;
+
+ @Autowired
+ GNBCUUPRepository gNBCUUPRepository;
+ /*
+ * @Autowired
+ * PLMNInfoRepo pLMNInfoRepo;
+ *
+ */ @Autowired
+ SliceProfileRepository sliceProfileRepository;
+
+ @PostConstruct
+ private void startWSTheread() {
+ new KeepWebsockAliveThread(this).start();
+ }
+
+ private String checkIpPortAlreadyExists(String ipPort, Map<String, String> serverIdIpPortMapping) {
+ String serverId = null;
+ for (String key : serverIdIpPortMapping.keySet()) {
+ String value = serverIdIpPortMapping.get(key);
+ if (value.equals(ipPort)) {
+ serverId = key;
+ break;
+ }
+ }
+ return serverId;
+ }
+
+ /**
+ * Add web socket sessions.
+ * * @param ipPort ip address for the session
+ *
+ * @param wsSession session details
+ */
+ public synchronized String addWebSocketSessions(String ipPort, Session wsSession) {
+ loadProperties();
+ if (webSocketSessions.containsKey(ipPort)) {
+ log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
+ + " already exist. Removing old session.");
+ webSocketSessions.remove(ipPort);
+ }
+
+ log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort);
+ webSocketSessions.put(ipPort, wsSession);
+ String serverId = null;
+ if (!serverIdIpPortMapping.containsValue(ipPort)) {
+ if (unassignedServerIds.size() > 0) {
log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
- serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
- if (serverId == null) {
- serverId = unassignedrtRicIds.remove(0);
- } else {
- if (unassignedrtRicIds.contains(serverId)) {
- unassignedrtRicIds.remove(serverId);
- }
- }
- log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedrtRicIds);
- log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort);
- serverIdIpPortMapping.put(serverId, ipPort);
- log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
- try {
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- if (server != null) {
- server.setIp(ipPort.split(":")[0]);
- server.setNetconfPort(ipPort.split(":")[1]);
- ransimRepo.mergeNetconfServers(server);
- }
-
- } catch (Exception e1) {
- log.error("Exception mapServerIdToNodes :", e1);
- }
- }
- else
- {
- log.info("addWebSocketSessions: No ric serverIds pending to assign for " + ipPort);
- }
- }
- }
- else
- {
- log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
- }
- } else {
- for (String key : serverIdIpPortMapping.keySet()) {
- if (serverIdIpPortMapping.get(key).equals(ipPort)) {
- log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already");
- serverId = key;
- break;
- }
- }
- }
- return serverId;
- }
-
- /**
- * Map server ID to the cells
- *
- * @param serverId Server ID
- */
- private void mapServerIdToNodes(String serverId) {
- dumpSessionDetails();
- // already mapped.RansimController Do nothing.
- if (!serverIdIpNodeMapping.containsKey(serverId)) {
- List<String> nodeIds = new ArrayList<String>();
- try {
- List<CellDetails> nodes = ransimRepo.getCellsWithNoServerIds();
- for (CellDetails cell : nodes) {
- cell.setServerId(serverId);
- nodeIds.add(cell.getNodeId());
- ransimRepo.mergeCellDetails(cell);
- }
- serverIdIpNodeMapping.put(serverId, nodeIds);
- } catch (Exception e1) {
- log.info("Exception mapServerIdToNodes :", e1);
-
- }
- }
- }
-
- /**
- * It removes the web socket sessions.
- *
- * @param ipPort ip address of the netconf server
- */
- public synchronized void removeWebSocketSessions(String ipPort) {
- log.info("remove websocket session request received for: " + ipPort);
- try {
- if (webSocketSessions.containsKey(ipPort)) {
- String removedServerId = null;
- for (String serverId : serverIdIpPortMapping.keySet()) {
- String ipPortVal = serverIdIpPortMapping.get(serverId);
- if (ipPortVal.equals(ipPort)) {
- if (!unassignedServerIds.contains(serverId)) {
- unassignedServerIds.add(serverId);
- log.info(serverId + "added in unassignedServerIds");
- }
- NetconfServers ns = ransimRepo.getNetconfServer(serverId);
- ns.setIp(null);
- ns.setNetconfPort(null);
- log.info(serverId + " ip and Port set as null ");
- ransimRepo.mergeNetconfServers(ns);
- removedServerId = serverId;
- break;
- }
- }
- serverIdIpPortMapping.remove(removedServerId);
-
- Session wsSession = webSocketSessions.remove(ipPort);
- log.info("removeWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
- + " is removed. Server Id : " + removedServerId);
- } else {
- log.info("addWebSocketSessions: Client session for " + ipPort + " not exist");
- }
- } catch (Exception e) {
- log.error("Exception in removeWebSocketSessions. e: " + e);
- }
-
- }
-
- /**
- * Checks the number of ransim agents running.
- *
- * @param cellsToBeSimulated number of cells to be simulated
- * @return returns true if there are enough ransim agents running
- */
- public boolean hasEnoughRansimAgentsRunning(int cellsToBeSimulated) {
-
- log.info("hasEnoughRansimAgentsRunning: numberOfCellsPerNCServer " + numberOfCellsPerNcServer
- + " , webSocketSessions.size:" + webSocketSessions.size() + " , cellsToBeSimulated:"
- + cellsToBeSimulated);
- log.info(strictValidateRansimAgentsAvailability);
-
- if (strictValidateRansimAgentsAvailability) {
- if (numberOfCellsPerNcServer * webSocketSessions.size() < cellsToBeSimulated) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * It updates the constant values in the properties file.
- */
- public void loadProperties() {
- InputStream input = null;
- try {
-
- input = new FileInputStream("/tmp/ransim-install/config/ransim.properties");
- netconfConstants.load(input);
- serverIdPrefix = netconfConstants.getProperty("serverIdPrefix");
- numberOfCellsPerNcServer = Integer.parseInt(netconfConstants.getProperty("numberOfCellsPerNCServer"));
- numberOfMachines = Integer.parseInt(netconfConstants.getProperty("numberOfMachines"));
- numberOfProcessPerMc = Integer.parseInt(netconfConstants.getProperty("numberOfProcessPerMc"));
- strictValidateRansimAgentsAvailability = Boolean
- .parseBoolean(netconfConstants.getProperty("strictValidateRansimAgentsAvailability"));
- maxPciValueAllowed = Long.parseLong(netconfConstants.getProperty("maxPciValueAllowed"));
- sdnrServerIp = System.getenv("SDNR_IP");
+ serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
+ if (serverId == null) {
+ serverId = unassignedServerIds.remove(0);
+ } else {
+ if (unassignedServerIds.contains(serverId)) {
+ unassignedServerIds.remove(serverId);
+ }
+ }
+ log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedServerIds);
+ log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort);
+ serverIdIpPortMapping.put(serverId, ipPort);
+ log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
+ mapServerIdToNodes(serverId);
+ try {
+
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ if (server != null) {
+ server.setIp(ipPort.split(":")[0]);
+ server.setNetconfPort(ipPort.split(":")[1]);
+ ransimRepo.mergeNetconfServers(server);
+ }
+
+ } catch (Exception e1) {
+ log.error("Exception mapServerIdToNodes :", e1);
+ }
+ } else {
+ log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
+ }
+ } else {
+ for (String key : serverIdIpPortMapping.keySet()) {
+ if (serverIdIpPortMapping.get(key).equals(ipPort)) {
+ log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already");
+ serverId = key;
+ break;
+ }
+ }
+ }
+ return serverId;
+ }
+
+ public synchronized String addRanWebSocketSessions(String ipPort, Session wsSession) {
+ if (webSocketSessions.containsKey(ipPort)) {
+ log.info("addWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
+ + " already exist. Removing old session.");
+ webSocketSessions.remove(ipPort);
+ }
+
+ log.info("addWebSocketSessions: Adding Client session " + wsSession.getId() + " for " + ipPort);
+ webSocketSessions.put(ipPort, wsSession);
+ String serverId = null;
+ if (!serverIdIpPortMapping.containsValue(ipPort)) {
+ if (!ricIdFunctionMapping.isEmpty()) {
+ if (unassignedgNBIds.size() > 0) {
+ log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
+ serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
+ if (serverId == null) {
+ serverId = unassignedgNBIds.remove(0);
+ } else {
+ if (unassignedgNBIds.contains(serverId)) {
+ unassignedgNBIds.remove(serverId);
+ }
+ }
+ log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedgNBIds);
+ log.info(
+ "RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for " + ipPort);
+ serverIdIpPortMapping.put(serverId, ipPort);
+ log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
+ try {
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ if (server != null) {
+ server.setIp(ipPort.split(":")[0]);
+ server.setNetconfPort(ipPort.split(":")[1]);
+ ransimRepo.mergeNetconfServers(server);
+ }
+
+ } catch (Exception e1) {
+ log.error("Exception mapServerIdToNodes :", e1);
+ }
+ } else {
+ if (unassignedrtRicIds.size() > 0) {
+ unassignedgNBIds.addAll(ricIdFunctionMapping.get(unassignedrtRicIds.get(0)));
+ log.info("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
+ serverId = checkIpPortAlreadyExists(ipPort, serverIdIpPortMapping);
+ if (serverId == null) {
+ serverId = unassignedrtRicIds.remove(0);
+ } else {
+ if (unassignedrtRicIds.contains(serverId)) {
+ unassignedrtRicIds.remove(serverId);
+ }
+ }
+ log.info("RanSim Controller - Available unassigned ServerIds :" + unassignedrtRicIds);
+ log.info("RanSim Controller - addWebSocketSessions: Adding serverId " + serverId + " for "
+ + ipPort);
+ serverIdIpPortMapping.put(serverId, ipPort);
+ log.debug("RanSim Controller - serverIdIpPortMapping >>>> :" + serverIdIpPortMapping);
+ try {
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ if (server != null) {
+ server.setIp(ipPort.split(":")[0]);
+ server.setNetconfPort(ipPort.split(":")[1]);
+ ransimRepo.mergeNetconfServers(server);
+ }
+
+ } catch (Exception e1) {
+ log.error("Exception mapServerIdToNodes :", e1);
+ }
+ } else {
+ log.info("addWebSocketSessions: No ric serverIds pending to assign for " + ipPort);
+ }
+ }
+ } else {
+ log.error("addWebSocketSessions: No serverIds pending to assign for " + ipPort);
+ }
+ } else {
+ for (String key : serverIdIpPortMapping.keySet()) {
+ if (serverIdIpPortMapping.get(key).equals(ipPort)) {
+ log.info("addWebSocketSessions: ServerId " + key + " for " + ipPort + " is exist already");
+ serverId = key;
+ break;
+ }
+ }
+ }
+ return serverId;
+ }
+
+ /**
+ * Map server ID to the cells
+ *
+ * @param serverId Server ID
+ */
+ private void mapServerIdToNodes(String serverId) {
+ dumpSessionDetails();
+ // already mapped.RansimController Do nothing.
+ if (!serverIdIpNodeMapping.containsKey(serverId)) {
+ List<String> nodeIds = new ArrayList<String>();
+ try {
+ List<CellDetails> nodes = ransimRepo.getCellsWithNoServerIds();
+ for (CellDetails cell : nodes) {
+ cell.setServerId(serverId);
+ nodeIds.add(cell.getNodeId());
+ ransimRepo.mergeCellDetails(cell);
+ }
+ serverIdIpNodeMapping.put(serverId, nodeIds);
+ } catch (Exception e1) {
+ log.info("Exception mapServerIdToNodes :", e1);
+
+ }
+ }
+ }
+
+ /**
+ * It removes the web socket sessions.
+ *
+ * @param ipPort ip address of the netconf server
+ */
+ public synchronized void removeWebSocketSessions(String ipPort) {
+ log.info("remove websocket session request received for: " + ipPort);
+ try {
+ if (webSocketSessions.containsKey(ipPort)) {
+ String removedServerId = null;
+ for (String serverId : serverIdIpPortMapping.keySet()) {
+ String ipPortVal = serverIdIpPortMapping.get(serverId);
+ if (ipPortVal.equals(ipPort)) {
+ if (!unassignedServerIds.contains(serverId)) {
+ unassignedServerIds.add(serverId);
+ log.info(serverId + "added in unassignedServerIds");
+ }
+ NetconfServers ns = ransimRepo.getNetconfServer(serverId);
+ ns.setIp(null);
+ ns.setNetconfPort(null);
+ log.info(serverId + " ip and Port set as null ");
+ ransimRepo.mergeNetconfServers(ns);
+ removedServerId = serverId;
+ break;
+ }
+ }
+ serverIdIpPortMapping.remove(removedServerId);
+
+ Session wsSession = webSocketSessions.remove(ipPort);
+ log.info("removeWebSocketSessions: Client session " + wsSession.getId() + " for " + ipPort
+ + " is removed. Server Id : " + removedServerId);
+ } else {
+ log.info("addWebSocketSessions: Client session for " + ipPort + " not exist");
+ }
+ } catch (Exception e) {
+ log.error("Exception in removeWebSocketSessions. e: " + e);
+ }
+
+ }
+
+ /**
+ * Checks the number of ransim agents running.
+ *
+ * @param cellsToBeSimulated number of cells to be simulated
+ * @return returns true if there are enough ransim agents running
+ */
+ public boolean hasEnoughRansimAgentsRunning(int cellsToBeSimulated) {
+
+ log.info("hasEnoughRansimAgentsRunning: numberOfCellsPerNCServer " + numberOfCellsPerNcServer
+ + " , webSocketSessions.size:" + webSocketSessions.size() + " , cellsToBeSimulated:"
+ + cellsToBeSimulated);
+ log.info(strictValidateRansimAgentsAvailability);
+
+ if (strictValidateRansimAgentsAvailability) {
+ if (numberOfCellsPerNcServer * webSocketSessions.size() < cellsToBeSimulated) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * It updates the constant values in the properties file.
+ */
+ public void loadProperties() {
+ InputStream input = null;
+ try {
+
+ input = new FileInputStream("/tmp/ransim-install/config/ransim.properties");
+ netconfConstants.load(input);
+ serverIdPrefix = netconfConstants.getProperty("serverIdPrefix");
+ numberOfCellsPerNcServer = Integer.parseInt(netconfConstants.getProperty("numberOfCellsPerNCServer"));
+ numberOfMachines = Integer.parseInt(netconfConstants.getProperty("numberOfMachines"));
+ numberOfProcessPerMc = Integer.parseInt(netconfConstants.getProperty("numberOfProcessPerMc"));
+ strictValidateRansimAgentsAvailability =
+ Boolean.parseBoolean(netconfConstants.getProperty("strictValidateRansimAgentsAvailability"));
+ maxPciValueAllowed = Long.parseLong(netconfConstants.getProperty("maxPciValueAllowed"));
+ sdnrServerIp = System.getenv("SDNR_IP");
sdnrServerPort = Integer.parseInt(System.getenv("SDNR_PORT"));
sdnrServerUserid = System.getenv("SDNR_USER");
sdnrServerPassword = System.getenv("SDNR_PASSWORD");
useCaseType = "sonUsecase";
- } catch (Exception e) {
- log.error("Properties file error", e);
- } finally {
- try {
- if (input != null) {
- input.close();
- }
- } catch (Exception ex) {
- log.error("Properties file error", ex);
- }
- }
- }
-
- public void loadGNBFunctionProperties() {
- try
- {
- sdnrServerIp = System.getenv("SDNR_IP");
+ } catch (Exception e) {
+ log.error("Properties file error", e);
+ } finally {
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (Exception ex) {
+ log.error("Properties file error", ex);
+ }
+ }
+ }
+
+ public void loadGNBFunctionProperties() {
+ try {
+ sdnrServerIp = System.getenv("SDNR_IP");
sdnrServerPort = Integer.parseInt(System.getenv("SDNR_PORT"));
sdnrServerUserid = System.getenv("SDNR_USER");
sdnrServerPassword = System.getenv("SDNR_PASSWORD");
useCaseType = "ranSlicingUsecase";
- rtricModelList = ranSliceConfigService.findAllNearRTRIC();
- for(NearRTRICModel rtricModel:rtricModelList)
- {
- List<String> gNBList = new ArrayList<>();
- for(GNBCUCPModel gNBCUCPModel : rtricModel.getgNBCUCPList())
- {
- gNBList.add(gNBCUCPModel.getgNBCUName());
- setRanNetconfServers(gNBCUCPModel.getgNBCUName());
- for(NRCellCUModel nRCellCUModel : gNBCUCPModel.getCellCUList())
- {
- if(nRCellCUModel.getpLMNInfoList().isEmpty())
- {
- org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser();
- try (FileReader reader = new FileReader("/tmp/ransim-install/config/gNBCUConfig.json")) {
- // Read JSON file
- Object obj = jsonParser.parse(reader);
- JSONArray List = (JSONArray) obj;
- for (int i = 0; i < List.size(); i++) {
- JSONObject gNB = (JSONObject) List.get(i);
- String gNBCUName = (String) gNB.get("gNBCUName");
- Long gNBId = (Long) gNB.get("gNBId");
- Long gNBIdLength = (Long) gNB.get("gNBIdLength");
- String pLMNId = (String) gNB.get("pLMNId");
- String nFType = (String) gNB.get("nFType");
- Long nearRTRICId = (Long) gNB.get("nearRTRICId");
- String cellListVar = (String) gNB.get("cellCUList").toString();
- Object cellListObj = jsonParser.parse(cellListVar);
- JSONArray cellList = (JSONArray) cellListObj;
- List<NRCellCUModel> nRCellCUModelList = new ArrayList<NRCellCUModel>();
- for (int j = 0; j < cellList.size(); j++) {
- JSONObject cell = (JSONObject) cellList.get(j);
- Long cellLocalId = (Long) cell.get("cellLocalId");
- String plmVar = (String) cell.get("pLMNInfoList").toString();
- Object pmlVarObj = jsonParser.parse(plmVar);
- JSONArray pmlList = (JSONArray) pmlVarObj;
- List<PLMNInfoModel> plmnInfoModelList = new ArrayList<PLMNInfoModel>();
- for (int k = 0; k < pmlList.size(); k++) {
- JSONObject pml = (JSONObject) pmlList.get(k);
- String pLMNid = (String) pml.get("pLMNId");
- JSONObject sNSSAI = (JSONObject) pml.get("sNSSAI");
- String sNssai = (String) sNSSAI.get("sNSSAI");
- String status = (String) sNSSAI.get("status");
- JSONObject configData = (JSONObject) sNSSAI.get("configData");
- Long maxNumberOfConns = (Long) configData.get("maxNumberOfConns");
- NSSAIConfig configDataObj = new NSSAIConfig();
- configDataObj.setMaxNumberOfConns(maxNumberOfConns.intValue());
- NSSAIData nssaiData = new NSSAIData();
- nssaiData.setsNSSAI(sNssai);
- nssaiData.setStatus(status);
- nssaiData.setConfigData(configDataObj);
- PLMNInfoModel plmnInfoModel = new PLMNInfoModel();
- plmnInfoModel.setpLMNId(pLMNid);
- plmnInfoModel.setsNSSAI(nssaiData);
- plmnInfoModelList.add(plmnInfoModel);
- }
- NRCellCUModel nrCellCUModel = new NRCellCUModel();
- nrCellCUModel.setCellLocalId(cellLocalId.intValue());
- nrCellCUModel.setpLMNInfoList(plmnInfoModelList);
- nRCellCUModelList.add(nrCellCUModel);
- }
- GNBCUCPModel gNBModel = new GNBCUCPModel();
- gNBModel.setgNBCUName(gNBCUName);
- gNBModel.setgNBId(gNBId.intValue());
- gNBModel.setgNBIdLength(gNBIdLength.intValue());
- gNBModel.setpLMNId(pLMNId);
- gNBModel.setnFType(nFType);
- gNBModel.setNearRTRICId(nearRTRICId.intValue());
- gNBModel.setCellCUList(nRCellCUModelList);
- ranSliceConfigService.saveGNBCUCP(gNBModel);
- }
- } catch (Exception e) {
- log.error("Properties file error", e);
- }
- }
- }
- }
- for(GNBCUUPModel gNBCUUPModel:rtricModel.getgNBCUUPList())
- {
- gNBList.add(gNBCUUPModel.getgNBCUUPId().toString());
- setRanNetconfServers(gNBCUUPModel.getgNBCUUPId().toString());
+ rtricModelList = ranSliceConfigService.findAllNearRTRIC();
+ for (NearRTRICModel rtricModel : rtricModelList) {
+ List<String> gNBList = new ArrayList<>();
+ for (GNBCUCPModel gNBCUCPModel : rtricModel.getgNBCUCPList()) {
+ gNBList.add(gNBCUCPModel.getgNBCUName());
+ setRanNetconfServers(gNBCUCPModel.getgNBCUName());
+ for (NRCellCUModel nRCellCUModel : gNBCUCPModel.getCellCUList()) {
+ if (nRCellCUModel.getpLMNInfoList().isEmpty()) {
+ org.json.simple.parser.JSONParser jsonParser = new org.json.simple.parser.JSONParser();
+ try (FileReader reader = new FileReader("/tmp/ransim-install/config/gNBCUConfig.json")) {
+ // Read JSON file
+ Object obj = jsonParser.parse(reader);
+ JSONArray List = (JSONArray) obj;
+ for (int i = 0; i < List.size(); i++) {
+ JSONObject gNB = (JSONObject) List.get(i);
+ String gNBCUName = (String) gNB.get("gNBCUName");
+ Long gNBId = (Long) gNB.get("gNBId");
+ Long gNBIdLength = (Long) gNB.get("gNBIdLength");
+ String pLMNId = (String) gNB.get("pLMNId");
+ String nFType = (String) gNB.get("nFType");
+ Long nearRTRICId = (Long) gNB.get("nearRTRICId");
+ String cellListVar = (String) gNB.get("cellCUList").toString();
+ Object cellListObj = jsonParser.parse(cellListVar);
+ JSONArray cellList = (JSONArray) cellListObj;
+ List<NRCellCUModel> nRCellCUModelList = new ArrayList<NRCellCUModel>();
+ for (int j = 0; j < cellList.size(); j++) {
+ JSONObject cell = (JSONObject) cellList.get(j);
+ Long cellLocalId = (Long) cell.get("cellLocalId");
+ String plmVar = (String) cell.get("pLMNInfoList").toString();
+ Object pmlVarObj = jsonParser.parse(plmVar);
+ JSONArray pmlList = (JSONArray) pmlVarObj;
+ List<PLMNInfoModel> plmnInfoModelList = new ArrayList<PLMNInfoModel>();
+ for (int k = 0; k < pmlList.size(); k++) {
+ JSONObject pml = (JSONObject) pmlList.get(k);
+ String pLMNid = (String) pml.get("pLMNId");
+ JSONObject sNSSAI = (JSONObject) pml.get("sNSSAI");
+ String sNssai = (String) sNSSAI.get("sNSSAI");
+ String status = (String) sNSSAI.get("status");
+ JSONObject configData = (JSONObject) sNSSAI.get("configData");
+ Long maxNumberOfConns = (Long) configData.get("maxNumberOfConns");
+ NSSAIConfig configDataObj = new NSSAIConfig();
+ configDataObj.setMaxNumberOfConns(maxNumberOfConns.intValue());
+ NSSAIData nssaiData = new NSSAIData();
+ nssaiData.setsNSSAI(sNssai);
+ nssaiData.setStatus(status);
+ nssaiData.setConfigData(configDataObj);
+ PLMNInfoModel plmnInfoModel = new PLMNInfoModel();
+ plmnInfoModel.setpLMNId(pLMNid);
+ plmnInfoModel.setsNSSAI(nssaiData);
+ plmnInfoModelList.add(plmnInfoModel);
+ }
+ NRCellCUModel nrCellCUModel = new NRCellCUModel();
+ nrCellCUModel.setCellLocalId(cellLocalId.intValue());
+ nrCellCUModel.setpLMNInfoList(plmnInfoModelList);
+ nRCellCUModelList.add(nrCellCUModel);
+ }
+ GNBCUCPModel gNBModel = new GNBCUCPModel();
+ gNBModel.setgNBCUName(gNBCUName);
+ gNBModel.setgNBId(gNBId.intValue());
+ gNBModel.setgNBIdLength(gNBIdLength.intValue());
+ gNBModel.setpLMNId(pLMNId);
+ gNBModel.setnFType(nFType);
+ gNBModel.setNearRTRICId(nearRTRICId.intValue());
+ gNBModel.setCellCUList(nRCellCUModelList);
+ ranSliceConfigService.saveGNBCUCP(gNBModel);
+ }
+ } catch (Exception e) {
+ log.error("Properties file error", e);
+ }
+ }
+ }
+ }
+ for (GNBCUUPModel gNBCUUPModel : rtricModel.getgNBCUUPList()) {
+ gNBList.add(gNBCUUPModel.getgNBCUUPId().toString());
+ setRanNetconfServers(gNBCUUPModel.getgNBCUUPId().toString());
+ }
+ for (GNBDUModel gNBDUModel : rtricModel.getgNBDUList()) {
+ gNBList.add(gNBDUModel.getgNBDUId().toString());
+ setRanNetconfServers(gNBDUModel.getgNBDUId().toString());
+ }
+ unassignedrtRicIds.add(rtricModel.getNearRTRICId().toString());
+ ricIdFunctionMapping.put(rtricModel.getNearRTRICId().toString(), gNBList);
+ setRanNetconfServers(rtricModel.getNearRTRICId().toString());
}
- for(GNBDUModel gNBDUModel:rtricModel.getgNBDUList())
- {
- gNBList.add(gNBDUModel.getgNBDUId().toString());
- setRanNetconfServers(gNBDUModel.getgNBDUId().toString());
+ } catch (Exception e) {
+ log.error("Properties file error", e);
+ }
+ }
+
+ public void setRanNetconfServers(String serverId) {
+ try {
+
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ if (server == null) {
+ server = new NetconfServers();
+ server.setServerId(serverId);
}
- unassignedrtRicIds.add(rtricModel.getNearRTRICId().toString());
- ricIdFunctionMapping.put(rtricModel.getNearRTRICId().toString(),gNBList);
- setRanNetconfServers(rtricModel.getNearRTRICId().toString());
- }
- }
- catch(Exception e){
- log.error("Properties file error", e);
- }
- }
-
- public void setRanNetconfServers(String serverId)
- {
- try {
-
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- if (server == null) {
- server = new NetconfServers();
- server.setServerId(serverId);
- }
- ransimRepo.mergeNetconfServers(server);
-
- } catch (Exception eu) {
- log.error("setNetconfServers Function Error", eu);
-
- }
- }
-
-
- /**
- * The function adds the cell(with nodeId passed as an argument) to its netconf
- * server list if the netconf server already exists. Else it will create a new
- * netconf server in the NetconfServers Table and the cell into its list.
- *
- * @param nodeId node Id of the cell
- */
- public void setNetconfServers(String nodeId) {
-
- CellDetails currentCell = ransimRepo.getCellDetail(nodeId);
-
- Set<CellDetails> newList = new HashSet<CellDetails>();
- try {
- if (currentCell != null) {
- NetconfServers server = ransimRepo.getNetconfServer(currentCell.getServerId());
-
- if (server == null) {
-
- server = new NetconfServers();
- server.setServerId(currentCell.getServerId());
- } else {
- newList.addAll(server.getCells());
- }
-
- newList.add(currentCell);
- server.setCells(newList);
- log.info("setNetconfServers: nodeId: " + nodeId + ", X:" + currentCell.getGridX() + ", Y:"
- + currentCell.getGridY() + ", ip: " + server.getIp() + ", portNum: " + server.getNetconfPort()
- + ", serverId:" + currentCell.getServerId());
-
- ransimRepo.mergeNetconfServers(server);
-
- }
-
- } catch (Exception eu) {
- log.error("setNetconfServers Function Error", eu);
-
- }
- }
-
- /**
- * generateClusterFromFile()
- *
- * @throws IOException
- */
- public void generateClusterFromFile() throws IOException {
-
- log.debug("Inside generateClusterFromFile");
- File dumpFile = null;
- String cellDetailsString = "";
-
- dumpFile = new File(fileBasePath+dumpFileName);
-
- BufferedReader br = null;
- try {
- log.debug("Reading dump file");
- br = new BufferedReader(new FileReader(dumpFile));
-
- StringBuilder sb = new StringBuilder();
- String line = br.readLine();
- while (line != null) {
- sb.append(line);
- sb.append("\n");
- line = br.readLine();
- }
- cellDetailsString = sb.toString();
-
- TopologyDump dumpTopo = new Gson().fromJson(cellDetailsString, TopologyDump.class);
- CellDetails cellsDb = new CellDetails();
-
- log.info("dumpTopo.getCellList().size():" + dumpTopo.getCellList().size());
- for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
- Gson g = new Gson();
- String pnt = g.toJson(dumpTopo.getCellList().get(i));
- log.info("Creating Cell:" + pnt);
- log.info("Creating Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId());
-
- cellsDb = new CellDetails();
- cellsDb.setNodeId(dumpTopo.getCellList().get(i).getCell().getNodeId());
- cellsDb.setPhysicalCellId(dumpTopo.getCellList().get(i).getCell().getPhysicalCellId());
- cellsDb.setLongitude(dumpTopo.getCellList().get(i).getCell().getLongitude());
- cellsDb.setLatitude(dumpTopo.getCellList().get(i).getCell().getLatitude());
- cellsDb.setServerId(dumpTopo.getCellList().get(i).getCell().getPnfName());
- if (!unassignedServerIds.contains(cellsDb.getServerId())) {
- unassignedServerIds.add(cellsDb.getServerId());
- }
- cellsDb.setNetworkId(dumpTopo.getCellList().get(i).getCell().getNetworkId());
-
- double lon = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLongitude());
- double lat = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLatitude());
-
- double xx = (lon - 0) * RansimUtilities.metersDeglon(0);
- double yy = (lat - 0) * RansimUtilities.metersDeglat(0);
-
- double rad = Math.sqrt(xx * xx + yy * yy);
-
- if (rad > 0) {
- double ct = xx / rad;
- double st = yy / rad;
- xx = rad * ((ct * Math.cos(0)) + (st * Math.sin(0)));
- yy = rad * ((st * Math.cos(0)) - (ct * Math.sin(0)));
- }
-
- cellsDb.setScreenX((float) (xx));
- cellsDb.setScreenY((float) (yy));
-
- List<String> attachedNoeds = serverIdIpNodeMapping.get(cellsDb.getServerId());
- log.info("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to "
- + cellsDb.getServerId());
- if (attachedNoeds == null) {
- attachedNoeds = new ArrayList<String>();
- }
- attachedNoeds.add(cellsDb.getNodeId());
- serverIdIpNodeMapping.put(cellsDb.getServerId(), attachedNoeds);
- if (attachedNoeds.size() > numberOfCellsPerNcServer) {
- log.warn("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to "
- + cellsDb.getServerId() + ", But it is exceeding numberOfCellsPerNcServer "
- + numberOfCellsPerNcServer);
- }
- ransimRepo.mergeCellDetails(cellsDb);
- setNetconfServers(cellsDb.getNodeId());
- }
-
- dumpSessionDetails();
-
- try {
-
- for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
-
- String cellNodeId = dumpTopo.getCellList().get(i).getCell().getNodeId();
-
- // neighbor list with the corresponding node id
- CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellNodeId);
- // cell with the corresponding nodeId
- CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId);
-
- Set<NeighborDetails> newCell = new HashSet<NeighborDetails>();
-
- if (currentCell != null) {
- if (neighborList == null) {
- neighborList = new CellNeighbor();
- neighborList.setNodeId(cellNodeId);
- }
- List<NbrDump> neighboursFromFile = dumpTopo.getCellList().get(i).getNeighbor();
- log.info("Creating Neighbor for Cell :" + cellNodeId);
- for (NbrDump a : neighboursFromFile) {
- String id = a.getNodeId().trim();
- boolean noHo = Boolean.parseBoolean(a.getBlacklisted().trim());
- CellDetails neighborCell = ransimRepo.getCellDetail(id);
- NeighborDetails neighborDetails = new NeighborDetails(
- new NeihborId(currentCell.getNodeId(), neighborCell.getNodeId()), noHo);
-
- newCell.add(neighborDetails);
- }
-
- neighborList.setNeighborList(newCell);
- ransimRepo.mergeCellNeighbor(neighborList);
- rsPciHdlr.setCollisionConfusionFromFile(cellNodeId);
-
- }
-
- }
-
- } catch (Exception e1) {
- log.error("Exception generateClusterFromFile :", e1);
- }
-
- try {
-
- long startTimeSectorNumber = System.currentTimeMillis();
- for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
-
- CellData icellData = dumpTopo.getCellList().get(i);
- CellDetails icell = ransimRepo.getCellDetail(icellData.getCell().getNodeId());
- int icount = icell.getSectorNumber();
- if (icount == 0) {
- log.info("Setting sectorNumber for Cell(i) :" + icell.getNodeId());
- int jcount = 0;
- for (int j = (i + 1); j < dumpTopo.getCellList().size(); j++) {
-
- CellData jcellData = dumpTopo.getCellList().get(j);
- if (icellData.getCell().getLatitude().equals(jcellData.getCell().getLatitude())) {
- if (icellData.getCell().getLongitude().equals(jcellData.getCell().getLongitude())) {
-
- if (icount == 0) {
- icount++;
- jcount = icount + 1;
- }
-
- CellDetails jcell = ransimRepo
- .getCellDetail(dumpTopo.getCellList().get(j).getCell().getNodeId());
-
- jcell.setSectorNumber(jcount);
- log.info("Setting sectorNumber for Cell(j) :" + jcell.getNodeId() + " icell: "
- + icell.getNodeId() + " Sector number: " + jcount);
- ransimRepo.mergeCellDetails(jcell);
- jcount++;
- if (jcount > 3) {
- break;
- }
- }
- }
- }
- icell.setSectorNumber(icount);
- ransimRepo.mergeCellDetails(icell);
- }
-
- }
-
- long endTimeSectorNumber = System.currentTimeMillis();
- log.info("Time taken for setting sector number: " + (endTimeSectorNumber - startTimeSectorNumber));
-
- } catch (Exception e3) {
- log.error("Exception generateClusterFromFile :", e3);
- }
-
- } catch (Exception e) {
- log.error("Exception generateClusterFromFile :", e);
-
- } finally {
- br.close();
- }
- }
-
- /**
- * The function deletes the cell from the database with the nodeId passed in the
- * arguments. It removes the cell from its neighbor's neighbor list and the
- * netconf server list.
- *
- * @param nodeId node Id of the cell to be deleted.
- * @return returns success or failure message
- */
- public String deleteCellFunction(String nodeId) {
- String result = "failure node dosent exist";
- log.info("deleteCellFunction called with nodeId :" + nodeId);
-
- try {
- CellDetails deleteCelldetail = ransimRepo.getCellDetail(nodeId);
-
- CellNeighbor deleteCellNeighbor = ransimRepo.getCellNeighbor(nodeId);
-
- if (deleteCelldetail != null) {
- if (deleteCellNeighbor != null) {
- List<CellNeighbor> cellNeighborList = ransimRepo.getCellNeighborList();
- for (CellNeighbor cellNeighbors : cellNeighborList) {
- Set<NeighborDetails> currentCellNeighbors = new HashSet<NeighborDetails>(
- cellNeighbors.getNeighborList());
-
- NeihborId deleteNeighborDetail = new NeihborId(cellNeighbors.getNodeId(),
- deleteCelldetail.getNodeId());
-
- if (currentCellNeighbors.contains(deleteNeighborDetail)) {
- log.info("Deleted Cell is Neighbor of NodeId : " + cellNeighbors.getNodeId());
- currentCellNeighbors.remove(deleteNeighborDetail);
- cellNeighbors.setNeighborList(currentCellNeighbors);
- ransimRepo.mergeCellNeighbor(cellNeighbors);
- }
- }
-
- deleteCellNeighbor.getNeighborList().clear();
- ransimRepo.deleteCellNeighbor(deleteCellNeighbor);
- }
-
- ransimRepo.deleteCellDetails(deleteCelldetail);
- result = "cell has been deleted from the database";
- } else {
- log.info("cell id does not exist");
- result = "failure nodeId dosent exist";
- return result;
- }
- } catch (Exception eu) {
- log.error("Exception deleteCellFunction :", eu);
- result = "Exception in function";
- }
- return result;
- }
-
- /**
- * Send configuration details to all the netconf server.
- */
- public void sendInitialConfigAll() {
- try {
- dumpSessionDetails();
- List<NetconfServers> ncServers = ransimRepo.getNetconfServersList();
- for (NetconfServers netconfServers : ncServers) {
- String ipPortKey = serverIdIpPortMapping.get(netconfServers.getServerId());
- if (ipPortKey == null || ipPortKey.trim().equals("")) {
- log.info("No client for " + netconfServers.getServerId());
- for (String ipPortKeyStr : webSocketSessions.keySet()) {
- if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) {
- serverIdIpPortMapping.put(netconfServers.getServerId(), ipPortKeyStr);
- ipPortKey = ipPortKeyStr;
- break;
- }
- }
- }
- if (ipPortKey != null && !ipPortKey.trim().equals("")) {
- Session clSess = webSocketSessions.get(ipPortKey);
- if (clSess != null) {
- sendInitialConfig(netconfServers.getServerId());
- try {
- String[] agentDetails = ipPortKey.split(":");
- new RestClient().sendMountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp,
- sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid,
- sdnrServerPassword);
- } catch (Exception ex1) {
- log.info("Ignoring exception", ex1);
- }
-
- } else {
- log.info("No session for " + ipPortKey);
- }
- }
- }
- } catch (Exception eu) {
- log.error("Exception:", eu);
- }
- }
-
- public void sendRanInitialConfigAll() {
- try {
- List<NearRTRICModel> ncServers = ranSliceConfigService.findAllNearRTRIC();
- for (NearRTRICModel netconfServers : ncServers) {
- String ipPortKey = serverIdIpPortMapping.get(netconfServers.getNearRTRICId());
- if (ipPortKey == null || ipPortKey.trim().equals("")) {
- log.info("No client for " + netconfServers.getNearRTRICId());
- for (String ipPortKeyStr : webSocketSessions.keySet()) {
- if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) {
- serverIdIpPortMapping.put(netconfServers.getNearRTRICId().toString(), ipPortKeyStr);
- ipPortKey = ipPortKeyStr;
- break;
- }
- }
- }
- if (ipPortKey != null && !ipPortKey.trim().equals("")) {
- Session clSess = webSocketSessions.get(ipPortKey);
- if (clSess != null) {
- sendRanInitialConfig(netconfServers.getNearRTRICId().toString());
- try {
- String[] agentDetails = ipPortKey.split(":");
- new RestClient().sendMountRequestToSdnr(netconfServers.getNearRTRICId().toString(), sdnrServerIp,
+ ransimRepo.mergeNetconfServers(server);
+
+ } catch (Exception eu) {
+ log.error("setNetconfServers Function Error", eu);
+
+ }
+ }
+
+ /**
+ * The function adds the cell(with nodeId passed as an argument) to its netconf
+ * server list if the netconf server already exists. Else it will create a new
+ * netconf server in the NetconfServers Table and the cell into its list.
+ *
+ * @param nodeId node Id of the cell
+ */
+ public void setNetconfServers(String nodeId) {
+
+ CellDetails currentCell = ransimRepo.getCellDetail(nodeId);
+
+ Set<CellDetails> newList = new HashSet<CellDetails>();
+ try {
+ if (currentCell != null) {
+ NetconfServers server = ransimRepo.getNetconfServer(currentCell.getServerId());
+
+ if (server == null) {
+
+ server = new NetconfServers();
+ server.setServerId(currentCell.getServerId());
+ } else {
+ newList.addAll(server.getCells());
+ }
+
+ newList.add(currentCell);
+ server.setCells(newList);
+ log.info("setNetconfServers: nodeId: " + nodeId + ", X:" + currentCell.getGridX() + ", Y:"
+ + currentCell.getGridY() + ", ip: " + server.getIp() + ", portNum: " + server.getNetconfPort()
+ + ", serverId:" + currentCell.getServerId());
+
+ ransimRepo.mergeNetconfServers(server);
+
+ }
+
+ } catch (Exception eu) {
+ log.error("setNetconfServers Function Error", eu);
+
+ }
+ }
+
+ /**
+ * generateClusterFromFile()
+ *
+ * @throws IOException
+ */
+ public void generateClusterFromFile() throws IOException {
+
+ log.debug("Inside generateClusterFromFile");
+ File dumpFile = null;
+ String cellDetailsString = "";
+
+ dumpFile = new File(fileBasePath + dumpFileName);
+
+ BufferedReader br = null;
+ try {
+ log.debug("Reading dump file");
+ br = new BufferedReader(new FileReader(dumpFile));
+
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+ while (line != null) {
+ sb.append(line);
+ sb.append("\n");
+ line = br.readLine();
+ }
+ cellDetailsString = sb.toString();
+
+ TopologyDump dumpTopo = new Gson().fromJson(cellDetailsString, TopologyDump.class);
+ CellDetails cellsDb = new CellDetails();
+
+ log.info("dumpTopo.getCellList().size():" + dumpTopo.getCellList().size());
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+ Gson g = new Gson();
+ String pnt = g.toJson(dumpTopo.getCellList().get(i));
+ log.info("Creating Cell:" + pnt);
+ log.info("Creating Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId());
+
+ cellsDb = new CellDetails();
+ cellsDb.setNodeId(dumpTopo.getCellList().get(i).getCell().getNodeId());
+ cellsDb.setPhysicalCellId(dumpTopo.getCellList().get(i).getCell().getPhysicalCellId());
+ cellsDb.setLongitude(dumpTopo.getCellList().get(i).getCell().getLongitude());
+ cellsDb.setLatitude(dumpTopo.getCellList().get(i).getCell().getLatitude());
+ cellsDb.setServerId(dumpTopo.getCellList().get(i).getCell().getPnfName());
+ if (!unassignedServerIds.contains(cellsDb.getServerId())) {
+ unassignedServerIds.add(cellsDb.getServerId());
+ }
+ cellsDb.setNetworkId(dumpTopo.getCellList().get(i).getCell().getNetworkId());
+
+ double lon = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLongitude());
+ double lat = Float.valueOf(dumpTopo.getCellList().get(i).getCell().getLatitude());
+
+ double xx = (lon - 0) * RansimUtilities.metersDeglon(0);
+ double yy = (lat - 0) * RansimUtilities.metersDeglat(0);
+
+ double rad = Math.sqrt(xx * xx + yy * yy);
+
+ if (rad > 0) {
+ double ct = xx / rad;
+ double st = yy / rad;
+ xx = rad * ((ct * Math.cos(0)) + (st * Math.sin(0)));
+ yy = rad * ((st * Math.cos(0)) - (ct * Math.sin(0)));
+ }
+
+ cellsDb.setScreenX((float) (xx));
+ cellsDb.setScreenY((float) (yy));
+
+ List<String> attachedNoeds = serverIdIpNodeMapping.get(cellsDb.getServerId());
+ log.info("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to "
+ + cellsDb.getServerId());
+ if (attachedNoeds == null) {
+ attachedNoeds = new ArrayList<String>();
+ }
+ attachedNoeds.add(cellsDb.getNodeId());
+ serverIdIpNodeMapping.put(cellsDb.getServerId(), attachedNoeds);
+ if (attachedNoeds.size() > numberOfCellsPerNcServer) {
+ log.warn("Attaching Cell:" + dumpTopo.getCellList().get(i).getCell().getNodeId() + " to "
+ + cellsDb.getServerId() + ", But it is exceeding numberOfCellsPerNcServer "
+ + numberOfCellsPerNcServer);
+ }
+ ransimRepo.mergeCellDetails(cellsDb);
+ setNetconfServers(cellsDb.getNodeId());
+ }
+
+ dumpSessionDetails();
+
+ try {
+
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+
+ String cellNodeId = dumpTopo.getCellList().get(i).getCell().getNodeId();
+
+ // neighbor list with the corresponding node id
+ CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellNodeId);
+ // cell with the corresponding nodeId
+ CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId);
+
+ Set<NeighborDetails> newCell = new HashSet<NeighborDetails>();
+
+ if (currentCell != null) {
+ if (neighborList == null) {
+ neighborList = new CellNeighbor();
+ neighborList.setNodeId(cellNodeId);
+ }
+ List<NbrDump> neighboursFromFile = dumpTopo.getCellList().get(i).getNeighbor();
+ log.info("Creating Neighbor for Cell :" + cellNodeId);
+ for (NbrDump a : neighboursFromFile) {
+ String id = a.getNodeId().trim();
+ boolean noHo = Boolean.parseBoolean(a.getBlacklisted().trim());
+ CellDetails neighborCell = ransimRepo.getCellDetail(id);
+ NeighborDetails neighborDetails = new NeighborDetails(
+ new NeihborId(currentCell.getNodeId(), neighborCell.getNodeId()), noHo);
+
+ newCell.add(neighborDetails);
+ }
+
+ neighborList.setNeighborList(newCell);
+ ransimRepo.mergeCellNeighbor(neighborList);
+ rsPciHdlr.setCollisionConfusionFromFile(cellNodeId);
+
+ }
+
+ }
+
+ } catch (Exception e1) {
+ log.error("Exception generateClusterFromFile :", e1);
+ }
+
+ try {
+
+ long startTimeSectorNumber = System.currentTimeMillis();
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+
+ CellData icellData = dumpTopo.getCellList().get(i);
+ CellDetails icell = ransimRepo.getCellDetail(icellData.getCell().getNodeId());
+ int icount = icell.getSectorNumber();
+ if (icount == 0) {
+ log.info("Setting sectorNumber for Cell(i) :" + icell.getNodeId());
+ int jcount = 0;
+ for (int j = (i + 1); j < dumpTopo.getCellList().size(); j++) {
+
+ CellData jcellData = dumpTopo.getCellList().get(j);
+ if (icellData.getCell().getLatitude().equals(jcellData.getCell().getLatitude())) {
+ if (icellData.getCell().getLongitude().equals(jcellData.getCell().getLongitude())) {
+
+ if (icount == 0) {
+ icount++;
+ jcount = icount + 1;
+ }
+
+ CellDetails jcell = ransimRepo
+ .getCellDetail(dumpTopo.getCellList().get(j).getCell().getNodeId());
+
+ jcell.setSectorNumber(jcount);
+ log.info("Setting sectorNumber for Cell(j) :" + jcell.getNodeId() + " icell: "
+ + icell.getNodeId() + " Sector number: " + jcount);
+ ransimRepo.mergeCellDetails(jcell);
+ jcount++;
+ if (jcount > 3) {
+ break;
+ }
+ }
+ }
+ }
+ icell.setSectorNumber(icount);
+ ransimRepo.mergeCellDetails(icell);
+ }
+
+ }
+
+ long endTimeSectorNumber = System.currentTimeMillis();
+ log.info("Time taken for setting sector number: " + (endTimeSectorNumber - startTimeSectorNumber));
+
+ } catch (Exception e3) {
+ log.error("Exception generateClusterFromFile :", e3);
+ }
+
+ } catch (Exception e) {
+ log.error("Exception generateClusterFromFile :", e);
+
+ } finally {
+ br.close();
+ }
+ }
+
+ /**
+ * The function deletes the cell from the database with the nodeId passed in the
+ * arguments. It removes the cell from its neighbor's neighbor list and the
+ * netconf server list.
+ *
+ * @param nodeId node Id of the cell to be deleted.
+ * @return returns success or failure message
+ */
+ public String deleteCellFunction(String nodeId) {
+ String result = "failure node dosent exist";
+ log.info("deleteCellFunction called with nodeId :" + nodeId);
+
+ try {
+ CellDetails deleteCelldetail = ransimRepo.getCellDetail(nodeId);
+
+ CellNeighbor deleteCellNeighbor = ransimRepo.getCellNeighbor(nodeId);
+
+ if (deleteCelldetail != null) {
+ if (deleteCellNeighbor != null) {
+ List<CellNeighbor> cellNeighborList = ransimRepo.getCellNeighborList();
+ for (CellNeighbor cellNeighbors : cellNeighborList) {
+ Set<NeighborDetails> currentCellNeighbors =
+ new HashSet<NeighborDetails>(cellNeighbors.getNeighborList());
+
+ NeihborId deleteNeighborDetail =
+ new NeihborId(cellNeighbors.getNodeId(), deleteCelldetail.getNodeId());
+
+ if (currentCellNeighbors.contains(deleteNeighborDetail)) {
+ log.info("Deleted Cell is Neighbor of NodeId : " + cellNeighbors.getNodeId());
+ currentCellNeighbors.remove(deleteNeighborDetail);
+ cellNeighbors.setNeighborList(currentCellNeighbors);
+ ransimRepo.mergeCellNeighbor(cellNeighbors);
+ }
+ }
+
+ deleteCellNeighbor.getNeighborList().clear();
+ ransimRepo.deleteCellNeighbor(deleteCellNeighbor);
+ }
+
+ ransimRepo.deleteCellDetails(deleteCelldetail);
+ result = "cell has been deleted from the database";
+ } else {
+ log.info("cell id does not exist");
+ result = "failure nodeId dosent exist";
+ return result;
+ }
+ } catch (Exception eu) {
+ log.error("Exception deleteCellFunction :", eu);
+ result = "Exception in function";
+ }
+ return result;
+ }
+
+ /**
+ * Send configuration details to all the netconf server.
+ */
+ public void sendInitialConfigAll() {
+ try {
+ dumpSessionDetails();
+ List<NetconfServers> ncServers = ransimRepo.getNetconfServersList();
+ for (NetconfServers netconfServers : ncServers) {
+ String ipPortKey = serverIdIpPortMapping.get(netconfServers.getServerId());
+ if (ipPortKey == null || ipPortKey.trim().equals("")) {
+ log.info("No client for " + netconfServers.getServerId());
+ for (String ipPortKeyStr : webSocketSessions.keySet()) {
+ if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) {
+ serverIdIpPortMapping.put(netconfServers.getServerId(), ipPortKeyStr);
+ ipPortKey = ipPortKeyStr;
+ break;
+ }
+ }
+ }
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ sendInitialConfig(netconfServers.getServerId());
+ try {
+ String[] agentDetails = ipPortKey.split(":");
+ new RestClient().sendMountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp,
sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid,
sdnrServerPassword);
- } catch (Exception ex1) {
- log.info("Ignoring exception", ex1);
- }
-
- } else {
- log.info("No session for " + ipPortKey);
- }
- }
- }
- } catch (Exception eu) {
- log.error("Exception:", eu);
- }
+ } catch (Exception ex1) {
+ log.info("Ignoring exception", ex1);
+ }
+
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ }
+ }
+ } catch (Exception eu) {
+ log.error("Exception:", eu);
+ }
}
+ public void sendRanInitialConfigAll() {
+ try {
+ List<NearRTRICModel> ncServers = ranSliceConfigService.findAllNearRTRIC();
+ for (NearRTRICModel netconfServers : ncServers) {
+ String ipPortKey = serverIdIpPortMapping.get(netconfServers.getNearRTRICId());
+ if (ipPortKey == null || ipPortKey.trim().equals("")) {
+ log.info("No client for " + netconfServers.getNearRTRICId());
+ for (String ipPortKeyStr : webSocketSessions.keySet()) {
+ if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) {
+ serverIdIpPortMapping.put(netconfServers.getNearRTRICId().toString(), ipPortKeyStr);
+ ipPortKey = ipPortKeyStr;
+ break;
+ }
+ }
+ }
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ sendRanInitialConfig(netconfServers.getNearRTRICId().toString());
+ try {
+ String[] agentDetails = ipPortKey.split(":");
+ new RestClient().sendMountRequestToSdnr(netconfServers.getNearRTRICId().toString(),
+ sdnrServerIp, sdnrServerPort, agentDetails[0], agentDetails[1], sdnrServerUserid,
+ sdnrServerPassword);
+ } catch (Exception ex1) {
+ log.info("Ignoring exception", ex1);
+ }
+
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ }
+ }
+ } catch (Exception eu) {
+ log.error("Exception:", eu);
+ }
+ }
- /**
- * Sends initial configuration details of the cells for a new netconf server
- * that has been started.
- *
- * @param ipPortKey ip address details of the netconf server
- */
- public void sendInitialConfigForNewAgent(String ipPortKey, String serverId) {
- try {
- dumpSessionDetails();
- if (ipPortKey != null && !ipPortKey.trim().equals("")) {
- if (serverId != null && !serverId.trim().equals("")) {
- Session clSess = webSocketSessions.get(ipPortKey);
- if (clSess != null) {
- String[] agentDetails = ipPortKey.split(":");
- sendInitialConfig(serverId);
- new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0],
+ /**
+ * Sends initial configuration details of the cells for a new netconf server
+ * that has been started.
+ *
+ * @param ipPortKey ip address details of the netconf server
+ */
+ public void sendInitialConfigForNewAgent(String ipPortKey, String serverId) {
+ try {
+ dumpSessionDetails();
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ if (serverId != null && !serverId.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ String[] agentDetails = ipPortKey.split(":");
+ sendInitialConfig(serverId);
+ new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0],
agentDetails[1], sdnrServerUserid, sdnrServerPassword);
-
- } else {
- log.info("No session for " + ipPortKey);
- }
- } else {
- log.info("No serverid for " + ipPortKey);
- }
- } else {
- log.info("Invalid ipPortKey " + ipPortKey);
- }
- } catch (Exception eu) {
- log.info("Exception:", eu);
- }
- }
-
- public void sendRanInitialConfigForNewAgent(String ipPortKey, String serverId) {
- try {
- if (ipPortKey != null && !ipPortKey.trim().equals("")) {
- if (serverId != null && !serverId.trim().equals("")) {
- Session clSess = webSocketSessions.get(ipPortKey);
- if (clSess != null) {
- String[] agentDetails = ipPortKey.split(":");
- sendRanInitialConfig(serverId);
- new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0],
+
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ } else {
+ log.info("No serverid for " + ipPortKey);
+ }
+ } else {
+ log.info("Invalid ipPortKey " + ipPortKey);
+ }
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+ }
+
+ public void sendRanInitialConfigForNewAgent(String ipPortKey, String serverId) {
+ try {
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ if (serverId != null && !serverId.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ String[] agentDetails = ipPortKey.split(":");
+ sendRanInitialConfig(serverId);
+ new RestClient().sendMountRequestToSdnr(serverId, sdnrServerIp, sdnrServerPort, agentDetails[0],
agentDetails[1], sdnrServerUserid, sdnrServerPassword);
- } else {
- log.info("No session for " + ipPortKey);
- }
- } else {
- log.info("No serverid for " + ipPortKey);
- }
- } else {
- log.info("Invalid ipPortKey " + ipPortKey);
- }
- } catch (Exception eu) {
- log.info("Exception:", eu);
- }
- }
-
- public void sendRanInitialConfig(String serverId) {
-
- try
- {
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server);
- if (server == null) {
- return;
- }
-
- for(NearRTRICModel rtRicModel:rtricModelList) {
- if(rtRicModel.getNearRTRICId().toString().equals(serverId)) {
- getInitalConfigTree(rtRicModel,serverId);
- NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(),
- server.getIp(), Integer.parseInt(server.getNetconfPort()));
-
- netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel,serverId));
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ } else {
+ log.info("No serverid for " + ipPortKey);
+ }
+ } else {
+ log.info("Invalid ipPortKey " + ipPortKey);
+ }
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+ }
+
+ public void sendRanInitialConfig(String serverId) {
+
+ try {
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server);
+ if (server == null) {
+ return;
}
- else {
- for(Map.Entry<String,List<String>> entry : ricIdFunctionMapping.entrySet()) {
- for(String value : entry.getValue()) {
- if(value.equals(serverId) && rtRicModel.getNearRTRICId().toString().equals(entry.getKey())) {
- getInitalConfigTree(rtRicModel,serverId);
- NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(),
- server.getIp(), Integer.parseInt(server.getNetconfPort()));
-
- netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel,serverId));
- }
- }
- }
- }
+
+ for (NearRTRICModel rtRicModel : rtricModelList) {
+ if (rtRicModel.getNearRTRICId().toString().equals(serverId)) {
+ getInitalConfigTree(rtRicModel, serverId);
+ NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", server.getServerId(),
+ server.getIp(), Integer.parseInt(server.getNetconfPort()));
+
+ netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel, serverId));
+ } else {
+ for (Map.Entry<String, List<String>> entry : ricIdFunctionMapping.entrySet()) {
+ for (String value : entry.getValue()) {
+ if (value.equals(serverId)
+ && rtRicModel.getNearRTRICId().toString().equals(entry.getKey())) {
+ getInitalConfigTree(rtRicModel, serverId);
+ NetconfClient netconfClient =
+ new NetconfClient("ransim", "admin", "admin", server.getServerId(),
+ server.getIp(), Integer.parseInt(server.getNetconfPort()));
+
+ netconfClient.editConfig(netconfClient.getInitialNodeSet(rtRicModel, serverId));
+ }
+ }
+ }
+ }
+ }
+
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
}
-
- }
- catch (Exception eu) {
- log.info("Exception:", eu);
- }
-
- }
-
- /**
+
+ }
+
+ /**
* Gets the initial config tree from the database.
*/
- private void getInitalConfigTree(NearRTRICModel rtRicModel,String serverId) {
+ private void getInitalConfigTree(NearRTRICModel rtRicModel, String serverId) {
RanNetwork ranNetwork = new RanNetwork();
List<NearRTRIC> nearRTRICList = new ArrayList<>();
-
+
NearRTRIC nearRTRIC = new NearRTRIC();
nearRTRIC.setIdNearRTRIC(rtRicModel.getNearRTRICId().toString());
Attributes attributes = new Attributes();
attributes.setLocationName("Palmdale");
attributes.setgNBId(rtRicModel.getgNBId().toString());
nearRTRIC.setAttributes(attributes);
-
+
List<GNBCUUPFunction> gNBCUUPFunctionList = new ArrayList<>();
- for(GNBCUUPModel gNBCUUPModel:rtRicModel.getgNBCUUPList())
- {
- if(gNBCUUPModel.getgNBCUUPId().toString().equals(serverId) || rtRicModel.getNearRTRICId().toString().equals(serverId))
- {
- GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction();
- Attributes cUUPattributes = new Attributes();
- cUUPattributes.setgNBCUUPId(gNBCUUPModel.getgNBCUUPId().toString());
- gNBCUUPFunction.setAttributes(cUUPattributes);
- gNBCUUPFunction.setIdGNBCUUPFunction(gNBCUUPModel.getgNBCUUPId().toString());
- gNBCUUPFunctionList.add(gNBCUUPFunction);
- }
+ for (GNBCUUPModel gNBCUUPModel : rtRicModel.getgNBCUUPList()) {
+ if (gNBCUUPModel.getgNBCUUPId().toString().equals(serverId)
+ || rtRicModel.getNearRTRICId().toString().equals(serverId)) {
+ GNBCUUPFunction gNBCUUPFunction = new GNBCUUPFunction();
+ Attributes cUUPattributes = new Attributes();
+ cUUPattributes.setgNBCUUPId(gNBCUUPModel.getgNBCUUPId().toString());
+ gNBCUUPFunction.setAttributes(cUUPattributes);
+ gNBCUUPFunction.setIdGNBCUUPFunction(gNBCUUPModel.getgNBCUUPId().toString());
+ gNBCUUPFunctionList.add(gNBCUUPFunction);
+ }
}
List<GNBDUFunction> gNBDUFunctionList = new ArrayList<>();
- for(GNBDUModel gNBDUModel:rtRicModel.getgNBDUList())
- {
- if(gNBDUModel.getgNBDUId().toString().equals(serverId) || rtRicModel.getNearRTRICId().toString().equals(serverId))
- {
- GNBDUFunction gNBDUFunction= new GNBDUFunction();
- Attributes dUattributes = new Attributes();
- dUattributes.setgNBId(gNBDUModel.getgNBId().toString());
- gNBDUFunction.setAttributes(dUattributes);
- gNBDUFunction.setIdGNBDUFunction(gNBDUModel.getgNBDUId().toString());
- List<NRCellDU> nRCellDUList = new ArrayList<>();
- for(NRCellDUModel nRCellDUModel : gNBDUModel.getCellDUList())
- {
- NRCellDU nRCellDU = new NRCellDU();
- Attributes nRCellDUattributes = new Attributes();
- nRCellDUattributes.setOperationalState(nRCellDUModel.getOperationalState());
- nRCellDUattributes.setCellState(nRCellDUModel.getCellState());
- nRCellDU.setAttributes(nRCellDUattributes);
- nRCellDU.setIdNRCellDU(nRCellDUModel.getCellLocalId().toString());
- nRCellDUList.add(nRCellDU);
- }
- gNBDUFunction.setnRCellDU(nRCellDUList);
- gNBDUFunctionList.add(gNBDUFunction);
+ for (GNBDUModel gNBDUModel : rtRicModel.getgNBDUList()) {
+ if (gNBDUModel.getgNBDUId().toString().equals(serverId)
+ || rtRicModel.getNearRTRICId().toString().equals(serverId)) {
+ GNBDUFunction gNBDUFunction = new GNBDUFunction();
+ Attributes dUattributes = new Attributes();
+ dUattributes.setgNBId(gNBDUModel.getgNBId().toString());
+ gNBDUFunction.setAttributes(dUattributes);
+ gNBDUFunction.setIdGNBDUFunction(gNBDUModel.getgNBDUId().toString());
+ List<NRCellDU> nRCellDUList = new ArrayList<>();
+ for (NRCellDUModel nRCellDUModel : gNBDUModel.getCellDUList()) {
+ NRCellDU nRCellDU = new NRCellDU();
+ Attributes nRCellDUattributes = new Attributes();
+ nRCellDUattributes.setOperationalState(nRCellDUModel.getOperationalState());
+ nRCellDUattributes.setCellState(nRCellDUModel.getCellState());
+ nRCellDU.setAttributes(nRCellDUattributes);
+ nRCellDU.setIdNRCellDU(nRCellDUModel.getCellLocalId().toString());
+ nRCellDUList.add(nRCellDU);
+ }
+ gNBDUFunction.setnRCellDU(nRCellDUList);
+ gNBDUFunctionList.add(gNBDUFunction);
+ }
}
- }
nearRTRIC.setgNBDUFunction(gNBDUFunctionList);
nearRTRIC.setgNBCUUPFunction(gNBCUUPFunctionList);
nearRTRICList.add(nearRTRIC);
@@ -1082,114 +1061,113 @@ public class RansimControllerServices {
String ipPortKey = serverIdIpPortMapping.get(serverId);
log.info("sendInitialConfig: ipPortKey:" + ipPortKey);
-
- Gson gson = new Gson();
- String jsonStr = gson.toJson(ranNetwork);
+
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(ranNetwork);
+ log.info("ConfigTopologyMessage: " + jsonStr);
+ Session session = webSocketSessions.get(ipPortKey);
+ RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, session);
+ }
+
+ /**
+ * To send the initial configration to the netconf server.
+ *
+ * @param serverId ip address details of the netconf server
+ */
+ public void sendInitialConfig(String serverId) {
+
+ try {
+ NetconfServers server = ransimRepo.getNetconfServer(serverId);
+ log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server);
+ if (server == null) {
+ return;
+ }
+
+ String ipPortKey = serverIdIpPortMapping.get(serverId);
+
+ log.info("sendInitialConfig: ipPortKey:" + ipPortKey);
+
+ List<CellDetails> cellList = new ArrayList<CellDetails>(server.getCells());
+
+ List<Topology> config = new ArrayList<Topology>();
+
+ for (int i = 0; i < server.getCells().size(); i++) {
+ Topology cell = new Topology();
+ CellDetails currentCell = ransimRepo.getCellDetail(cellList.get(i).getNodeId());
+ CellNeighbor neighbor = ransimRepo.getCellNeighbor(cellList.get(i).getNodeId());
+
+ cell.setCellId("" + currentCell.getNodeId());
+ cell.setPciId(currentCell.getPhysicalCellId());
+ cell.setPnfName(serverId);
+
+ List<Neighbor> nbrList = new ArrayList<Neighbor>();
+ Set<NeighborDetails> nbrsDet = neighbor.getNeighborList();
+ for (NeighborDetails cellDetails : nbrsDet) {
+ Neighbor nbr = new Neighbor();
+ CellDetails nbrCell = ransimRepo.getCellDetail(cellDetails.getNeigbor().getNeighborCell());
+ nbr.setNodeId(nbrCell.getNodeId());
+ nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
+ nbr.setPnfName(nbrCell.getServerId());
+ nbr.setServerId(nbrCell.getServerId());
+ nbr.setPlmnId(nbrCell.getNetworkId());
+ nbr.setBlacklisted(cellDetails.isBlacklisted());
+ nbrList.add(nbr);
+ }
+ cell.setNeighborList(nbrList);
+ config.add(i, cell);
+ }
+
+ SetConfigTopology topo = new SetConfigTopology();
+
+ topo.setServerId(server.getServerId());
+ String uuid = globalNcServerUuidMap.get(server.getServerId());
+ if (uuid == null) {
+ uuid = getUuid();
+ globalNcServerUuidMap.put(server.getServerId(), uuid);
+ }
+ topo.setUuid(uuid);
+
+ topo.setTopology(config);
+
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(topo);
log.info("ConfigTopologyMessage: " + jsonStr);
- Session session = webSocketSessions.get(ipPortKey);
- RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, session);
+ Session clSess = webSocketSessions.get(ipPortKey);
+ Thread.sleep(10000);
+ RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, clSess);
+
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+
}
+ private static String getUuid() {
+ return UUID.randomUUID().toString();
+ }
- /**
- * To send the initial configration to the netconf server.
- *
- * @param serverId ip address details of the netconf server
- */
- public void sendInitialConfig(String serverId) {
-
- try {
- NetconfServers server = ransimRepo.getNetconfServer(serverId);
- log.info("sendInitialConfig: serverId:" + serverId + ", server:" + server);
- if (server == null) {
- return;
- }
-
- String ipPortKey = serverIdIpPortMapping.get(serverId);
-
- log.info("sendInitialConfig: ipPortKey:" + ipPortKey);
-
- List<CellDetails> cellList = new ArrayList<CellDetails>(server.getCells());
-
- List<Topology> config = new ArrayList<Topology>();
-
- for (int i = 0; i < server.getCells().size(); i++) {
- Topology cell = new Topology();
- CellDetails currentCell = ransimRepo.getCellDetail(cellList.get(i).getNodeId());
- CellNeighbor neighbor = ransimRepo.getCellNeighbor(cellList.get(i).getNodeId());
-
- cell.setCellId("" + currentCell.getNodeId());
- cell.setPciId(currentCell.getPhysicalCellId());
- cell.setPnfName(serverId);
-
- List<Neighbor> nbrList = new ArrayList<Neighbor>();
- Set<NeighborDetails> nbrsDet = neighbor.getNeighborList();
- for (NeighborDetails cellDetails : nbrsDet) {
- Neighbor nbr = new Neighbor();
- CellDetails nbrCell = ransimRepo.getCellDetail(cellDetails.getNeigbor().getNeighborCell());
- nbr.setNodeId(nbrCell.getNodeId());
- nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
- nbr.setPnfName(nbrCell.getServerId());
- nbr.setServerId(nbrCell.getServerId());
- nbr.setPlmnId(nbrCell.getNetworkId());
- nbr.setBlacklisted(cellDetails.isBlacklisted());
- nbrList.add(nbr);
- }
- cell.setNeighborList(nbrList);
- config.add(i, cell);
- }
-
- SetConfigTopology topo = new SetConfigTopology();
-
- topo.setServerId(server.getServerId());
- String uuid = globalNcServerUuidMap.get(server.getServerId());
- if (uuid == null) {
- uuid = getUuid();
- globalNcServerUuidMap.put(server.getServerId(), uuid);
- }
- topo.setUuid(uuid);
-
- topo.setTopology(config);
-
- Gson gson = new Gson();
- String jsonStr = gson.toJson(topo);
- log.info("ConfigTopologyMessage: " + jsonStr);
- Session clSess = webSocketSessions.get(ipPortKey);
- Thread.sleep(10000);
- RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, clSess);
-
- } catch (Exception eu) {
- log.info("Exception:", eu);
- }
-
- }
-
- private static String getUuid() {
- return UUID.randomUUID().toString();
- }
-
- /**
- * The function alters the database information based on the modifications made
- * in the SDNR.
- *
- * @param message message received from the SDNR
- * @param session sends the session details
- * @param ipPort ip address of the netconf server
- */
- public void handleModifyPciFromSdnr(String message, Session session, String ipPort) {
- log.info("handleModifyPciFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
- ModifyPci modifyPci = new Gson().fromJson(message, ModifyPci.class);
- log.info("handleModifyPciFromSDNR: modifyPci:" + modifyPci.getCellId() + "; pci: " + modifyPci.getPciId());
- String source = "Netconf";
- CellDetails cd = ransimRepo.getCellDetail(modifyPci.getCellId());
- long pci = cd.getPhysicalCellId();
- cd.setPhysicalCellId(modifyPci.getPciId());
- ransimRepo.mergeCellDetails(cd);
- rsPciHdlr.updatePciOperationsTable(modifyPci.getCellId(), source, pci, modifyPci.getPciId());
- }
-
- public void handleRTRICConfigFromSdnr(String message, Session session, String ipPort) {
- log.info("handleReconfigureRTRICFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
+ /**
+ * The function alters the database information based on the modifications made
+ * in the SDNR.
+ *
+ * @param message message received from the SDNR
+ * @param session sends the session details
+ * @param ipPort ip address of the netconf server
+ */
+ public void handleModifyPciFromSdnr(String message, Session session, String ipPort) {
+ log.info("handleModifyPciFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
+ ModifyPci modifyPci = new Gson().fromJson(message, ModifyPci.class);
+ log.info("handleModifyPciFromSDNR: modifyPci:" + modifyPci.getCellId() + "; pci: " + modifyPci.getPciId());
+ String source = "Netconf";
+ CellDetails cd = ransimRepo.getCellDetail(modifyPci.getCellId());
+ long pci = cd.getPhysicalCellId();
+ cd.setPhysicalCellId(modifyPci.getPciId());
+ ransimRepo.mergeCellDetails(cd);
+ rsPciHdlr.updatePciOperationsTable(modifyPci.getCellId(), source, pci, modifyPci.getPciId());
+ }
+
+ public void handleRTRICConfigFromSdnr(String message, Session session, String ipPort) {
+ log.info("handleReconfigureRTRICFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
ConfigPLMNInfo configPLMNInfo = new Gson().fromJson(message, ConfigPLMNInfo.class);
log.info("handleReconfigureRTRICFromSDNR:" + configPLMNInfo.getSNSSAI());
List<GNBDUModel> gNBDUModelList = new ArrayList<>();
@@ -1197,331 +1175,327 @@ public class RansimControllerServices {
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
try {
- RestTemplate restTemplate = new RestTemplate();
- ResponseEntity<List<GNBDUModel>> response = restTemplate.exchange("http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list"+configPLMNInfo.getSNSSAI().get(0), HttpMethod.GET, requestEntity,
- new ParameterizedTypeReference<List<GNBDUModel>>() {
- });
- gNBDUModelList = response.getBody();
- }
- catch (Exception e) {
- log.info("Exception:", e);
+ RestTemplate restTemplate = new RestTemplate();
+ ResponseEntity<List<GNBDUModel>> response = restTemplate.exchange(
+ "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list"
+ + configPLMNInfo.getSNSSAI().get(0),
+ HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<GNBDUModel>>() {});
+ gNBDUModelList = response.getBody();
+ } catch (Exception e) {
+ log.info("Exception:", e);
}
- for(GNBDUModel gNBDUModel :gNBDUModelList)
- {
- String serverId = gNBDUModel.getgNBDUId().toString();
- int duCellCount = gNBDUModel.getCellDUList().size();
- for(SNSSAI sNSSAI : configPLMNInfo.getSNSSAI()) {
- for(ConfigData configData : sNSSAI.getConfigData()) {
- configData.setConfigValue((configData.getConfigValue())/duCellCount);
- }
- }
- String ipPortKey = serverIdIpPortMapping.get(serverId);
- log.info("sendConfigRTRICMessage: ipPortKey:" + ipPortKey);
-
- Gson gson = new Gson();
+ for (GNBDUModel gNBDUModel : gNBDUModelList) {
+ String serverId = gNBDUModel.getgNBDUId().toString();
+ int duCellCount = gNBDUModel.getCellDUList().size();
+ for (SNSSAI sNSSAI : configPLMNInfo.getSNSSAI()) {
+ for (ConfigData configData : sNSSAI.getConfigData()) {
+ configData.setConfigValue((configData.getConfigValue()) / duCellCount);
+ }
+ }
+ String ipPortKey = serverIdIpPortMapping.get(serverId);
+ log.info("sendConfigRTRICMessage: ipPortKey:" + ipPortKey);
+
+ Gson gson = new Gson();
String jsonStr = gson.toJson(configPLMNInfo);
log.info("ConfigRTRICMessage: " + jsonStr);
Session duSession = webSocketSessions.get(ipPortKey);
RansimWebSocketServer.sendSetReconfigureMessage(jsonStr, duSession);
}
- }
-
- public void handleRRMPolicyRatioUpdateFromSdnr(String message, Session session, String ipPort){
- log.info("handle RRMPolicy update: " + message );
- RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class);
- rrmPolicyRepository.save(rRMPolicyRatio);
- }
-
-
- public void handleRRMPolicyRatioDeleteFromSdnr(String message, Session session, String ipPort) {
- log.info("handle RRMPolicyRatio Delete: " + message);
- RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class);
- rrmPolicyRepository.delete(rRMPolicyRatio);
- }
-
- public void handlePLMNInfoUpdateFromSdnr(String message, Session session, String ipPort) {
- log.info("handle PLMNInfo update: "+message);
- List<PLMNInfo> pLMNInfoList = null;
- org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = new Gson().fromJson(message,
- org.onap.ransim.rest.api.models.PLMNInfoModel.class);
- PLMNInfo plmnInfo = new PLMNInfo();
- NSSAIConfig nSSAIConfig = new NSSAIConfig();
- nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
- org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
- sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
- sNSSAI.setStatus(plmnInfoModel.getStatus());
- sNSSAI.setConfigData(nSSAIConfig);
- plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
- plmnInfo.setsNSSAI(sNSSAI);
- try {
- if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) {
- org.onap.ransim.rest.api.models.NRCellDU nrCellDu = nRCellDURepository
- .findById(plmnInfoModel.getNrCellId()).get();
- if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) {
- pLMNInfoList = nrCellDu.getpLMNInfoList();
- } else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
- }
- pLMNInfoList.add(plmnInfo);
- nrCellDu.setpLMNInfoList(pLMNInfoList);
- nRCellDURepository.save(nrCellDu);
- } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) {
- org.onap.ransim.rest.api.models.NRCellCU nrCellCu = nRCellCURepository
- .findById(plmnInfoModel.getNrCellId()).get();
- if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) {
- pLMNInfoList = nrCellCu.getpLMNInfoList();
- } else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
- }
- pLMNInfoList.add(plmnInfo);
- nrCellCu.setpLMNInfoList(pLMNInfoList);
- nRCellCURepository.save(nrCellCu);
- } else {
- org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction = gNBCUUPRepository
- .findById(plmnInfoModel.getGnbId()).get();
- if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) {
- pLMNInfoList = gNBCUUPFunction.getpLMNInfoList();
- } else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
- }
- pLMNInfoList.add(plmnInfo);
- gNBCUUPFunction.setpLMNInfoList(pLMNInfoList);
- gNBCUUPRepository.save(gNBCUUPFunction);
- }
- } catch (NullPointerException nullPointerException) {
- log.error("Record does not exist");
- } catch (Exception e) {
- log.error("Unexpected error while fetching data from database: " + e);
- }
- }
-
- public void handlePLMNInfoDeleteFromSdnr(String message, Session session, String ipPort) {
- log.info("handle PLMNInfo Delete: " + message);
- org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = new Gson().fromJson(message,
- org.onap.ransim.rest.api.models.PLMNInfoModel.class);
- PLMNInfo plmnInfo = new PLMNInfo();
- NSSAIConfig nSSAIConfig = new NSSAIConfig();
- nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
- org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
- sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
- sNSSAI.setStatus(plmnInfoModel.getStatus());
- sNSSAI.setConfigData(nSSAIConfig);
- plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
- plmnInfo.setsNSSAI(sNSSAI);
- // pLMNInfoRepo.delete(plmnInfo);
-}
+ }
+
+ public void handleRRMPolicyRatioUpdateFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle RRMPolicy update: " + message);
+ RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class);
+ rrmPolicyRepository.save(rRMPolicyRatio);
+ }
+
+ public void handleRRMPolicyRatioDeleteFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle RRMPolicyRatio Delete: " + message);
+ RRMPolicyRatio rRMPolicyRatio = new Gson().fromJson(message, RRMPolicyRatio.class);
+ rrmPolicyRepository.delete(rRMPolicyRatio);
+ }
+
+ public void handlePLMNInfoUpdateFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle PLMNInfo update: " + message);
+ List<PLMNInfo> pLMNInfoList = null;
+ org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel =
+ new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class);
+ PLMNInfo plmnInfo = new PLMNInfo();
+ NSSAIConfig nSSAIConfig = new NSSAIConfig();
+ nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
+ org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
+ sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
+ sNSSAI.setStatus(plmnInfoModel.getStatus());
+ sNSSAI.setConfigData(nSSAIConfig);
+ plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
+ plmnInfo.setsNSSAI(sNSSAI);
+ try {
+ if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) {
+ org.onap.ransim.rest.api.models.NRCellDU nrCellDu =
+ nRCellDURepository.findById(plmnInfoModel.getNrCellId()).get();
+ if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) {
+ pLMNInfoList = nrCellDu.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ nrCellDu.setpLMNInfoList(pLMNInfoList);
+ nRCellDURepository.save(nrCellDu);
+ } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) {
+ org.onap.ransim.rest.api.models.NRCellCU nrCellCu =
+ nRCellCURepository.findById(plmnInfoModel.getNrCellId()).get();
+ if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) {
+ pLMNInfoList = nrCellCu.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ nrCellCu.setpLMNInfoList(pLMNInfoList);
+ nRCellCURepository.save(nrCellCu);
+ } else {
+ org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction =
+ gNBCUUPRepository.findById(plmnInfoModel.getGnbId()).get();
+ if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) {
+ pLMNInfoList = gNBCUUPFunction.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ gNBCUUPFunction.setpLMNInfoList(pLMNInfoList);
+ gNBCUUPRepository.save(gNBCUUPFunction);
+ }
+ } catch (NullPointerException nullPointerException) {
+ log.error("Record does not exist");
+ } catch (Exception e) {
+ log.error("Unexpected error while fetching data from database: " + e);
+ }
+ }
- public void handleSliceProfileUpdateFromSdnr(String message, Session session, String ipPort) {
- log.info("handle SliceProfile update: "+message);
- SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class);
- sliceProfileRepository.save(sliceProfile);
- }
-
- public void handleSliceProfileDeleteFromSdnr(String message, Session session, String ipPort) {
- log.info("handle SliceProfile delete: "+message);
- SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class);
- sliceProfileRepository.delete(sliceProfile);
- }
-
-
- /**
- * The function alters the database information based on the modifications made
- * in the SDNR.
- *
- * @param message message received from the SDNR
- * @param session sends the session details
- * @param ipPort ip address of the netconf server
- */
- public void handleModifyNeighborFromSdnr(String message, Session session, String ipPort) {
- log.info("handleModifyAnrFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
- ModifyNeighbor modifyNeighbor = new Gson().fromJson(message, ModifyNeighbor.class);
- log.info("handleModifyAnrFromSDNR: modifyPci:" + modifyNeighbor.getCellId());
- List<NeighborDetails> neighborList = new ArrayList<NeighborDetails>();
- List<String> cellList = new ArrayList<String>();
- cellList.add(modifyNeighbor.getCellId());
- String nbrsAdd = "";
- String nbrsDel = "";
- String source = "Netconf";
-
- for (int i = 0; i < modifyNeighbor.getNeighborList().size(); i++) {
- if (modifyNeighbor.getNeighborList().get(i).isBlacklisted()) {
- NeighborDetails nd = new NeighborDetails(
- new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()),
- true);
- ransimRepo.mergeNeighborDetails(nd);
- cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId());
- if (nbrsAdd.equals("")) {
- nbrsDel = modifyNeighbor.getNeighborList().get(i).getNodeId();
- } else {
- nbrsDel += "," + modifyNeighbor.getNeighborList().get(i).getNodeId();
- }
- } else {
- NeighborDetails nd = new NeighborDetails(
- new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()),
- false);
- ransimRepo.mergeNeighborDetails(nd);
- cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId());
- if (nbrsDel.equals("")) {
- nbrsAdd = modifyNeighbor.getNeighborList().get(i).getNodeId();
- } else {
- nbrsAdd += "," + modifyNeighbor.getNeighborList().get(i).getNodeId();
- }
- }
-
- }
-
- for (String cl : cellList) {
- rsPciHdlr.setCollisionConfusionFromFile(cl);
- }
-
- log.info("neighbor list: " + neighborList);
-
- rsPciHdlr.updateNbrsOperationsTable(modifyNeighbor.getCellId(), source, nbrsAdd, nbrsDel);
- }
-
- /**
- * The function sends the modification made in the GUI to the netconf server.
- *
- * @param cellId node Id of the cell which was modified
- * @param pciId PCI number of the cell which was modified
- */
- public void handleModifyPciFromGui(String cellId, long pciId) {
- log.info("handleModifyPciFromGUI: cellId:" + cellId + " pciId:" + pciId);
-
- try {
- CellDetails currentCell = ransimRepo.getCellDetail(cellId);
- CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellId);
- List<Neighbor> nbrList = new ArrayList<Neighbor>();
- Iterator<NeighborDetails> iter = neighborList.getNeighborList().iterator();
- while (iter.hasNext()) {
- NeighborDetails nbCell = iter.next();
- Neighbor nbr = new Neighbor();
- CellDetails nbrCell = ransimRepo.getCellDetail(nbCell.getNeigbor().getNeighborCell());
-
- nbr.setNodeId(nbrCell.getNodeId());
- nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
- nbr.setPnfName(nbrCell.getNodeName());
- nbr.setServerId(nbrCell.getServerId());
- nbr.setPlmnId(nbrCell.getNetworkId());
- nbrList.add(nbr);
- }
-
- String pnfName = currentCell.getServerId();
- String ipPort = serverIdIpPortMapping.get(pnfName);
- log.info("handleModifyPciFromGui:ipPort >>>>>>> " + ipPort);
-
- if (ipPort != null && !ipPort.trim().equals("")) {
-
- String[] ipPortArr = ipPort.split(":");
- Topology oneCell = new Topology(pnfName, pciId, cellId, nbrList);
- UpdateCell updatedPci = new UpdateCell(currentCell.getServerId(), ipPortArr[0], ipPortArr[1], oneCell);
- Gson gson = new Gson();
- String jsonStr = gson.toJson(updatedPci);
- if (ipPort != null && !ipPort.trim().equals("")) {
- Session clSess = webSocketSessions.get(ipPort);
- if (clSess != null) {
- RansimWebSocketServer.sendUpdateCellMessage(jsonStr, clSess);
- log.info("handleModifyPciFromGui, message: " + jsonStr);
- } else {
- log.info("No client session for " + ipPort);
- }
- } else {
- log.info("No client for " + currentCell.getServerId());
- }
- }
-
- } catch (Exception eu) {
-
- log.error("Exception:", eu);
- }
- }
-
- /**
- * The function unmounts the connection with SDNR.
- *
- * @return returns null value
- */
- public String stopAllSimulation() {
- try {
- List<NetconfServers> ncServers = ransimRepo.getNetconfServersList();
- for (NetconfServers netconfServers : ncServers) {
- try {
- log.info("Unmount " + netconfServers.getServerId());
- new RestClient().sendUnmountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp,
+ public void handlePLMNInfoDeleteFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle PLMNInfo Delete: " + message);
+ org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel =
+ new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class);
+ PLMNInfo plmnInfo = new PLMNInfo();
+ NSSAIConfig nSSAIConfig = new NSSAIConfig();
+ nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
+ org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
+ sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
+ sNSSAI.setStatus(plmnInfoModel.getStatus());
+ sNSSAI.setConfigData(nSSAIConfig);
+ plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
+ plmnInfo.setsNSSAI(sNSSAI);
+ // pLMNInfoRepo.delete(plmnInfo);
+ }
+
+ public void handleSliceProfileUpdateFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle SliceProfile update: " + message);
+ SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class);
+ sliceProfileRepository.save(sliceProfile);
+ }
+
+ public void handleSliceProfileDeleteFromSdnr(String message, Session session, String ipPort) {
+ log.info("handle SliceProfile delete: " + message);
+ SliceProfile sliceProfile = new Gson().fromJson(message, SliceProfile.class);
+ sliceProfileRepository.delete(sliceProfile);
+ }
+
+ /**
+ * The function alters the database information based on the modifications made
+ * in the SDNR.
+ *
+ * @param message message received from the SDNR
+ * @param session sends the session details
+ * @param ipPort ip address of the netconf server
+ */
+ public void handleModifyNeighborFromSdnr(String message, Session session, String ipPort) {
+ log.info("handleModifyAnrFromSDNR: message:" + message + " session:" + session + " ipPort:" + ipPort);
+ ModifyNeighbor modifyNeighbor = new Gson().fromJson(message, ModifyNeighbor.class);
+ log.info("handleModifyAnrFromSDNR: modifyPci:" + modifyNeighbor.getCellId());
+ List<NeighborDetails> neighborList = new ArrayList<NeighborDetails>();
+ List<String> cellList = new ArrayList<String>();
+ cellList.add(modifyNeighbor.getCellId());
+ String nbrsAdd = "";
+ String nbrsDel = "";
+ String source = "Netconf";
+
+ for (int i = 0; i < modifyNeighbor.getNeighborList().size(); i++) {
+ if (modifyNeighbor.getNeighborList().get(i).isBlacklisted()) {
+ NeighborDetails nd = new NeighborDetails(
+ new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()),
+ true);
+ ransimRepo.mergeNeighborDetails(nd);
+ cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId());
+ if (nbrsAdd.equals("")) {
+ nbrsDel = modifyNeighbor.getNeighborList().get(i).getNodeId();
+ } else {
+ nbrsDel += "," + modifyNeighbor.getNeighborList().get(i).getNodeId();
+ }
+ } else {
+ NeighborDetails nd = new NeighborDetails(
+ new NeihborId(modifyNeighbor.getCellId(), modifyNeighbor.getNeighborList().get(i).getNodeId()),
+ false);
+ ransimRepo.mergeNeighborDetails(nd);
+ cellList.add(modifyNeighbor.getNeighborList().get(i).getNodeId());
+ if (nbrsDel.equals("")) {
+ nbrsAdd = modifyNeighbor.getNeighborList().get(i).getNodeId();
+ } else {
+ nbrsAdd += "," + modifyNeighbor.getNeighborList().get(i).getNodeId();
+ }
+ }
+
+ }
+
+ for (String cl : cellList) {
+ rsPciHdlr.setCollisionConfusionFromFile(cl);
+ }
+
+ log.info("neighbor list: " + neighborList);
+
+ rsPciHdlr.updateNbrsOperationsTable(modifyNeighbor.getCellId(), source, nbrsAdd, nbrsDel);
+ }
+
+ /**
+ * The function sends the modification made in the GUI to the netconf server.
+ *
+ * @param cellId node Id of the cell which was modified
+ * @param pciId PCI number of the cell which was modified
+ */
+ public void handleModifyPciFromGui(String cellId, long pciId) {
+ log.info("handleModifyPciFromGUI: cellId:" + cellId + " pciId:" + pciId);
+
+ try {
+ CellDetails currentCell = ransimRepo.getCellDetail(cellId);
+ CellNeighbor neighborList = ransimRepo.getCellNeighbor(cellId);
+ List<Neighbor> nbrList = new ArrayList<Neighbor>();
+ Iterator<NeighborDetails> iter = neighborList.getNeighborList().iterator();
+ while (iter.hasNext()) {
+ NeighborDetails nbCell = iter.next();
+ Neighbor nbr = new Neighbor();
+ CellDetails nbrCell = ransimRepo.getCellDetail(nbCell.getNeigbor().getNeighborCell());
+
+ nbr.setNodeId(nbrCell.getNodeId());
+ nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
+ nbr.setPnfName(nbrCell.getNodeName());
+ nbr.setServerId(nbrCell.getServerId());
+ nbr.setPlmnId(nbrCell.getNetworkId());
+ nbrList.add(nbr);
+ }
+
+ String pnfName = currentCell.getServerId();
+ String ipPort = serverIdIpPortMapping.get(pnfName);
+ log.info("handleModifyPciFromGui:ipPort >>>>>>> " + ipPort);
+
+ if (ipPort != null && !ipPort.trim().equals("")) {
+
+ String[] ipPortArr = ipPort.split(":");
+ Topology oneCell = new Topology(pnfName, pciId, cellId, nbrList);
+ UpdateCell updatedPci = new UpdateCell(currentCell.getServerId(), ipPortArr[0], ipPortArr[1], oneCell);
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(updatedPci);
+ if (ipPort != null && !ipPort.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPort);
+ if (clSess != null) {
+ RansimWebSocketServer.sendUpdateCellMessage(jsonStr, clSess);
+ log.info("handleModifyPciFromGui, message: " + jsonStr);
+ } else {
+ log.info("No client session for " + ipPort);
+ }
+ } else {
+ log.info("No client for " + currentCell.getServerId());
+ }
+ }
+
+ } catch (Exception eu) {
+
+ log.error("Exception:", eu);
+ }
+ }
+
+ /**
+ * The function unmounts the connection with SDNR.
+ *
+ * @return returns null value
+ */
+ public String stopAllSimulation() {
+ try {
+ List<NetconfServers> ncServers = ransimRepo.getNetconfServersList();
+ for (NetconfServers netconfServers : ncServers) {
+ try {
+ log.info("Unmount " + netconfServers.getServerId());
+ new RestClient().sendUnmountRequestToSdnr(netconfServers.getServerId(), sdnrServerIp,
sdnrServerPort, sdnrServerUserid, sdnrServerPassword);
- } catch (Exception e) {
- log.error("Ignore Exception:", e);
- }
- serverIdIpNodeMapping.clear();
- }
- return "Netconf servers unmounted.";
- } catch (Exception eu) {
-
- log.error("Exception:", eu);
- return "Error";
- }
- }
-
-
-
- /**
- * Used to dump session details.
- */
- synchronized public static void dumpSessionDetails() {
-
- try {
-
- log.info("serverIdIpPortMapping.size:" + serverIdIpPortMapping.size() + "webSocketSessions.size"
- + webSocketSessions.size());
- for (String key : serverIdIpPortMapping.keySet()) {
- String val = serverIdIpPortMapping.get(key);
- Session sess = webSocketSessions.get(val);
- log.info("ServerId:" + key + " IpPort:" + val + " Session:" + sess);
- }
- for (String serverId : unassignedServerIds) {
- log.info("Unassigned ServerId:" + serverId);
- }
- for (String serverId : serverIdIpPortMapping.keySet()) {
- List<String> attachedNoeds = serverIdIpNodeMapping.get(serverId);
- if (attachedNoeds != null) {
- log.info("ServerId:" + serverId + " attachedNoeds.size:" + attachedNoeds.size() + " nodes:"
- + attachedNoeds.toArray());
- } else {
- log.info("ServerId:" + serverId + " attachedNoeds:" + null);
- }
- }
- } catch (Exception e) {
- log.info("Exception:", e);
- }
- }
+ } catch (Exception e) {
+ log.error("Ignore Exception:", e);
+ }
+ serverIdIpNodeMapping.clear();
+ }
+ return "Netconf servers unmounted.";
+ } catch (Exception eu) {
+
+ log.error("Exception:", eu);
+ return "Error";
+ }
+ }
+
+ /**
+ * Used to dump session details.
+ */
+ synchronized public static void dumpSessionDetails() {
+
+ try {
+
+ log.info("serverIdIpPortMapping.size:" + serverIdIpPortMapping.size() + "webSocketSessions.size"
+ + webSocketSessions.size());
+ for (String key : serverIdIpPortMapping.keySet()) {
+ String val = serverIdIpPortMapping.get(key);
+ Session sess = webSocketSessions.get(val);
+ log.info("ServerId:" + key + " IpPort:" + val + " Session:" + sess);
+ }
+ for (String serverId : unassignedServerIds) {
+ log.info("Unassigned ServerId:" + serverId);
+ }
+ for (String serverId : serverIdIpPortMapping.keySet()) {
+ List<String> attachedNoeds = serverIdIpNodeMapping.get(serverId);
+ if (attachedNoeds != null) {
+ log.info("ServerId:" + serverId + " attachedNoeds.size:" + attachedNoeds.size() + " nodes:"
+ + attachedNoeds.toArray());
+ } else {
+ log.info("ServerId:" + serverId + " attachedNoeds:" + null);
+ }
+ }
+ } catch (Exception e) {
+ log.info("Exception:", e);
+ }
+ }
}
+
class KeepWebsockAliveThread extends Thread {
- static Logger log = Logger.getLogger(KeepWebsockAliveThread.class.getName());
- RansimControllerServices rsCtrlrServices = null;
-
- KeepWebsockAliveThread(RansimControllerServices ctrlr) {
- rsCtrlrServices = ctrlr;
- }
-
- @Override
- public void run() {
- log.info("Inside KeepWebsockAliveThread run method");
- while (true) {
- for (String ipPort : RansimControllerServices.webSocketSessions.keySet()) {
- try {
- Session sess = RansimControllerServices.webSocketSessions.get(ipPort);
- RansimWebSocketServer.sendPingMessage(sess);
- log.debug("Sent ping message to Client ipPort:" + ipPort);
- } catch (Exception ex1) {
- }
- }
- try {
- Thread.sleep(10000);
- } catch (InterruptedException ex) {
- log.error("Thread interrupted");
- }
- }
- }
+ static Logger log = Logger.getLogger(KeepWebsockAliveThread.class.getName());
+ RansimControllerServices rsCtrlrServices = null;
+
+ KeepWebsockAliveThread(RansimControllerServices ctrlr) {
+ rsCtrlrServices = ctrlr;
+ }
+
+ @Override
+ public void run() {
+ log.info("Inside KeepWebsockAliveThread run method");
+ while (true) {
+ for (String ipPort : RansimControllerServices.webSocketSessions.keySet()) {
+ try {
+ Session sess = RansimControllerServices.webSocketSessions.get(ipPort);
+ RansimWebSocketServer.sendPingMessage(sess);
+ log.debug("Sent ping message to Client ipPort:" + ipPort);
+ } catch (Exception ex1) {
+ }
+ }
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException ex) {
+ log.error("Thread interrupted");
+ }
+ }
+ }
}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java
index e51af6f..ecc76b3 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimRepositoryService.java
@@ -23,6 +23,7 @@ package org.onap.ransim.rest.api.services;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+
import org.apache.log4j.Logger;
import org.onap.ransim.rest.api.models.CellDetails;
import org.onap.ransim.rest.api.models.CellNeighbor;
@@ -40,225 +41,241 @@ import org.springframework.stereotype.Service;
@Service
public class RansimRepositoryService {
- static Logger log = Logger.getLogger(RansimRepositoryService.class.getName());
+ static Logger log = Logger.getLogger(RansimRepositoryService.class.getName());
- @Autowired
- CellDetailsRepo cellDetailsRepo;
+ @Autowired
+ CellDetailsRepo cellDetailsRepo;
- @Autowired
- NetconfServersRepo netconfServersRepo;
+ @Autowired
+ NetconfServersRepo netconfServersRepo;
- @Autowired
- CellNeighborRepo cellNeighborRepo;
+ @Autowired
+ CellNeighborRepo cellNeighborRepo;
- @Autowired
- NeighborDetailsRepo neighborDetailsRepo;
+ @Autowired
+ NeighborDetailsRepo neighborDetailsRepo;
- @Autowired
- OperationLogRepo operationLogRepo;
+ @Autowired
+ OperationLogRepo operationLogRepo;
- /**
- * Method to retrieve cell details
- * @param nodeId
- * @return
- */
- public CellDetails getCellDetail(String nodeId) {
- Optional<CellDetails> cd = cellDetailsRepo.findById(nodeId);
- CellDetails cellDetails = null;
- if (cd.isPresent()) {
- cellDetails = cd.get();
- }
- return cellDetails;
- }
+ /**
+ * Method to retrieve cell details
+ *
+ * @param nodeId
+ * @return
+ */
+ public CellDetails getCellDetail(String nodeId) {
+ Optional<CellDetails> cd = cellDetailsRepo.findById(nodeId);
+ CellDetails cellDetails = null;
+ if (cd.isPresent()) {
+ cellDetails = cd.get();
+ }
+ return cellDetails;
+ }
- /**
- * Method to retrieve netconf server details
- * @param serverId
- * @return
- */
- public NetconfServers getNetconfServer(String serverId) {
- Optional<NetconfServers> serverDetails = netconfServersRepo.findById(serverId);
- NetconfServers server = null;
- if (serverDetails.isPresent()) {
- server = serverDetails.get();
- }
- return server;
- }
+ /**
+ * Method to retrieve netconf server details
+ *
+ * @param serverId
+ * @return
+ */
+ public NetconfServers getNetconfServer(String serverId) {
+ Optional<NetconfServers> serverDetails = netconfServersRepo.findById(serverId);
+ NetconfServers server = null;
+ if (serverDetails.isPresent()) {
+ server = serverDetails.get();
+ }
+ return server;
+ }
- /**
- * Method to retrieve cell neighbors
- * @param nodeId
- * @return
- */
- public CellNeighbor getCellNeighbor(String nodeId) {
- Optional<CellNeighbor> cellNeighborDetails = cellNeighborRepo.findById(nodeId);
- CellNeighbor cellNeighbor = null;
- if (cellNeighborDetails.isPresent()) {
- cellNeighbor = cellNeighborDetails.get();
- }
- return cellNeighbor;
- }
+ /**
+ * Method to retrieve cell neighbors
+ *
+ * @param nodeId
+ * @return
+ */
+ public CellNeighbor getCellNeighbor(String nodeId) {
+ Optional<CellNeighbor> cellNeighborDetails = cellNeighborRepo.findById(nodeId);
+ CellNeighbor cellNeighbor = null;
+ if (cellNeighborDetails.isPresent()) {
+ cellNeighbor = cellNeighborDetails.get();
+ }
+ return cellNeighbor;
+ }
- /**
- * Method to retrieve all cell details
- * @return
- */
- public List<CellDetails> getCellDetailsList() {
- Iterable<CellDetails> cellsList = cellDetailsRepo.findAll();
- if (cellsList != null) {
- return (List<CellDetails>) cellsList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve all cell details
+ *
+ * @return
+ */
+ public List<CellDetails> getCellDetailsList() {
+ Iterable<CellDetails> cellsList = cellDetailsRepo.findAll();
+ if (cellsList != null) {
+ return (List<CellDetails>) cellsList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to retrieve cells with no server ids
- * @return
- */
- public List<CellDetails> getCellsWithNoServerIds() {
- List<CellDetails> cellsList = cellDetailsRepo.findCellsWithNoServerId();
- if (cellsList != null) {
- return cellsList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve cells with no server ids
+ *
+ * @return
+ */
+ public List<CellDetails> getCellsWithNoServerIds() {
+ List<CellDetails> cellsList = cellDetailsRepo.findCellsWithNoServerId();
+ if (cellsList != null) {
+ return cellsList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to retrieve cell with collision or confusion
- * @return
- */
- public List<CellDetails> getCellsWithCollisionOrConfusion() {
- List<CellDetails> cellsList = cellDetailsRepo.getCellsWithCollisionOrConfusion();
- if (cellsList != null) {
- return cellsList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve cell with collision or confusion
+ *
+ * @return
+ */
+ public List<CellDetails> getCellsWithCollisionOrConfusion() {
+ List<CellDetails> cellsList = cellDetailsRepo.getCellsWithCollisionOrConfusion();
+ if (cellsList != null) {
+ return cellsList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to retrieve operation log
- * @return
- */
- public List<OperationLog> getOperationLogList() {
- Iterable<OperationLog> opLogList = operationLogRepo.findAll();
- if (opLogList != null) {
- return (List<OperationLog>) opLogList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve operation log
+ *
+ * @return
+ */
+ public List<OperationLog> getOperationLogList() {
+ Iterable<OperationLog> opLogList = operationLogRepo.findAll();
+ if (opLogList != null) {
+ return (List<OperationLog>) opLogList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to retrieve all netconf servers
- * @return
- */
- public List<NetconfServers> getNetconfServersList() {
- Iterable<NetconfServers> serversList = netconfServersRepo.findAll();
- if (serversList != null) {
- return (List<NetconfServers>) serversList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve all netconf servers
+ *
+ * @return
+ */
+ public List<NetconfServers> getNetconfServersList() {
+ Iterable<NetconfServers> serversList = netconfServersRepo.findAll();
+ if (serversList != null) {
+ return (List<NetconfServers>) serversList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to retrieve all cell neighbors
- * @return
- */
- public List<CellNeighbor> getCellNeighborList() {
- Iterable<CellNeighbor> cellNeighborList = cellNeighborRepo.findAll();
- if (cellNeighborList != null) {
- return (List<CellNeighbor>) cellNeighborList;
- } else {
- return new ArrayList<>();
- }
- }
+ /**
+ * Method to retrieve all cell neighbors
+ *
+ * @return
+ */
+ public List<CellNeighbor> getCellNeighborList() {
+ Iterable<CellNeighbor> cellNeighborList = cellNeighborRepo.findAll();
+ if (cellNeighborList != null) {
+ return (List<CellNeighbor>) cellNeighborList;
+ } else {
+ return new ArrayList<>();
+ }
+ }
- /**
- * Method to delete specific cells
- * @param deleteCelldetail
- */
- public void deleteCellDetails(CellDetails deleteCelldetail) {
+ /**
+ * Method to delete specific cells
+ *
+ * @param deleteCelldetail
+ */
+ public void deleteCellDetails(CellDetails deleteCelldetail) {
- if (deleteCelldetail.getServerId() != null) {
- NetconfServers ns = getNetconfServer(deleteCelldetail.getServerId());
- if (ns != null) {
- ns.getCells().remove(deleteCelldetail);
- netconfServersRepo.save(ns);
- }
- }
- cellDetailsRepo.deleteById(deleteCelldetail.getNodeId());
- }
+ if (deleteCelldetail.getServerId() != null) {
+ NetconfServers ns = getNetconfServer(deleteCelldetail.getServerId());
+ if (ns != null) {
+ ns.getCells().remove(deleteCelldetail);
+ netconfServersRepo.save(ns);
+ }
+ }
+ cellDetailsRepo.deleteById(deleteCelldetail.getNodeId());
+ }
- /**
- * Method to delete cell neighbors
- * @param deleteCellNeighbor
- */
- public void deleteCellNeighbor(CellNeighbor deleteCellNeighbor) {
- cellNeighborRepo.deleteById(deleteCellNeighbor.getNodeId());
- }
+ /**
+ * Method to delete cell neighbors
+ *
+ * @param deleteCellNeighbor
+ */
+ public void deleteCellNeighbor(CellNeighbor deleteCellNeighbor) {
+ cellNeighborRepo.deleteById(deleteCellNeighbor.getNodeId());
+ }
- /**
- * Method to delete all netconf servers
- */
- public void deleteNetconfServers() {
- netconfServersRepo.deleteAll();
- }
+ /**
+ * Method to delete all netconf servers
+ */
+ public void deleteNetconfServers() {
+ netconfServersRepo.deleteAll();
+ }
- /**
- * Method to delete all cell neighbors
- */
- public void deleteCellNeighbors() {
- cellNeighborRepo.deleteAll();
- }
+ /**
+ * Method to delete all cell neighbors
+ */
+ public void deleteCellNeighbors() {
+ cellNeighborRepo.deleteAll();
+ }
- /**
- * Method to delete all cells
- */
- public void deleteAllCellDetails() {
- cellDetailsRepo.deleteAll();
- }
+ /**
+ * Method to delete all cells
+ */
+ public void deleteAllCellDetails() {
+ cellDetailsRepo.deleteAll();
+ }
- /**
- * Method to save cells
- * @param cellDetail
- */
- public void mergeCellDetails(CellDetails cellDetail) {
- cellDetailsRepo.save(cellDetail);
- }
+ /**
+ * Method to save cells
+ *
+ * @param cellDetail
+ */
+ public void mergeCellDetails(CellDetails cellDetail) {
+ cellDetailsRepo.save(cellDetail);
+ }
- /**
- * Method to save neighbors
- * @param neighborDetails
- */
- public void mergeNeighborDetails(NeighborDetails neighborDetails) {
- neighborDetailsRepo.save(neighborDetails);
- }
+ /**
+ * Method to save neighbors
+ *
+ * @param neighborDetails
+ */
+ public void mergeNeighborDetails(NeighborDetails neighborDetails) {
+ neighborDetailsRepo.save(neighborDetails);
+ }
- /**
- * Method to save netconf servers
- * @param netconfServers
- */
- public void mergeNetconfServers(NetconfServers netconfServers) {
- netconfServersRepo.save(netconfServers);
- }
+ /**
+ * Method to save netconf servers
+ *
+ * @param netconfServers
+ */
+ public void mergeNetconfServers(NetconfServers netconfServers) {
+ netconfServersRepo.save(netconfServers);
+ }
- /**
- * Method to save cell neighbors
- * @param cellNeighbor
- */
- public void mergeCellNeighbor(CellNeighbor cellNeighbor) {
- cellNeighborRepo.save(cellNeighbor);
- }
+ /**
+ * Method to save cell neighbors
+ *
+ * @param cellNeighbor
+ */
+ public void mergeCellNeighbor(CellNeighbor cellNeighbor) {
+ cellNeighborRepo.save(cellNeighbor);
+ }
- /**
- * Method to save operation log
- * @param opLog
- */
- public void mergeOperationLog(OperationLog opLog) {
- operationLogRepo.save(opLog);
- }
+ /**
+ * Method to save operation log
+ *
+ * @param opLog
+ */
+ public void mergeOperationLog(OperationLog opLog) {
+ operationLogRepo.save(opLog);
+ }
}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java
index c03d439..1a74c25 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/SlicingPMDataGenerator.java
@@ -1,261 +1,259 @@
-/*-
- * ============LICENSE_START=======================================================
- * Ran Simulator Controller
- * ================================================================================
- * Copyright (C) 2021 Wipro Limited.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ransim.rest.api.services;
-import java.util.Collection;
-import java.util.Set;
-
-import java.io.File;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.websocket.Session;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import java.io.ByteArrayOutputStream;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.onap.ransim.rest.api.exceptions.RansimException;
-import org.onap.ransim.rest.api.models.NSSAIConfig;
-import org.onap.ransim.rest.web.mapper.GNBDUModel;
-import org.onap.ransim.rest.web.mapper.NRCellDUModel;
-import org.onap.ransim.rest.web.mapper.NSSAIData;
-import org.onap.ransim.rest.web.mapper.PLMNInfoModel;
-import org.onap.ransim.rest.xml.models.FileFooter;
-import org.onap.ransim.rest.xml.models.FileHeader;
-import org.onap.ransim.rest.xml.models.FileSender;
-import org.onap.ransim.rest.xml.models.GranularityPeriod;
-import org.onap.ransim.rest.xml.models.Job;
-import org.onap.ransim.rest.xml.models.ManagedElement;
-import org.onap.ransim.rest.xml.models.MeasCollec;
-import org.onap.ransim.rest.xml.models.MeasCollecEnd;
-import org.onap.ransim.rest.xml.models.MeasCollecFile;
-import org.onap.ransim.rest.xml.models.MeasData;
-import org.onap.ransim.rest.xml.models.MeasInfo;
-import org.onap.ransim.rest.xml.models.MeasType;
-import org.onap.ransim.rest.xml.models.MeasValue;
-import org.onap.ransim.rest.xml.models.ReportingPeriod;
-import org.onap.ransim.rest.xml.models.Result;
-import org.onap.ransim.websocket.model.SlicingPmMessage;
-import org.onap.ransim.websocket.server.RansimWebSocketServer;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-import com.google.gson.Gson;
-
-@Service
-public class SlicingPMDataGenerator {
-
- static Logger logger = Logger.getLogger(SlicingPMDataGenerator.class.getName());
-
- @Autowired
- RANSliceConfigService ranSliceConfigService;
-
- double ricId11MaxVariation = 0.8;
- double ricId22MaxVariation = 0.2;
-
- /**
- * Generates closed loop PM data for all DU functions Generates PRBs for DUs in
- * the ratio of 80:20 for the same nssai in different RICs
- *
- * @throws RansimException
- */
- public void generateClosedLoopPmData(long startTime) {
- try {
- String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list";
- List<GNBDUModel> duList = sendGetRequestToransimDb(requestUrl).getBody();
- for (GNBDUModel du : duList) {
- logger.info("Generating PM data for DU : " + du.getgNBDUName() + " Id :" + du.getgNBDUId());
- Map<String, NSSAIConfig> activeNssaiDetails = new HashMap<String, NSSAIConfig>();
- List<NRCellDUModel> duCellList = du.getCellDUList();
- int ricId = du.getNearRTRICId();
- List<PLMNInfoModel> plmnInfoList = new ArrayList<>();
- duCellList.forEach(cell -> plmnInfoList.addAll(cell.getpLMNInfoList()));
- List<NSSAIData> nssaiData = new ArrayList<>();
- plmnInfoList.forEach(plmnInfo -> nssaiData.add(plmnInfo.getsNSSAI()));
- nssaiData.stream().filter(nssai -> nssai.getStatus().equalsIgnoreCase("active"))
- .forEach(x -> activeNssaiDetails.put(x.getsNSSAI(), x.getConfigData()));
- produceMeasurementCollectionFile(du, activeNssaiDetails, duCellList, ricId);
- logger.info("PM data generated for DU : " + du.getgNBDUName() + " Id: " + du.getgNBDUId());
- }
- } catch (RansimException e) {
- logger.debug("ERROR in closed lopp PM data generation : ");
- logger.debug(e);
- } catch (Exception exp) {
- logger.debug(exp);
- }
- }
-
- private void produceMeasurementCollectionFile(GNBDUModel du, Map<String, NSSAIConfig> activeNssaiDetails,
- List<NRCellDUModel> duCellList, int ricId) throws RansimException {
- logger.debug("produceing MeasurementCollectionFile ");
- SlicingPmMessage pmMessage = new SlicingPmMessage();
- pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000);
- pmMessage.setSourceName(du.getgNBDUName());
- LocalDateTime beginTime = LocalDateTime.now();
- String beginTimeString = beginTime.toString();
- MeasCollec measCollec = new MeasCollec(beginTimeString);
- FileSender fileSender = new FileSender(du.getgNBDUName());
- FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender);
- Random r = new Random();
- int jobId = r.nextInt((9999 - 1000) + 1) + 1000;
- Job job = new Job(String.valueOf(jobId));
- ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S");
-
- List<MeasType> measTypeList = setMeasurementTypes(activeNssaiDetails);
- List<MeasValue> measValueList = setMeasurementValues(duCellList, getMaxVariation(ricId), measTypeList);
-
- ManagedElement managedElement = new ManagedElement("r0.1", du.getgNBDUName());
- LocalDateTime grabularityEndTime = LocalDateTime.now();
- String grabularityEndTimeString = grabularityEndTime.toString();
- GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S");
- MeasInfo measInfo = new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList,
- measValueList);
- List<MeasInfo> measInfoList = new ArrayList<MeasInfo>();
- measInfoList.add(measInfo);
- MeasData measData = new MeasData(managedElement, measInfoList);
- List<MeasData> measDataList = new ArrayList<MeasData>();
- measDataList.add(measData);
- LocalDateTime endTime = LocalDateTime.now();
- String endTimeString = endTime.toString();
- pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000);
- MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString);
- FileFooter fileFooter = new FileFooter(measCollecEnd);
- MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter,
- "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec");
-
- try {
- String startDate = beginTimeString.replace(':', '-');
- String endDate = endTimeString.replace(':', '-');
- String fileName = "A" + startDate + "-" + endDate + "-" + String.valueOf(jobId) + "-"
- + du.getgNBDUName() + ".xml";
- pmMessage.setFileName(fileName);
- Gson gson = new Gson();
- String pmData = gson.toJson(measCollecFile);
- pmMessage.setPmData(pmData);
- closedLoopPmData(pmMessage);
- } catch (Exception exp) {
- logger.debug(exp);
- }
-
- }
-
- private List<MeasValue> setMeasurementValues(List<NRCellDUModel> duCellList, double ricIdVariation,
- List<MeasType> measTypeList) {
- logger.debug("setting MeasurementValues");
- List<MeasValue> measValueList = new ArrayList<MeasValue>();
- duCellList.forEach(cell -> {
- AtomicInteger pValue = new AtomicInteger(1);
- List<Result> resultList = new ArrayList<>();
- int prbs = cell.getPrbs();
- measTypeList.forEach(meas -> {
- int prbsUsed = (int) (Math.random() * ricIdVariation * prbs);
- Result result = new Result(pValue.getAndIncrement(), prbsUsed);
- resultList.add(result);
- });
- MeasValue measValue = new MeasValue(cell.getCellLocalId(), resultList, false);
- measValueList.add(measValue);
-
- });
- return measValueList;
- }
-
- private double getMaxVariation(int ricId) throws RansimException {
- switch (ricId) {
- case 11:
- // ricId11MaxVariation =
- // Double.parseDouble(System.getProperty("RIC_11_VARIATION"));
- return ricId11MaxVariation;
- case 22:
- return ricId22MaxVariation;
- default:
- throw new RansimException("Invalid RIC ID : valid Ids : [11,22] ");
- }
- }
-
- private List<MeasType> setMeasurementTypes(Map<String, NSSAIConfig> activeNssaiDetails) {
- logger.debug("setting MeasurementTypes");
- List<MeasType> measTypeList = new ArrayList<MeasType>();
- AtomicInteger pValue = new AtomicInteger(1);
- activeNssaiDetails.forEach((nssai, configData) -> {
- MeasType mesType1 = new MeasType("SM.PrbUsedDl." + nssai, pValue.getAndIncrement());
- MeasType mesType2 = new MeasType("SM.PrbUsedUl." + nssai, pValue.getAndIncrement());
- measTypeList.add(mesType1);
- measTypeList.add(mesType2);
- });
- return measTypeList;
- }
-
- public static <T> ResponseEntity<List<GNBDUModel>> sendGetRequestToransimDb(String requestUrl) {
- HttpHeaders headers = new HttpHeaders();
- logger.info("sending request to ransimdb : " + requestUrl);
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
- try {
- RestTemplate restTemplate = new RestTemplate();
- return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity,
- new ParameterizedTypeReference<List<GNBDUModel>>() {
- });
- } catch (Exception e) {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
- }
- }
-
- public void closedLoopPmData(SlicingPmMessage pmMessage) {
- Gson gson = new Gson();
- String jsonStr = gson.toJson(pmMessage);
- logger.info("ClosedPmData " + jsonStr);
- String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName());
- if (ipPort != null && !ipPort.trim().equals("")) {
- logger.info("Connection estabilished with ip: " + ipPort);
- if (ipPort != null && !ipPort.trim().equals("")) {
- Session clSess = RansimControllerServices.webSocketSessions.get(ipPort);
- if (clSess != null) {
- logger.info("PM Data message sent.");
- RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess);
- } else {
- logger.info("No client session for " + ipPort);
- }
- } else {
- logger.info("No client for this serverId");
- }
- } else {
- logger.info("No client for ");
- }
- }
-}
-
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2021 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.services;
+
+import com.google.gson.Gson;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.websocket.Session;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.exceptions.RansimException;
+import org.onap.ransim.rest.api.models.NSSAIConfig;
+import org.onap.ransim.rest.web.mapper.GNBDUModel;
+import org.onap.ransim.rest.web.mapper.NRCellDUModel;
+import org.onap.ransim.rest.web.mapper.NSSAIData;
+import org.onap.ransim.rest.web.mapper.PLMNInfoModel;
+import org.onap.ransim.rest.xml.models.FileFooter;
+import org.onap.ransim.rest.xml.models.FileHeader;
+import org.onap.ransim.rest.xml.models.FileSender;
+import org.onap.ransim.rest.xml.models.GranularityPeriod;
+import org.onap.ransim.rest.xml.models.Job;
+import org.onap.ransim.rest.xml.models.ManagedElement;
+import org.onap.ransim.rest.xml.models.MeasCollec;
+import org.onap.ransim.rest.xml.models.MeasCollecEnd;
+import org.onap.ransim.rest.xml.models.MeasCollecFile;
+import org.onap.ransim.rest.xml.models.MeasData;
+import org.onap.ransim.rest.xml.models.MeasInfo;
+import org.onap.ransim.rest.xml.models.MeasType;
+import org.onap.ransim.rest.xml.models.MeasValue;
+import org.onap.ransim.rest.xml.models.ReportingPeriod;
+import org.onap.ransim.rest.xml.models.Result;
+import org.onap.ransim.websocket.model.SlicingPmMessage;
+import org.onap.ransim.websocket.server.RansimWebSocketServer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+@Service
+public class SlicingPMDataGenerator {
+
+ static Logger logger = Logger.getLogger(SlicingPMDataGenerator.class.getName());
+
+ @Autowired
+ RANSliceConfigService ranSliceConfigService;
+
+ double ricId11MaxVariation = 0.8;
+ double ricId22MaxVariation = 0.2;
+
+ /**
+ * Generates closed loop PM data for all DU functions Generates PRBs for DUs in
+ * the ratio of 80:20 for the same nssai in different RICs
+ *
+ * @throws RansimException
+ */
+ public void generateClosedLoopPmData(long startTime) {
+ try {
+ String requestUrl = "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/du-list";
+ List<GNBDUModel> duList = sendGetRequestToransimDb(requestUrl).getBody();
+ for (GNBDUModel du : duList) {
+ logger.info("Generating PM data for DU : " + du.getgNBDUName() + " Id :" + du.getgNBDUId());
+ Map<String, NSSAIConfig> activeNssaiDetails = new HashMap<String, NSSAIConfig>();
+ List<NRCellDUModel> duCellList = du.getCellDUList();
+ int ricId = du.getNearRTRICId();
+ List<PLMNInfoModel> plmnInfoList = new ArrayList<>();
+ duCellList.forEach(cell -> plmnInfoList.addAll(cell.getpLMNInfoList()));
+ List<NSSAIData> nssaiData = new ArrayList<>();
+ plmnInfoList.forEach(plmnInfo -> nssaiData.add(plmnInfo.getsNSSAI()));
+ nssaiData.stream().filter(nssai -> nssai.getStatus().equalsIgnoreCase("active"))
+ .forEach(x -> activeNssaiDetails.put(x.getsNSSAI(), x.getConfigData()));
+ produceMeasurementCollectionFile(du, activeNssaiDetails, duCellList, ricId);
+ logger.info("PM data generated for DU : " + du.getgNBDUName() + " Id: " + du.getgNBDUId());
+ }
+ } catch (RansimException e) {
+ logger.debug("ERROR in closed lopp PM data generation : ");
+ logger.debug(e);
+ } catch (Exception exp) {
+ logger.debug(exp);
+ }
+ }
+
+ private void produceMeasurementCollectionFile(GNBDUModel du, Map<String, NSSAIConfig> activeNssaiDetails,
+ List<NRCellDUModel> duCellList, int ricId) throws RansimException {
+ logger.debug("produceing MeasurementCollectionFile ");
+ SlicingPmMessage pmMessage = new SlicingPmMessage();
+ pmMessage.setStartEpochMicrosec(System.currentTimeMillis() * 1000);
+ pmMessage.setSourceName(du.getgNBDUName());
+ LocalDateTime beginTime = LocalDateTime.now();
+ String beginTimeString = beginTime.toString();
+ MeasCollec measCollec = new MeasCollec(beginTimeString);
+ FileSender fileSender = new FileSender(du.getgNBDUName());
+ FileHeader fileHeader = new FileHeader("Prefix", "Acme Ltd", "32.435 V10.0", measCollec, fileSender);
+ Random r = new Random();
+ int jobId = r.nextInt((9999 - 1000) + 1) + 1000;
+ Job job = new Job(String.valueOf(jobId));
+ ReportingPeriod reportingPeriod = new ReportingPeriod("PT900S");
+
+ List<MeasType> measTypeList = setMeasurementTypes(activeNssaiDetails);
+ List<MeasValue> measValueList = setMeasurementValues(duCellList, getMaxVariation(ricId), measTypeList);
+
+ ManagedElement managedElement = new ManagedElement("r0.1", du.getgNBDUName());
+ LocalDateTime grabularityEndTime = LocalDateTime.now();
+ String grabularityEndTimeString = grabularityEndTime.toString();
+ GranularityPeriod granularityPeriod = new GranularityPeriod(grabularityEndTimeString, "PT900S");
+ MeasInfo measInfo =
+ new MeasInfo("measInfoIsVal", job, granularityPeriod, reportingPeriod, measTypeList, measValueList);
+ List<MeasInfo> measInfoList = new ArrayList<MeasInfo>();
+ measInfoList.add(measInfo);
+ MeasData measData = new MeasData(managedElement, measInfoList);
+ List<MeasData> measDataList = new ArrayList<MeasData>();
+ measDataList.add(measData);
+ LocalDateTime endTime = LocalDateTime.now();
+ String endTimeString = endTime.toString();
+ pmMessage.setLastEpochMicrosec(System.currentTimeMillis() * 1000);
+ MeasCollecEnd measCollecEnd = new MeasCollecEnd(endTimeString);
+ FileFooter fileFooter = new FileFooter(measCollecEnd);
+ MeasCollecFile measCollecFile = new MeasCollecFile(fileHeader, measDataList, fileFooter,
+ "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec");
+
+ try {
+ String startDate = beginTimeString.replace(':', '-');
+ String endDate = endTimeString.replace(':', '-');
+ String fileName =
+ "A" + startDate + "-" + endDate + "-" + String.valueOf(jobId) + "-" + du.getgNBDUName() + ".xml";
+ pmMessage.setFileName(fileName);
+ Gson gson = new Gson();
+ String pmData = gson.toJson(measCollecFile);
+ pmMessage.setPmData(pmData);
+ closedLoopPmData(pmMessage);
+ } catch (Exception exp) {
+ logger.debug(exp);
+ }
+
+ }
+
+ private List<MeasValue> setMeasurementValues(List<NRCellDUModel> duCellList, double ricIdVariation,
+ List<MeasType> measTypeList) {
+ logger.debug("setting MeasurementValues");
+ List<MeasValue> measValueList = new ArrayList<MeasValue>();
+ duCellList.forEach(cell -> {
+ AtomicInteger pValue = new AtomicInteger(1);
+ List<Result> resultList = new ArrayList<>();
+ int prbs = cell.getPrbs();
+ measTypeList.forEach(meas -> {
+ int prbsUsed = (int) (Math.random() * ricIdVariation * prbs);
+ Result result = new Result(pValue.getAndIncrement(), prbsUsed);
+ resultList.add(result);
+ });
+ MeasValue measValue = new MeasValue(cell.getCellLocalId(), resultList, false);
+ measValueList.add(measValue);
+
+ });
+ return measValueList;
+ }
+
+ private double getMaxVariation(int ricId) throws RansimException {
+ switch (ricId) {
+ case 11:
+ // ricId11MaxVariation =
+ // Double.parseDouble(System.getProperty("RIC_11_VARIATION"));
+ return ricId11MaxVariation;
+ case 22:
+ return ricId22MaxVariation;
+ default:
+ throw new RansimException("Invalid RIC ID : valid Ids : [11,22] ");
+ }
+ }
+
+ private List<MeasType> setMeasurementTypes(Map<String, NSSAIConfig> activeNssaiDetails) {
+ logger.debug("setting MeasurementTypes");
+ List<MeasType> measTypeList = new ArrayList<MeasType>();
+ AtomicInteger pValue = new AtomicInteger(1);
+ activeNssaiDetails.forEach((nssai, configData) -> {
+ MeasType mesType1 = new MeasType("SM.PrbUsedDl." + nssai, pValue.getAndIncrement());
+ MeasType mesType2 = new MeasType("SM.PrbUsedUl." + nssai, pValue.getAndIncrement());
+ measTypeList.add(mesType1);
+ measTypeList.add(mesType2);
+ });
+ return measTypeList;
+ }
+
+ public static <T> ResponseEntity<List<GNBDUModel>> sendGetRequestToransimDb(String requestUrl) {
+ HttpHeaders headers = new HttpHeaders();
+ logger.info("sending request to ransimdb : " + requestUrl);
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
+ try {
+ RestTemplate restTemplate = new RestTemplate();
+ return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<GNBDUModel>>() {});
+ } catch (Exception e) {
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+ }
+
+ public void closedLoopPmData(SlicingPmMessage pmMessage) {
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(pmMessage);
+ logger.info("ClosedPmData " + jsonStr);
+ String ipPort = RansimControllerServices.serverIdIpPortMapping.get(pmMessage.getSourceName());
+ if (ipPort != null && !ipPort.trim().equals("")) {
+ logger.info("Connection estabilished with ip: " + ipPort);
+ if (ipPort != null && !ipPort.trim().equals("")) {
+ Session clSess = RansimControllerServices.webSocketSessions.get(ipPort);
+ if (clSess != null) {
+ logger.info("PM Data message sent.");
+ RansimWebSocketServer.sendIntelligentSlicingPmData(jsonStr, clSess);
+ } else {
+ logger.info("No client session for " + ipPort);
+ }
+ } else {
+ logger.info("No client for this serverId");
+ }
+ } else {
+ logger.info("No client for ");
+ }
+ }
+}