diff options
Diffstat (limited to 'ransim')
4 files changed, 117 insertions, 91 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java index 881d19b..6ba89c2 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/handler/RansimPciHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Ran Simulator Controller * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-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. @@ -95,34 +95,37 @@ public class RansimPciHandler { boolean collisionDetected = false; boolean confusionDetected = false; List<Long> nbrPcis = new ArrayList<Long>(); - List<Long> ConfusionPcis = new ArrayList<Long>(); - int collisionCount = 0; - int confusionCount = 0; + String collisions = ""; + HashMap<Long, String> confusions = new HashMap<Long, String>(); CellDetails currentCell = ransimRepo.getCellDetail(cellNodeId); log.info("Setting confusion/collision for Cell :" + cellNodeId); GetNeighborList cellNbrDetails = generateNeighborList(cellNodeId); for (CellDetails firstLevelNbr : cellNbrDetails.getCellsWithHo()) { - if (nbrPcis.contains((Long) firstLevelNbr.getPhysicalCellId())) { + if (nbrPcis.contains((Long) firstLevelNbr.getPhysicalCellId())) { confusionDetected = true; - if (ConfusionPcis.contains(firstLevelNbr.getPhysicalCellId())) { - confusionCount++; + if(confusions.containsKey((Long) firstLevelNbr.getPhysicalCellId())) { + confusions.put((Long) firstLevelNbr.getPhysicalCellId(), + confusions.get((Long) firstLevelNbr.getPhysicalCellId())+","+firstLevelNbr.getNodeId()); } else { - ConfusionPcis.add(firstLevelNbr.getPhysicalCellId()); - confusionCount = confusionCount + 2; + confusions.put((Long) firstLevelNbr.getPhysicalCellId(),firstLevelNbr.getNodeId()); } - } else { - nbrPcis.add((Long) firstLevelNbr.getPhysicalCellId()); - } - if (currentCell.getPhysicalCellId() == firstLevelNbr.getPhysicalCellId()) { - collisionDetected = true; - collisionCount++; - } + } else { + nbrPcis.add((Long) firstLevelNbr.getPhysicalCellId()); + } + + if (currentCell.getPhysicalCellId() == firstLevelNbr.getPhysicalCellId()) { + collisionDetected = true; + collisions += collisions.isEmpty()?firstLevelNbr.getNodeId():","+firstLevelNbr.getNodeId(); + } } + result.setCollisions(collisions); + result.setConfusions(confusions); + currentCell.setPciCollisionDetected(collisionDetected); currentCell.setPciConfusionDetected(confusionDetected); @@ -147,9 +150,6 @@ public class RansimPciHandler { result.setProblem("No Issues"); } - result.setCollisionCount("" + collisionCount); - result.setConfusionCount("" + confusionCount); - ransimRepo.mergeCellDetails(currentCell); return result; @@ -731,54 +731,60 @@ public class RansimPciHandler { * Node Id of the cell * @param issue * Contains the collision/confusion details of the cess - * @return returns EventFm object, with all the necessary parameters. + * @return returns List of EventFm objects, with all the necessary parameters. */ - public static EventFm setEventFm(String networkId, String ncServer, String cellId, FmAlarmInfo issue) { + public static List<EventFm> setEventFm(String networkId, String ncServer, String cellId, FmAlarmInfo issue) { log.info("Inside generate FmData"); + List<EventFm> eventList = new ArrayList<EventFm>(); EventFm event = new EventFm(); try { CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm(); FaultFields faultFields = new FaultFields(); - - commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); - commonEventHeader.setSourceName(cellId); - commonEventHeader.setReportingEntityName(ncServer); - String uuid = globalFmCellIdUuidMap.get(cellId); if (uuid == null) { uuid = getUuid(); globalFmCellIdUuidMap.put(cellId, uuid); } commonEventHeader.setSourceUuid(uuid); - - if (issue.getProblem().equals("Collision") || issue.getProblem().equals("Confusion") - || issue.getProblem().equals("CollisionAndConfusion")) { - faultFields.setAlarmCondition("RanPciCollisionConfusionOccurred"); - faultFields.setEventSeverity("CRITICAL"); - faultFields.setEventSourceType("other"); - faultFields.setSpecificProblem(issue.getProblem()); - - Map<String, String> alarmAdditionalInformation = new HashMap<String, String>(); - alarmAdditionalInformation.put("networkId", networkId); - alarmAdditionalInformation.put("collisions", issue.getCollisionCount()); - alarmAdditionalInformation.put("confusions", issue.getConfusionCount()); - - faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation); - + faultFields.setAlarmCondition("RanPciCollisionConfusionOccurred"); + faultFields.setEventSeverity("CRITICAL"); + faultFields.setEventSourceType("other"); + Map<String, String> alarmAdditionalInformation = new HashMap<String, String>(); + alarmAdditionalInformation.put("networkId", networkId); + faultFields.setAlarmAdditionalInformation(alarmAdditionalInformation); + + if (!issue.getCollisions().isEmpty()) { + commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + commonEventHeader.setSourceName(cellId); + commonEventHeader.setReportingEntityName(ncServer); + faultFields.setSpecificProblem(issue.getCollisions()); + faultFields.setEventCategory("PCICollision"); + commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + event.setCommonEventHeader(commonEventHeader); + event.setFaultFields(faultFields); + eventList.add(event); } - commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); - event.setCommonEventHeader(commonEventHeader); - event.setFaultFields(faultFields); + for (Map.Entry<Long, String> set : issue.getConfusions().entrySet()) { + commonEventHeader.setStartEpochMicrosec(System.currentTimeMillis() * 1000); + commonEventHeader.setSourceName(cellId); + commonEventHeader.setReportingEntityName(ncServer); + faultFields.setSpecificProblem(set.getValue()); + faultFields.setEventCategory("PCIConfusion"); + commonEventHeader.setLastEpochMicrosec(System.currentTimeMillis() * 1000); + event.setCommonEventHeader(commonEventHeader); + event.setFaultFields(faultFields); + eventList.add(event); + } } catch (Exception e) { log.info("Exception: ", e); } - return event; + return eventList; } @@ -806,8 +812,8 @@ public class RansimPciHandler { if (op1.getProblem().equals("CollisionAndConfusion") || op1.getProblem().equals("Collision") || op1.getProblem().equals("Confusion")) { log.info("op1: " + op1); - EventFm lci = setEventFm(cell.getNetworkId(), cell.getServerId(), cell.getNodeId(), op1); - listCellIssue.add(lci); + List<EventFm> lci = setEventFm(cell.getNetworkId(), cell.getServerId(), cell.getNodeId(), op1); + listCellIssue.addAll(lci); ncs.add(cell.getServerId()); log.info("Generating Fm data for: " + cell.getNodeId()); } @@ -820,9 +826,9 @@ public class RansimPciHandler { if (source.equals("GUI")) { if (op2.getProblem().equals("CollisionAndConfusion") || op2.getProblem().equals("Collision") || op2.getProblem().equals("Confusion")) { - EventFm lci = setEventFm(nbrCell.getNetworkId(), nbrCell.getServerId(), nbrCell.getNodeId(), op2); + List<EventFm> lci = setEventFm(nbrCell.getNetworkId(), nbrCell.getServerId(), nbrCell.getNodeId(), op2); log.info("FmData added:" + nbrCell.getNodeId()); - listCellIssue.add(lci); + listCellIssue.addAll(lci); ncs.add(nbrCell.getServerId()); log.info("Generating Fm data for: " + nbrCell.getNodeId()); } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java index 2b7dd39..ef81d3b 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Ran Simulator Controller * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-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. @@ -20,52 +20,59 @@ package org.onap.ransim.rest.api.models; -public class FmAlarmInfo { +import java.util.HashMap; +public class FmAlarmInfo { + private String problem; - private String collisionCount; - private String confusionCount; + private String collisions; + private HashMap<Long, String> confusions; + public FmAlarmInfo() { super(); } - + /** * Constructor with all fields. - * - * @param problem Collision or Confusion - * @param collisionCount No of cells that causes collision. - * @param confusionCount No od cells that causes confusion. + * + * @param problem + * Collision or Confusion + * @param collisions + * Cell ids that causes collision. + * @param confusions + * Cell ids that causes confusion. */ - public FmAlarmInfo(String problem, String collisionCount, String confusionCount) { + public FmAlarmInfo(String problem, String collisions, HashMap<Long, String> confusions) { super(); this.problem = problem; - this.collisionCount = collisionCount; - this.confusionCount = confusionCount; + this.collisions = collisions; + this.confusions = confusions; } - + public String getProblem() { return problem; } - + public void setProblem(String problem) { this.problem = problem; } - public String getCollisionCount() { - return collisionCount; + public String getCollisions() { + return collisions; } - public void setCollisionCount(String collisionCount) { - this.collisionCount = collisionCount; + public void setCollisions(String collisions) { + this.collisions = collisions; } - public String getConfusionCount() { - return confusionCount; + public HashMap<Long, String> getConfusions(){ + return confusions; } - public void setConfusionCount(String confusionCount) { - this.confusionCount = confusionCount; + public void setConfusions(HashMap<Long, String> confusions) { + this.confusions = confusions; } + } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java index 17fed3c..38c24c9 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Ran Simulator Controller * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-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. @@ -23,65 +23,76 @@ package org.onap.ransim.websocket.model; import java.util.Map; public class FaultFields { - + private String alarmCondition; private String eventSourceType; private String specificProblem; private String eventSeverity; + private String eventCategory; private Map<String, String> alarmAdditionalInformation; - + public FaultFields() { super(); + // TODO Auto-generated constructor stub } - - public FaultFields(String alarmCondition, String eventSourceType, String specificProblem, String eventSeverity, - Map<String, String> alarmAdditionalInformation) { + + public FaultFields(String alarmCondition, String eventSourceType, String specificProblem, + String eventSeverity, String eventCategory, Map<String, String> alarmAdditionalInformation) { super(); this.alarmCondition = alarmCondition; this.eventSourceType = eventSourceType; this.specificProblem = specificProblem; this.eventSeverity = eventSeverity; + this.eventCategory = eventCategory; this.alarmAdditionalInformation = alarmAdditionalInformation; } - + public String getAlarmCondition() { return alarmCondition; } - + public void setAlarmCondition(String alarmCondition) { this.alarmCondition = alarmCondition; } - + public String getEventSourceType() { return eventSourceType; } - + public void setEventSourceType(String eventSourceType) { this.eventSourceType = eventSourceType; } - + public String getSpecificProblem() { return specificProblem; } - + public void setSpecificProblem(String specificProblem) { this.specificProblem = specificProblem; } - + public String getEventSeverity() { return eventSeverity; } - + public void setEventSeverity(String eventSeverity) { this.eventSeverity = eventSeverity; } + public String getEventCategory(){ + return eventCategory; + } + + public void setEventCategory(String eventCategory) { + this.eventCategory = eventCategory; + } + public Map<String, String> getAlarmAdditionalInformation() { return alarmAdditionalInformation; } - + public void setAlarmAdditionalInformation(Map<String, String> alarmAdditionalInformation) { this.alarmAdditionalInformation = alarmAdditionalInformation; } - + } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java index 4c886e3..400089f 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java @@ -187,11 +187,9 @@ public class TestRansimController { RansimControllerServices rscontroller = Mockito.mock(RansimControllerServices.class); Map<String, String> alarmAdditionalInformation = new HashMap<String, String>(); alarmAdditionalInformation.put("networkId", "abc"); - alarmAdditionalInformation.put("collisions", "1"); - alarmAdditionalInformation.put("confusions", "0"); CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm("Chn00", "", "nc1", 0, 0); FaultFields faultFields = new FaultFields("RanPciCollisionConfusionOccurred", "other", "Collision", "CRITICAL", - alarmAdditionalInformation); + "PCICollision", alarmAdditionalInformation); EventFm checkObj = new EventFm(commonEventHeader, faultFields); new MockUp<RansimControllerServices>() { @@ -210,7 +208,11 @@ public class TestRansimController { String networkId = "abc"; String ncServer = "nc1"; String cellId = "Chn00"; - FmAlarmInfo issue = new FmAlarmInfo("Collision", "1", "0"); + String collisions = ""; + HashMap<Long,String> confusions = new HashMap<Long,String>(); + collisions += "Chn00"+","+"Chn00"; + confusions.put(Long.valueOf(0),"Chn00");confusions.put(Long.valueOf(1),"Chn00"); + FmAlarmInfo issue = new FmAlarmInfo("Collision", collisions, confusions); /* * EventFm eventObj = rscontroller.setEventFm(networkId, ncServer, cellId, * issue); |