From 282711996763df7e081f3e41f42f8d475f14625c Mon Sep 17 00:00:00 2001 From: krishnaa96 Date: Fri, 12 Apr 2019 19:56:25 +0530 Subject: Implement DMaaP message handling from policy Handling of dmaap response from policy implemented Blueprint updated for config policy fetch Fix sonar issues Change-Id: I7a8a54b5d62e5db94ea2bc2d28805d8f5680d579 Issue-ID: DCAEGEN2-1427 Signed-off-by: krishnaa96 --- .../sonhms/DmaapNotificationsComponent.java | 17 +++-- .../org/onap/dcaegen2/services/sonhms/Event.java | 37 ++++++---- .../dcaegen2/services/sonhms/EventHandler.java | 10 +-- .../onap/dcaegen2/services/sonhms/FaultFields.java | 85 +++++++++++----------- .../sonhms/FaultNotificationComponent.java | 46 ++++++------ .../sonhms/FaultNotificationtoClusterMapping.java | 34 ++++----- .../services/sonhms/HoMetricsComponent.java | 3 +- .../onap/dcaegen2/services/sonhms/MainThread.java | 29 ++++---- .../services/sonhms/NewPmNotification.java | 18 ++--- .../services/sonhms/PmNotificationHandler.java | 36 +++++---- .../onap/dcaegen2/services/sonhms/PmThread.java | 8 +- .../services/sonhms/child/ChildThread.java | 7 +- .../services/sonhms/child/ChildThreadUtils.java | 67 ++++++++++------- .../dcaegen2/services/sonhms/child/PnfUtils.java | 67 +++++++++-------- .../dcaegen2/services/sonhms/child/StateOof.java | 16 ++-- .../sonhms/controller/ConfigFetchFromCbs.java | 56 +++++++------- .../sonhms/dao/HandOverMetricsRepository.java | 10 ++- .../dao/PerformanceNotificationsRepository.java | 9 +-- .../services/sonhms/dmaap/DmaapClient.java | 4 +- .../sonhms/dmaap/FMNotificationCallback.java | 55 -------------- .../sonhms/dmaap/FmNotificationCallback.java | 56 ++++++++++++++ .../sonhms/dmaap/NotificationCallback.java | 4 +- .../sonhms/dmaap/PMNotificationCallback.java | 52 ------------- .../sonhms/dmaap/PmNotificationCallback.java | 52 +++++++++++++ .../services/sonhms/dmaap/PolicyDmaapClient.java | 67 ++++++++++++++++- .../sonhms/entity/PerformanceNotifications.java | 5 +- .../sonhms/model/AdditionalMeasurements.java | 17 +++-- .../dcaegen2/services/sonhms/model/AnrInput.java | 12 ++- .../services/sonhms/model/Configurations.java | 18 ++++- .../dcaegen2/services/sonhms/model/HoDetails.java | 18 +++-- .../sonhms/model/LteNeighborListInUseLteCell.java | 4 + .../services/sonhms/model/MeasurementFields.java | 13 ++-- .../services/sonhms/model/PMNotification.java | 44 ----------- .../services/sonhms/model/PmNotification.java | 43 +++++++++++ .../services/sonhms/model/PolicyNotification.java | 25 ++++++- .../dcaegen2/services/sonhms/model/Status.java | 50 +++++++++++++ .../services/sonhms/restclient/AnrSolutions.java | 16 ++-- .../services/sonhms/restclient/OofRestClient.java | 7 -- .../services/sonhms/restclient/PciSolutions.java | 3 +- .../services/sonhms/restclient/Solutions.java | 11 ++- .../services/sonhms/utils/ClusterUtils.java | 8 +- 41 files changed, 664 insertions(+), 475 deletions(-) delete mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FmNotificationCallback.java delete mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PmNotificationCallback.java delete mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/PmNotification.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java (limited to 'src/main') diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java index 39cfbd1..a5d8ba7 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java @@ -29,7 +29,7 @@ import java.io.IOException; import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository; import org.onap.dcaegen2.services.sonhms.model.Notification; -import org.onap.dcaegen2.services.sonhms.model.PMNotification; +import org.onap.dcaegen2.services.sonhms.model.PmNotification; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +39,7 @@ public class DmaapNotificationsComponent { private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); /** - * Get sdnr notifications + * Get sdnr notifications. */ public Either getSdnrNotifications() { DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil @@ -61,21 +61,22 @@ public class DmaapNotificationsComponent { } /** - * Get pm notifications + * Get pm notifications. */ - public Either getPmNotifications(){ - PerformanceNotificationsRepository pmNotificationRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class); + public Either getPmNotifications() { + PerformanceNotificationsRepository pmNotificationRepository = + BeanUtil.getBean(PerformanceNotificationsRepository.class); String pmNotificationString = pmNotificationRepository.getPerformanceNotificationFromQueue(); if (pmNotificationString == null) { return Either.right(404); } ObjectMapper mapper = new ObjectMapper(); - PMNotification pmNotification = new PMNotification(); + PmNotification pmNotification = new PmNotification(); try { - pmNotification = mapper.readValue(pmNotificationString, PMNotification.class); + pmNotification = mapper.readValue(pmNotificationString, PmNotification.class); return Either.left(pmNotification); - } catch(IOException e) { + } catch (IOException e) { log.error("Exception in parsing pm notification ",pmNotificationString,e); return Either.right(400); } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java index 84b8eee..3a71f2b 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Event.java @@ -18,27 +18,32 @@ * ============LICENSE_END========================================================= * *******************************************************************************/ + package org.onap.dcaegen2.services.sonhms; public class Event { - private CommonEventHeader commonEventHeader; - private FaultFields faultFields; - public CommonEventHeader getCommonEventHeader() { - return commonEventHeader; - } - public void setCommonEventHeader(CommonEventHeader commonEventHeader) { - this.commonEventHeader = commonEventHeader; - } - public FaultFields getFaultFields() { - return faultFields; - } - public void setFaultFields(FaultFields faultFields) { - this.faultFields = faultFields; - } + private CommonEventHeader commonEventHeader; + private FaultFields faultFields; + + public CommonEventHeader getCommonEventHeader() { + return commonEventHeader; + } + + public void setCommonEventHeader(CommonEventHeader commonEventHeader) { + this.commonEventHeader = commonEventHeader; + } + + public FaultFields getFaultFields() { + return faultFields; + } + + public void setFaultFields(FaultFields faultFields) { + this.faultFields = faultFields; + } + @Override public String toString() { return "Event [commonEventHeader=" + commonEventHeader + ", faultFields=" + faultFields + "]"; } - - + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java index bcd9e92..c96cbc8 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/EventHandler.java @@ -106,7 +106,8 @@ public class EventHandler { faultNotificationtoClusterMapping.setCollisionConfusionMap(collisionConfusionMap); // matching cells - if (faultNotificationtoClusterMapping.getCellsinCluster() != null && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) { + if (faultNotificationtoClusterMapping.getCellsinCluster() != null + && !faultNotificationtoClusterMapping.getCellsinCluster().isEmpty()) { try { handleMatchedFmCells(faultNotificationtoClusterMapping, clusterDetails); } catch (ConfigDbNotFoundException e) { @@ -115,7 +116,8 @@ public class EventHandler { } // unmatched new cells - if (faultNotificationtoClusterMapping.getNewCells() != null && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) { + if (faultNotificationtoClusterMapping.getNewCells() != null + && !faultNotificationtoClusterMapping.getNewCells().isEmpty()) { handleUnmatchedFmCells(faultNotificationtoClusterMapping, networkId); } @@ -161,8 +163,6 @@ public class EventHandler { /** * handle unmatched fm cells. * - * @param networkId2 - * @param faultNotificationtoClusterMapping */ private void handleUnmatchedFmCells(FaultNotificationtoClusterMapping faultNotificationtoClusterMapping, String networkId) { @@ -175,7 +175,7 @@ public class EventHandler { .get(cellId); log.info("Handle Unmatching cells for FM notificatins,collisionConfusionCount{}", collisionConfusionCount); - Either existingCluster = clusterUtils.getClusterForFMCell(cellId, newClusters); + Either existingCluster = clusterUtils.getClusterForFmCell(cellId, newClusters); if (existingCluster.isRight()) { try { Map> clusterMap = clusterUtils.findClusterMap(cellId); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java index c1649b2..a2c877d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultFields.java @@ -23,7 +23,7 @@ package org.onap.dcaegen2.services.sonhms; public class FaultFields { - @Override + @Override public String toString() { return "FaultFields [faultFieldsVersion=" + faultFieldsVersion + ", alarmCondition=" + alarmCondition + ", eventSourceType=" + eventSourceType + ", specificProblem=" + specificProblem + ", eventSeverity=" @@ -32,13 +32,12 @@ public class FaultFields { } private double faultFieldsVersion; - private String alarmCondition; - private String eventSourceType; - private String specificProblem; - private String eventSeverity; - private String vfStatus; - private AlarmAdditionalInformation alarmAdditionalInformation; - + private String alarmCondition; + private String eventSourceType; + private String specificProblem; + private String eventSeverity; + private String vfStatus; + private AlarmAdditionalInformation alarmAdditionalInformation; public AlarmAdditionalInformation getAlarmAdditionalInformation() { return alarmAdditionalInformation; @@ -49,51 +48,51 @@ public class FaultFields { } public double getFaultFieldsVersion() { - return faultFieldsVersion; - } + return faultFieldsVersion; + } - public void setFaultFieldsVersion(double faultFieldsVersion) { - this.faultFieldsVersion = faultFieldsVersion; - } + public void setFaultFieldsVersion(double faultFieldsVersion) { + this.faultFieldsVersion = faultFieldsVersion; + } - public String getAlarmCondition() { - return alarmCondition; - } + public String getAlarmCondition() { + return alarmCondition; + } - public void setAlarmCondition(String alarmCondition) { - this.alarmCondition = alarmCondition; - } + public void setAlarmCondition(String alarmCondition) { + this.alarmCondition = alarmCondition; + } - public String getEventSourceType() { - return eventSourceType; - } + public String getEventSourceType() { + return eventSourceType; + } - public void setEventSourceType(String eventSourceType) { - this.eventSourceType = eventSourceType; - } + public void setEventSourceType(String eventSourceType) { + this.eventSourceType = eventSourceType; + } - public String getSpecificProblem() { - return specificProblem; - } + public String getSpecificProblem() { + return specificProblem; + } - public void setSpecificProblem(String specificProblem) { - this.specificProblem = specificProblem; - } + public void setSpecificProblem(String specificProblem) { + this.specificProblem = specificProblem; + } - public String getEventSeverity() { - return eventSeverity; - } + public String getEventSeverity() { + return eventSeverity; + } - public void setEventSeverity(String eventSeverity) { - this.eventSeverity = eventSeverity; - } + public void setEventSeverity(String eventSeverity) { + this.eventSeverity = eventSeverity; + } - public String getVfStatus() { - return vfStatus; - } + public String getVfStatus() { + return vfStatus; + } - public void setVfStatus(String vfStatus) { - this.vfStatus = vfStatus; - } + public void setVfStatus(String vfStatus) { + this.vfStatus = vfStatus; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java index 99695ab..d1bf351 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationComponent.java @@ -36,35 +36,35 @@ import org.slf4j.LoggerFactory; public class FaultNotificationComponent { - private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class); + private static Logger log = LoggerFactory.getLogger(FaultNotificationComponent.class); - /** - * Get fault notifications. - */ - public Either,Integer> getFaultNotifications() { - FaultNotificationsRepository faultNotificationsRepository = BeanUtil - .getBean(FaultNotificationsRepository.class); - String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue(); - log.info("get fault notifications method"); - if (notificationString == null) { - return Either.right(404); - } - ObjectMapper mapper = new ObjectMapper(); - FaultEvent faultEvent = new FaultEvent(); - List faultEvents = new ArrayList<>(); - try { - faultEvent = mapper.readValue(notificationString,FaultEvent.class); + /** + * Get fault notifications. + */ + public Either, Integer> getFaultNotifications() { + FaultNotificationsRepository faultNotificationsRepository = BeanUtil + .getBean(FaultNotificationsRepository.class); + String notificationString = faultNotificationsRepository.getFaultNotificationFromQueue(); + log.info("get fault notifications method"); + if (notificationString == null) { + return Either.right(404); + } + ObjectMapper mapper = new ObjectMapper(); + FaultEvent faultEvent = new FaultEvent(); + List faultEvents = new ArrayList<>(); + try { + faultEvent = mapper.readValue(notificationString, FaultEvent.class); log.info("Parsing FM notification"); - + } catch (IOException e) { log.error("Exception in parsing Notification {}", e); return Either.right(400); } - - faultEvents.add(faultEvent); - - return Either.left(faultEvents); - } + faultEvents.add(faultEvent); + + return Either.left(faultEvents); + + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java index 5e59467..1ac6715 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/FaultNotificationtoClusterMapping.java @@ -27,26 +27,26 @@ import java.util.Map; public class FaultNotificationtoClusterMapping { public Map getCellsinCluster() { - return cellsinCluster; - } + return cellsinCluster; + } + + public void setCellsinCluster(Map cellsinCluster) { + this.cellsinCluster = cellsinCluster; + } - public void setCellsinCluster(Map cellsinCluster) { - this.cellsinCluster = cellsinCluster; - } + public List getNewCells() { + return newCells; + } - public List getNewCells() { - return newCells; - } + public void setNewCells(List newCells) { + this.newCells = newCells; + } - public void setNewCells(List newCells) { - this.newCells = newCells; - } - - private Map> collisionConfusionMap; + private Map> collisionConfusionMap; - //map that returns cellid and its matching cluster id + // map that returns cellid and its matching cluster id - public Map> getCollisionConfusionMap() { + public Map> getCollisionConfusionMap() { return collisionConfusionMap; } @@ -55,7 +55,7 @@ public class FaultNotificationtoClusterMapping { } private Map cellsinCluster; - - //cells that dont match + + // cells that dont match private List newCells; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java index d27227f..cf1cf45 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java @@ -57,7 +57,8 @@ public class HoMetricsComponent { log.error("Exception in parsing HO metrics", hoDetailsString, e); return Either.right(400); } - } else + } else { return Either.right(404); + } } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java index 6cbb711..43c8e3d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/MainThread.java @@ -55,7 +55,7 @@ public class MainThread implements Runnable { private EventHandler eventHandler; - private Map bufferedFMNotificationCells; + private Map bufferedFmNotificationCells; private List sdnrNotificationCells; @@ -77,7 +77,7 @@ public class MainThread implements Runnable { faultNotificationComponent = new FaultNotificationComponent(); sdnrNotificationCells = new ArrayList<>(); fmNotificationToBuffer = new ArrayList<>(); - bufferedFMNotificationCells = new HashMap<>(); + bufferedFmNotificationCells = new HashMap<>(); eventHandler = new EventHandler(childStatusQueue, Executors.newFixedThreadPool(Configuration.getInstance().getMaximumClusters()), new HashMap<>(), new ClusterUtils(), new ThreadUtils()); @@ -101,15 +101,14 @@ public class MainThread implements Runnable { if (difference > 5000) { log.info("FM handling difference > 5000"); - for (String sdnrCell: sdnrNotificationCells) { - bufferedFMNotificationCells.remove(sdnrCell); + for (String sdnrCell : sdnrNotificationCells) { + bufferedFmNotificationCells.remove(sdnrCell); } - - log.info("FM bufferedFMNotificationCells {}", bufferedFMNotificationCells.values()); - List fmNotificationsToHandle = new ArrayList<>( - bufferedFMNotificationCells.values()); + + log.info("FM bufferedFMNotificationCells {}", bufferedFmNotificationCells.values()); + List fmNotificationsToHandle = new ArrayList<>(bufferedFmNotificationCells.values()); Boolean result = eventHandler.handleFaultNotification(fmNotificationsToHandle); - bufferedFMNotificationCells = new HashMap<>(); + bufferedFmNotificationCells = new HashMap<>(); isTimer = false; log.info("FM notification handling {}", result); } @@ -160,21 +159,21 @@ public class MainThread implements Runnable { } else { for (FaultEvent fmNotification : fmNotifications.left().value()) { faultCellId = fmNotification.getEvent().getCommonEventHeader().getSourceName(); - bufferedFMNotificationCells.put(faultCellId, fmNotification); + bufferedFmNotificationCells.put(faultCellId, fmNotification); log.info("Buffered FM cell {}", faultCellId); log.info("fmNotification{}", fmNotification); } log.info("bufferedFMNotificationCells before staring timer {}", - bufferedFMNotificationCells.keySet()); + bufferedFmNotificationCells.keySet()); - for (String sdnrCell: sdnrNotificationCells) { - bufferedFMNotificationCells.remove(sdnrCell); + for (String sdnrCell : sdnrNotificationCells) { + bufferedFmNotificationCells.remove(sdnrCell); } - + startTimer = new Timestamp(System.currentTimeMillis()); isTimer = true; - log.info("Buffered FM cell {}", bufferedFMNotificationCells.keySet()); + log.info("Buffered FM cell {}", bufferedFmNotificationCells.keySet()); } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java index ce583dd..374e615 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/NewPmNotification.java @@ -27,29 +27,29 @@ import org.springframework.stereotype.Component; @Component public class NewPmNotification { - + private Boolean newNotif; - + @PostConstruct public void init() { - newNotif=false; + newNotif = false; } public Boolean getNewNotif() { - return newNotif; - } + return newNotif; + } public void setNewNotif(Boolean newNotif) { - this.newNotif = newNotif; + this.newNotif = newNotif; } - public NewPmNotification(Boolean newNotif) { + public NewPmNotification(Boolean newNotif) { super(); this.newNotif = newNotif; } - + public NewPmNotification() { - + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java index 0df0bdb..e2223d7 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java @@ -43,16 +43,17 @@ import org.onap.dcaegen2.services.sonhms.model.HoDetails; import org.onap.dcaegen2.services.sonhms.model.Lte; import org.onap.dcaegen2.services.sonhms.model.LteCell; import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; -import org.onap.dcaegen2.services.sonhms.model.PMNotification; import org.onap.dcaegen2.services.sonhms.model.Payload; +import org.onap.dcaegen2.services.sonhms.model.PmNotification; import org.onap.dcaegen2.services.sonhms.model.Ran; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PmNotificationHandler { - private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); + private static Logger log = LoggerFactory.getLogger(PmNotificationHandler.class); PolicyDmaapClient policyDmaapClient; public PmNotificationHandler() { @@ -66,7 +67,7 @@ public class PmNotificationHandler { /** * handle PM notifications. */ - public Boolean handlePmNotifications(PMNotification pmNotification, int badThreshold) { + public Boolean handlePmNotifications(PmNotification pmNotification, int badThreshold) { HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class); Boolean result; try { @@ -75,10 +76,8 @@ public class PmNotificationHandler { String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); for (AdditionalMeasurements additionalMeasurements : pmNotification.getEvent().getMeasurementFields() .getAdditionalMeasurements()) { - int attemptsCount = Integer - .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO")); - int successCount = Integer - .parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO")); + int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO")); + int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO")); float successRate = ((float) successCount / attemptsCount) * 100; if (successRate >= badThreshold) { HoDetails hoDetails = new HoDetails(); @@ -101,7 +100,7 @@ public class PmNotificationHandler { if (!lteCellList.isEmpty()) { log.info("triggering policy to remove bad neighbors"); Flag policyTriggerFlag = BeanUtil.getBean(Flag.class); - + while (policyTriggerFlag.getHolder().equals("CHILD")) { Thread.sleep(100); } @@ -138,27 +137,34 @@ public class PmNotificationHandler { } - private Boolean sendAnrUpdateToPolicy(PMNotification pmNotification, List lteCellList) { + private Boolean sendAnrUpdateToPolicy(PmNotification pmNotification, List lteCellList) { ObjectMapper mapper = new ObjectMapper(); try { mapper.setSerializationInclusion(Include.NON_NULL); ArrayList configurations = new ArrayList<>(); String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); Configurations configuration = new Configurations( - new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId), - new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size())))))))); + new Data(new FapService(cellId, null, + new CellConfig(new Lte(new Ran(new Common(cellId), + new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))), + null); configurations.add(configuration); Payload payload = new Payload(configurations); log.info("payload : {}", payload); String anrUpdateString = mapper.writeValueAsString(payload); ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(), - new PolicyDmaapClient()); - String notification = childUtils.getNotificationString(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), UUID.randomUUID().toString(), anrUpdateString, - System.currentTimeMillis(), "ModifyConfigANR"); + new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance())); + String requestId = UUID.randomUUID().toString(); + String notification = childUtils.getNotificationString( + pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId, + anrUpdateString, System.currentTimeMillis(), "ModifyConfigANR"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); - + // getting policy response + policyDmaapClient.handlePolicyResponse(requestId); + log.info("handled policy response"); + } catch (Exception e) { log.error("Exception in sending Anr update to policy ", e); return false; diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java index d2d509f..49f0c56 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmThread.java @@ -24,7 +24,8 @@ package org.onap.dcaegen2.services.sonhms; import fj.data.Either; import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; -import org.onap.dcaegen2.services.sonhms.model.PMNotification; +import org.onap.dcaegen2.services.sonhms.model.PmNotification; +import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +47,8 @@ public class PmThread implements Runnable { super(); this.newPmNotification = newPmNotification; dmaapNotificationsComponent = new DmaapNotificationsComponent(); - pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient()); + pmNotificationHandler = new PmNotificationHandler(new PolicyDmaapClient(new DmaapUtils(), + Configuration.getInstance())); } @Override @@ -59,7 +61,7 @@ public class PmThread implements Runnable { Thread.sleep(1000); if (newPmNotification.getNewNotif()) { log.info("New PM notification from Dmaap"); - Either pmNotification = dmaapNotificationsComponent.getPmNotifications(); + Either pmNotification = dmaapNotificationsComponent.getPmNotifications(); if (pmNotification.isRight()) { if (pmNotification.right().value() == 400) { log.error("error parsing pm notifications"); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java index 15a2881..b053467 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java @@ -55,6 +55,7 @@ import org.onap.dcaegen2.services.sonhms.model.ThreadId; import org.onap.dcaegen2.services.sonhms.restclient.AsyncResponseBody; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.onap.dcaegen2.services.sonhms.utils.ClusterUtils; +import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; import org.slf4j.Logger; import org.slf4j.MDC; @@ -149,7 +150,7 @@ public class ChildThread implements Runnable { ClusterUtils clusterUtils = new ClusterUtils(); Detection detect = new Detection(); ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(), - new PolicyDmaapClient()); + new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance())); try { String networkId = cluster.getNetworkId(); @@ -167,9 +168,9 @@ public class ChildThread implements Runnable { Boolean trigger = childUtils.triggerOrWait(collisionConfusionResult); ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - int timer = 60; + double timer = 60; try { - timer = (int) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); + timer = (double) configPolicy.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); } catch (NullPointerException e) { log.info("Policy config not available. Using default timeout - 60 seconds"); } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java index 1acfde6..183de84 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java @@ -111,9 +111,9 @@ public class ChildThreadUtils { * get policy notification string from oof result. * */ - public String getNotificationString(String pnfName, String requestId, String payloadString, - Long alarmStartTime, String action) { - + public String getNotificationString(String pnfName, String requestId, String payloadString, Long alarmStartTime, + String action) { + String closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"; try { closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); @@ -127,6 +127,7 @@ public class ChildThreadUtils { policyNotification.setClosedLoopControlName(closedLoopControlName); policyNotification.setPayload(payloadString); ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); String notification = ""; try { @@ -161,7 +162,8 @@ public class ChildThreadUtils { String cellId = cellPciPair.getCellId(); int pci = cellPciPair.getPhysicalCellId(); Configurations configuration = new Configurations(new Data(new FapService(cellId, - new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null)))))); + new X0005b9Lte(pci, pnfName), new CellConfig(new Lte(new Ran(new Common(cellId), null))))), + null); configurations.add(configuration); } @@ -175,7 +177,9 @@ public class ChildThreadUtils { log.debug("JSON processing exception: {}", e); } - String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString, + String requestId = UUID.randomUUID().toString(); + + String notification = getNotificationString(pnfName, requestId, payloadString, System.currentTimeMillis(), "ModifyConfig"); log.info("Policy Notification: {}", notification); boolean status = policyDmaapClient.sendNotificationToPolicy(notification); @@ -185,34 +189,37 @@ public class ChildThreadUtils { } else { log.debug("Sending notification to policy failed"); } + policyDmaapClient.handlePolicyResponse(requestId); + log.info("handled policy response in ModifyConfig"); } } if (!solutions.getAnrSolutions().isEmpty()) { - Map>>> anrPnfs; + Map>>> anrPnfs; List configurations = new ArrayList<>(); anrPnfs = pnfUtils.getPnfsForAnrSolutions(solutions.getAnrSolutions()); - for(Map.Entry>>> entry : anrPnfs.entrySet()) { + for (Map.Entry>>> entry : anrPnfs.entrySet()) { String pnfName = entry.getKey(); - for(Map> cellRemNeighborsPair : anrPnfs.get(pnfName)) { - for(Map.Entry> entry1 : cellRemNeighborsPair.entrySet()) { - String cellId = entry1.getKey(); - List lteCellList = new ArrayList<>(); - for(String removeableNeighbor : entry1.getValue()) { - LteCell lteCell = new LteCell(); - lteCell.setBlacklisted("true"); - lteCell.setPlmnId(solutions.getNetworkId()); - lteCell.setCid(removeableNeighbor); - int pci = SdnrRestClient.getPci(cellId); - lteCell.setPhyCellId(pci); - lteCell.setPnfName(pnfName); - lteCellList.add(lteCell); - } - Configurations configuration = new Configurations( - new Data(new FapService(cellId, null, new CellConfig(new Lte(new Ran(new Common(cellId), - new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size())))))))); - configurations.add(configuration); - } + for (Map> cellRemNeighborsPair : anrPnfs.get(pnfName)) { + for (Map.Entry> entry1 : cellRemNeighborsPair.entrySet()) { + String cellId = entry1.getKey(); + List lteCellList = new ArrayList<>(); + for (String removeableNeighbor : entry1.getValue()) { + LteCell lteCell = new LteCell(); + lteCell.setBlacklisted("true"); + lteCell.setPlmnId(solutions.getNetworkId()); + lteCell.setCid(removeableNeighbor); + int pci = SdnrRestClient.getPci(cellId); + lteCell.setPhyCellId(pci); + lteCell.setPnfName(pnfName); + lteCellList.add(lteCell); + } + Configurations configuration = new Configurations(new Data(new FapService(cellId, null, + new CellConfig(new Lte(new Ran(new Common(cellId), new NeighborListInUse(null, + lteCellList, String.valueOf(lteCellList.size()))))))), + null); + configurations.add(configuration); + } } Payload payload = new Payload(configurations); ObjectMapper mapper = new ObjectMapper(); @@ -223,13 +230,17 @@ public class ChildThreadUtils { } catch (JsonProcessingException e) { log.error("Exception in writing anrupdate string", e); } - String notification = getNotificationString(pnfName, UUID.randomUUID().toString(), payloadString, + String requestId = UUID.randomUUID().toString(); + String notification = getNotificationString(pnfName, requestId, payloadString, System.currentTimeMillis(), "ModifyConfigANR"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); + policyDmaapClient.handlePolicyResponse(requestId); + log.info("handled policy response in ModifyConfigANR"); + } - + } return true; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java index 43c6c53..66f8221 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/PnfUtils.java @@ -38,8 +38,6 @@ import org.onap.dcaegen2.services.sonhms.restclient.Solutions; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.slf4j.Logger; - - public class PnfUtils { private static final Logger log = org.slf4j.LoggerFactory.getLogger(ChildThreadUtils.class); @@ -50,58 +48,59 @@ public class PnfUtils { */ public Map> getPnfs(Solutions solutions) throws ConfigDbNotFoundException { - Map> pnfs = new HashMap<>(); + Map> pnfs = new HashMap<>(); List pciSolutions = solutions.getPciSolutions(); for (PciSolutions pciSolution : pciSolutions) { - String cellId = pciSolution.getCellId(); - int pci = pciSolution.getPci(); + String cellId = pciSolution.getCellId(); + int pci = pciSolution.getPci(); - String pnfName = ""; - CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class); - Optional cellInfo = cellInfoRepository.findById(cellId); - if (cellInfo.isPresent()) { - pnfName = cellInfo.get().getPnfName(); - } else { - pnfName = SdnrRestClient.getPnfName(cellId); - cellInfoRepository.save(new CellInfo(cellId, pnfName)); - } - if (pnfs.containsKey(pnfName)) { - pnfs.get(pnfName).add(new CellPciPair(cellId, pci)); - } else { - List cellPciPairs = new ArrayList<>(); - cellPciPairs.add(new CellPciPair(cellId, pci)); - pnfs.put(pnfName, cellPciPairs); - } + String pnfName = ""; + CellInfoRepository cellInfoRepository = BeanUtil.getBean(CellInfoRepository.class); + Optional cellInfo = cellInfoRepository.findById(cellId); + if (cellInfo.isPresent()) { + pnfName = cellInfo.get().getPnfName(); + } else { + pnfName = SdnrRestClient.getPnfName(cellId); + cellInfoRepository.save(new CellInfo(cellId, pnfName)); + } + if (pnfs.containsKey(pnfName)) { + pnfs.get(pnfName).add(new CellPciPair(cellId, pci)); + } else { + List cellPciPairs = new ArrayList<>(); + cellPciPairs.add(new CellPciPair(cellId, pci)); + pnfs.put(pnfName, cellPciPairs); + } } return pnfs; } - + /** - * get pnfs for ANR solutions + * get pnfs for ANR solutions. * */ - public Map>>> getPnfsForAnrSolutions(List anrSolutions) throws ConfigDbNotFoundException { - - Map>>> anrPnfs = new HashMap<>(); - + public Map>>> getPnfsForAnrSolutions(List anrSolutions) + throws ConfigDbNotFoundException { + + Map>>> anrPnfs = new HashMap<>(); + List removeableNeighbors; - for(AnrSolutions anrSolution : anrSolutions) { + for (AnrSolutions anrSolution : anrSolutions) { String cellId = anrSolution.getCellId(); String pnfName = SdnrRestClient.getPnfName(cellId); removeableNeighbors = anrSolution.getRemoveableNeighbors(); - Map> cellRemNeighborsPair = new HashMap<>(); + Map> cellRemNeighborsPair = new HashMap<>(); cellRemNeighborsPair.put(cellId, removeableNeighbors); - if(anrPnfs.containsKey(pnfName)) { + if (anrPnfs.containsKey(pnfName)) { anrPnfs.get(pnfName).add(cellRemNeighborsPair); - }else { - List>> anrCells = new ArrayList<>(); + } else { + List>> anrCells = new ArrayList<>(); anrCells.add(cellRemNeighborsPair); anrPnfs.put(pnfName, anrCells); } } - log.info("anr Pnfs {}",anrPnfs.toString()); + log.info("anr Pnfs {}", anrPnfs); return anrPnfs; - + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java index a92617c..acfa1a4 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; public class StateOof { private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class); private BlockingQueue> childStatusUpdate; + public StateOof() { } @@ -50,13 +51,15 @@ public class StateOof { /** * Triggers OOF for pci. - * @throws OofNotFoundException when trigger oof fails + * + * @throws OofNotFoundException + * when trigger oof fails */ - public UUID triggerOof(List cellidList, - String networkId, List anrInputList) throws OofNotFoundException, InterruptedException { - + public UUID triggerOof(List cellidList, String networkId, List anrInputList) + throws OofNotFoundException, InterruptedException { + log.info("Triggering oof"); - + log.debug("the cells triggering the oof are {}", cellidList); UUID transactionId = UUID.randomUUID(); @@ -79,9 +82,8 @@ public class StateOof { Thread.currentThread().interrupt(); } - + return transactionId; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java index 767dae2..548cb4d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java @@ -40,7 +40,6 @@ import org.onap.dcaegen2.services.sonhms.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class ConfigFetchFromCbs { private static Logger log = LoggerFactory.getLogger(ConfigFetchFromCbs.class); @@ -56,40 +55,42 @@ public class ConfigFetchFromCbs { RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create(); // Read necessary properties from the environment final EnvProperties env = EnvProperties.fromEnvironment(); - log.debug("environments {}",env); + log.debug("environments {}", env); ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - + // Create the client and use it to get the configuration final CbsRequest request = CbsRequests.getAll(diagnosticContext); - CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request)) - .subscribe(jsonObject -> { - log.debug("configuration from CBS {}", jsonObject); - JsonObject config = jsonObject.getAsJsonObject("config"); - - updateConfigurationFromJsonObject(config); - - Type mapType = new TypeToken>() {}.getType(); - JsonObject policyJson = jsonObject.getAsJsonObject("policy"); - Map policy = new Gson().fromJson(policyJson, mapType); - configPolicy.setConfig(policy); - }, throwable -> log.warn("Ooops", throwable)) ; + CbsClientFactory.createCbsClient(env).flatMap(cbsClient -> cbsClient.get(request)).subscribe(jsonObject -> { + log.info("configuration and policy from CBS {}", jsonObject); + JsonObject config = jsonObject.getAsJsonObject("config"); + + updateConfigurationFromJsonObject(config); + + Type mapType = new TypeToken>() { + }.getType(); + JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0) + .getAsJsonObject().getAsJsonObject("config"); + Map policy = new Gson().fromJson(policyJson, mapType); + configPolicy.setConfig(policy); + log.info("Config policy {}", configPolicy); + }, throwable -> log.warn("Ooops", throwable)); } private void updateConfigurationFromJsonObject(JsonObject jsonObject) { - + log.info("Updating configuration from CBS"); Configuration configuration = Configuration.getInstance(); - log.info("configuration from CBS {}", jsonObject); - - Type mapType = new TypeToken>() {}.getType(); - + + Type mapType = new TypeToken>() { + }.getType(); + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); Map streamsSubscribes = new Gson().fromJson(subscribes, mapType); - + JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); Map streamsPublishes = new Gson().fromJson(publishes, mapType); - + int pgPort = jsonObject.get("postgres.port").getAsInt(); int pollingInterval = jsonObject.get("sonhandler.pollingInterval").getAsInt(); String pgPassword = jsonObject.get("postgres.password").getAsString(); @@ -102,19 +103,20 @@ public class ConfigFetchFromCbs { String pgHost = jsonObject.get("postgres.host").getAsString(); JsonArray servers = jsonObject.getAsJsonArray("sonhandler.dmaap.server"); - Type listType = new TypeToken>() {}.getType(); + Type listType = new TypeToken>() { + }.getType(); List dmaapServers = new Gson().fromJson(servers, listType); - + String cg = jsonObject.get("sonhandler.cg").getAsString(); int bufferTime = jsonObject.get("sonhandler.bufferTime").getAsInt(); String cid = jsonObject.get("sonhandler.cid").getAsString(); String configDbService = jsonObject.get("sonhandler.configDb.service").getAsString(); String namespace = jsonObject.get("sonhandler.namespace").getAsString(); String callbackUrl = "http://" + System.getenv("HOSTNAME") + "." + namespace + ":8080/callbackUrl"; - + JsonArray optimizersJson = jsonObject.getAsJsonArray("sonhandler.optimizers"); - List optimizers = new Gson().fromJson(optimizersJson, listType); - + List optimizers = new Gson().fromJson(optimizersJson, listType); + String oofService = jsonObject.get("sonhandler.oof.service").getAsString(); int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java index efc1e19..40ba19a 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/HandOverMetricsRepository.java @@ -22,18 +22,20 @@ package org.onap.dcaegen2.services.sonhms.dao; import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; @Repository +@Transactional public interface HandOverMetricsRepository extends CrudRepository { - @Query(nativeQuery=true, - value="SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1") + @Query(nativeQuery = true, value = "SELECT ho_details FROM handover_metrics WHERE src_cell_id=?1") public String getHandOverMetrics(String srcCellId); - @Query(nativeQuery=true, - value="UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2") + @Modifying + @Query(nativeQuery = true, value = "UPDATE handover_metrics SET ho_details=?1 where src_cell_id=?2") public void updateHoMetrics(String hoDetails, String srcCellId); } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java index c83956f..d45d7de 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dao/PerformanceNotificationsRepository.java @@ -28,11 +28,10 @@ import org.springframework.stereotype.Repository; @Repository public interface PerformanceNotificationsRepository extends CrudRepository { - - @Query(nativeQuery = true, - value = "DELETE FROM performance_notifications " - + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY " - + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;") + + @Query(nativeQuery = true, value = "DELETE FROM performance_notifications " + + "WHERE notification = ( SELECT notification FROM performance_notifications ORDER BY " + + "created_at FOR UPDATE SKIP LOCKED LIMIT 1 ) RETURNING notification;") public String getPerformanceNotificationFromQueue(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java index d3ca349..664dbf8 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/DmaapClient.java @@ -100,7 +100,7 @@ public class DmaapClient { // create notification consumers for FM NotificationConsumer fmNotificationConsumer = new NotificationConsumer(fmNotifCambriaConsumer, - new FMNotificationCallback()); + new FmNotificationCallback()); // start fm notification consumer threads executorPool = Executors.newScheduledThreadPool(10); executorPool.scheduleAtFixedRate(fmNotificationConsumer, 0, configuration.getPollingInterval(), @@ -108,7 +108,7 @@ public class DmaapClient { // create notification consumers for PM NotificationConsumer pmNotificationConsumer = new NotificationConsumer(pmNotifCambriaConsumer, - new PMNotificationCallback()); + new PmNotificationCallback()); // start pm notification consumer threads executorPool = Executors.newScheduledThreadPool(10); executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(), diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java deleted file mode 100644 index aede74b..0000000 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FMNotificationCallback.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * son-handler - * ================================================================================ - * Copyright (C) 2019 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.dcaegen2.services.sonhms.dmaap; - -import org.onap.dcaegen2.services.sonhms.NewFmNotification; -import org.onap.dcaegen2.services.sonhms.dao.FaultNotificationsRepository; -import org.onap.dcaegen2.services.sonhms.entity.FaultNotifications; -import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FMNotificationCallback extends NotificationCallback{ - - private static Logger log = LoggerFactory.getLogger(FMNotificationCallback.class); - - @Override - public void activateCallBack(String msg){ - handleNotification(msg); - } - - private void handleNotification(String msg) { - - FaultNotificationsRepository faultNotificationsRepository=BeanUtil - .getBean(FaultNotificationsRepository.class); - - NewFmNotification newNotification=BeanUtil.getBean(NewFmNotification.class); - FaultNotifications faultNotification = new FaultNotifications(); - faultNotification.setNotification(msg); - if (log.isDebugEnabled()) { - log.debug(faultNotification.toString()); - } - faultNotificationsRepository.save(faultNotification); - newNotification.setNewNotif(true); - } - -} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FmNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FmNotificationCallback.java new file mode 100644 index 0000000..c2231a0 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/FmNotificationCallback.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 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.dcaegen2.services.sonhms.dmaap; + +import org.onap.dcaegen2.services.sonhms.NewFmNotification; +import org.onap.dcaegen2.services.sonhms.dao.FaultNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.FaultNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FmNotificationCallback extends NotificationCallback { + + private static Logger log = LoggerFactory.getLogger(FmNotificationCallback.class); + + @Override + public void activateCallBack(String msg) { + handleNotification(msg); + } + + private void handleNotification(String msg) { + + FaultNotificationsRepository faultNotificationsRepository = BeanUtil + .getBean(FaultNotificationsRepository.class); + + + FaultNotifications faultNotification = new FaultNotifications(); + faultNotification.setNotification(msg); + if (log.isDebugEnabled()) { + log.debug(faultNotification.toString()); + } + NewFmNotification newNotification = BeanUtil.getBean(NewFmNotification.class); + faultNotificationsRepository.save(faultNotification); + newNotification.setNewNotif(true); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java index f488f03..860789a 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/NotificationCallback.java @@ -23,6 +23,6 @@ package org.onap.dcaegen2.services.sonhms.dmaap; public abstract class NotificationCallback { - public abstract void activateCallBack(String msg); - + public abstract void activateCallBack(String msg); + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java deleted file mode 100644 index 47e285a..0000000 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PMNotificationCallback.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * son-handler - * ================================================================================ - * Copyright (C) 2019 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.dcaegen2.services.sonhms.dmaap; - -import org.onap.dcaegen2.services.sonhms.NewPmNotification; -import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository; -import org.onap.dcaegen2.services.sonhms.entity.PerformanceNotifications; -import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PMNotificationCallback extends NotificationCallback { - - private static Logger log = LoggerFactory.getLogger(PMNotificationCallback.class); - - @Override - public void activateCallBack(String msg){ - handleNotification(msg); - } - - private void handleNotification(String msg) { - - PerformanceNotificationsRepository performanceNotificationsRepository=BeanUtil.getBean(PerformanceNotificationsRepository.class); - NewPmNotification newNotification=BeanUtil.getBean(NewPmNotification.class); - PerformanceNotifications performanceNotification = new PerformanceNotifications(); - performanceNotification.setNotification(msg); - log.info("Performance notification {}", performanceNotification); - performanceNotificationsRepository.save(performanceNotification); - newNotification.setNewNotif(true); - } - - -} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PmNotificationCallback.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PmNotificationCallback.java new file mode 100644 index 0000000..ea6a39f --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PmNotificationCallback.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 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.dcaegen2.services.sonhms.dmaap; + +import org.onap.dcaegen2.services.sonhms.NewPmNotification; +import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.entity.PerformanceNotifications; +import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PmNotificationCallback extends NotificationCallback { + + private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class); + + @Override + public void activateCallBack(String msg) { + handleNotification(msg); + } + + private void handleNotification(String msg) { + + PerformanceNotificationsRepository performanceNotificationsRepository = BeanUtil + .getBean(PerformanceNotificationsRepository.class); + PerformanceNotifications performanceNotification = new PerformanceNotifications(); + performanceNotification.setNotification(msg); + log.info("Performance notification {}", performanceNotification); + NewPmNotification newNotification = BeanUtil.getBean(NewPmNotification.class); + performanceNotificationsRepository.save(performanceNotification); + newNotification.setNewNotif(true); + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java index dbd9b58..d5371eb 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java @@ -22,29 +22,43 @@ package org.onap.dcaegen2.services.sonhms.dmaap; import com.att.nsa.cambria.client.CambriaBatchingPublisher; +import com.att.nsa.cambria.client.CambriaConsumer; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; +import java.sql.Timestamp; import java.util.Map; import org.onap.dcaegen2.services.sonhms.Configuration; +import org.onap.dcaegen2.services.sonhms.model.Payload; +import org.onap.dcaegen2.services.sonhms.model.PolicyNotification; import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; +import org.slf4j.Logger; public class PolicyDmaapClient { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyDmaapClient.class); + private DmaapUtils dmaapUtils; + + private Configuration configuration; + + + public PolicyDmaapClient(DmaapUtils dmaapUtils, Configuration configuration) { + this.dmaapUtils = dmaapUtils; + this.configuration = configuration; + } /** * Method stub for sending notification to policy. */ @SuppressWarnings("unchecked") public boolean sendNotificationToPolicy(String msg) { - dmaapUtils = new DmaapUtils(); - Map streamsPublishes = Configuration.getInstance().getStreamsPublishes(); + Map streamsPublishes = configuration.getStreamsPublishes(); String policyTopicUrl = ((Map) ((Map) streamsPublishes.get("CL_topic")) .get("dmaap_info")).get("topic_url"); String[] policyTopicSplit = policyTopicUrl.split("\\/"); String policyTopic = policyTopicSplit[policyTopicSplit.length - 1]; - Configuration configuration = Configuration.getInstance(); CambriaBatchingPublisher cambriaBatchingPublisher; try { @@ -57,4 +71,51 @@ public class PolicyDmaapClient { } return true; } + + /** + * Handles policy response. + */ + @SuppressWarnings("unchecked") + public Boolean handlePolicyResponse(String requestId) { + + Map streamSubscribes = configuration.getStreamsSubscribes(); + String policyResponseTopicUrl = ((Map) ((Map) streamSubscribes + .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url"); + String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/"); + String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1]; + log.debug("policyResponse Topic : {}", policyResponseTopic); + CambriaConsumer policyResponseCambriaConsumer = null; + policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic); + Timestamp startTimer = new Timestamp(System.currentTimeMillis()); + + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + Long difference = currentTime.getTime() - startTimer.getTime(); + + while (difference < 10000) { + Iterable policyResponseMessages; + try { + policyResponseMessages = policyResponseCambriaConsumer.fetch(); + for (String msg : policyResponseMessages) { + ObjectMapper mapper = new ObjectMapper(); + PolicyNotification policyResponse = mapper.readValue(msg, PolicyNotification.class); + if (requestId.equals(policyResponse.getRequestId())) { + String payload = policyResponse.getPayload(); + Payload payloadObject = mapper.readValue(payload, Payload.class); + int status = payloadObject.getConfiguration().get(0).getStatus().getCode(); + String statusToString = Integer.toString(status); + log.info("response from policy, status code {}", statusToString); + + } + return true; + } + } catch (IOException e) { + log.info("caught io exception while fetching policy response"); + } + currentTime = new Timestamp(System.currentTimeMillis()); + difference = currentTime.getTime() - startTimer.getTime(); + } + log.info("no response from policy, timer expired"); + return true; + + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java index 30a6c0e..67981d7 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/entity/PerformanceNotifications.java @@ -33,8 +33,8 @@ import org.hibernate.annotations.CreationTimestamp; @Entity @Table(name = "PERFORMANCE_NOTIFICATIONS") public class PerformanceNotifications { - - @Id + + @Id @Column(name = "notification", columnDefinition = "text") private String notification; @@ -67,5 +67,4 @@ public class PerformanceNotifications { this.createdAt = createdAt; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java index 15a93e9..c55c6d6 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AdditionalMeasurements.java @@ -24,30 +24,33 @@ package org.onap.dcaegen2.services.sonhms.model; import java.util.Map; public class AdditionalMeasurements { - + String name; - Map hashMap ; - + Map hashMap; + public AdditionalMeasurements() { - + } + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public Map getHashMap() { return hashMap; } + public void setHashMap(Map hashMap) { this.hashMap = hashMap; } + @Override public String toString() { return "AdditionalMeasurements [name=" + name + ", hashMap=" + hashMap + "]"; } - - - + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java index faff91e..07a2923 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/AnrInput.java @@ -27,10 +27,11 @@ public class AnrInput { String cellId; List removeableNeighbors; - + public AnrInput() { - + } + /** * Parameterized Constructor. */ @@ -40,18 +41,21 @@ public class AnrInput { this.cellId = cellId; this.removeableNeighbors = removeableNeighbors; } + public String getCellId() { return cellId; } + public void setCellId(String cellId) { this.cellId = cellId; } + public List getRemoveableNeighbors() { return removeableNeighbors; } + public void setRemoveableNeighbors(List removeableNeighbors) { this.removeableNeighbors = removeableNeighbors; } - - + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java index 415b7d9..686666c 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Configurations.java @@ -27,6 +27,9 @@ public class Configurations { @JsonProperty("data") private Data data; + @JsonProperty("Status") + private Status status; + /** * constructor. * @@ -34,22 +37,31 @@ public class Configurations { public Configurations() { } + /** * Parameterized constructor. * */ - public Configurations(Data data) { + public Configurations(Data data, Status status) { super(); this.data = data; + this.status = status; } + public Data getData() { return data; } + public void setData(Data data) { this.data = data; } - - + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java index ecc2048..1d43f09 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/HoDetails.java @@ -22,43 +22,49 @@ package org.onap.dcaegen2.services.sonhms.model; public class HoDetails { - + private String dstCellId; private int attemptsCount; private int successCount; private float successRate; - + /** - * default constructor + * default constructor. */ public HoDetails() { - + } - + public String getDstCellId() { return dstCellId; } + public void setDstCellId(String dstCellId) { this.dstCellId = dstCellId; } + public int getAttemptsCount() { return attemptsCount; } + public void setAttemptsCount(int attemptsCount) { this.attemptsCount = attemptsCount; } + public int getSuccessCount() { return successCount; } + public void setSuccessCount(int successCount) { this.successCount = successCount; } + public float getSuccessRate() { return successRate; } + public void setSuccessRate(float successRate) { this.successRate = successRate; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java index f1cae93..ce9099b 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/LteNeighborListInUseLteCell.java @@ -24,6 +24,7 @@ package org.onap.dcaegen2.services.sonhms.model; import com.fasterxml.jackson.annotation.JsonProperty; public class LteNeighborListInUseLteCell { + @JsonProperty("pnfName") private String pnfName; @@ -52,6 +53,9 @@ public class LteNeighborListInUseLteCell { } + /** + * constructor. + */ public LteNeighborListInUseLteCell(String pnfName, String enable, String alias, String mustInclude, String plmnId, String cid, int phyCellId, String blacklisted) { super(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/MeasurementFields.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/MeasurementFields.java index bdd8641..477a2d3 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/MeasurementFields.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/MeasurementFields.java @@ -27,15 +27,16 @@ public class MeasurementFields { String measurementInterval; String measurementFieldsVersion; - + List additionalMeasurements; - + /** - * default constructor + * default constructor. */ public MeasurementFields() { - + } + public String getMeasurementInterval() { return measurementInterval; } @@ -51,13 +52,13 @@ public class MeasurementFields { public void setAdditionalMeasurements(List additionalMeasurements) { this.additionalMeasurements = additionalMeasurements; } - + public String getMeasurementFieldsVersion() { return measurementFieldsVersion; } + public void setMeasurementFieldsVersion(String measurementFieldsVersion) { this.measurementFieldsVersion = measurementFieldsVersion; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java deleted file mode 100644 index 076be31..0000000 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PMNotification.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * son-handler - * ================================================================================ - * Copyright (C) 2019 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.dcaegen2.services.sonhms.model; - -public class PMNotification { - - Event event; - - /** - * default constructor - */ - public PMNotification() { - - } - - public Event getEvent() { - return event; - } - public void setEvent(Event event) { - this.event = event; - } - - - -} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PmNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PmNotification.java new file mode 100644 index 0000000..17b794e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PmNotification.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 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.dcaegen2.services.sonhms.model; + +public class PmNotification { + + Event event; + + /** + * default constructor. + */ + public PmNotification() { + + } + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java index e432b0c..16f7518 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java @@ -32,7 +32,7 @@ public class PolicyNotification { private long closedLoopAlarmStart; private String closedLoopEventClient; private String closedLoopEventStatus; - + @JsonProperty("target_type") private String targetType; @@ -46,6 +46,9 @@ public class PolicyNotification { private String from; private String version; + + private String policyName; + private String policyVersion; @JsonProperty("Action") private String action; @@ -60,9 +63,9 @@ public class PolicyNotification { /** * Constructor. - * */ - public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, String action) { + public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, + String action) { this.closedLoopControlName = closedLoopControlName; this.requestId = requestId; this.closedLoopEventClient = "microservice.PCI"; @@ -210,6 +213,22 @@ public class PolicyNotification { } return (this.hashCode() == obj.hashCode()); } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getPolicyVersion() { + return policyVersion; + } + + public void setPolicyVersion(String policyVersion) { + this.policyVersion = policyVersion; + } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java new file mode 100644 index 0000000..8f35b50 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Status.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019 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.dcaegen2.services.sonhms.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +public class Status { + @JsonProperty("Code") + private int code; + + @JsonProperty("Value") + private String value; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java index 117f202..042603a 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/AnrSolutions.java @@ -25,14 +25,17 @@ import java.util.ArrayList; import java.util.List; public class AnrSolutions { - + String cellId; List removeableNeighbors = new ArrayList<>(); - + public AnrSolutions() { - + } - + + /** + * constructor. + */ public AnrSolutions(String cellId, List removeableNeighbors) { super(); this.cellId = cellId; @@ -42,19 +45,22 @@ public class AnrSolutions { public String getCellId() { return cellId; } + public void setCellId(String cellId) { this.cellId = cellId; } + public List getRemoveableNeighbors() { return removeableNeighbors; } + public void setRemoveableNeighbors(List removeableNeighbors) { this.removeableNeighbors = removeableNeighbors; } + @Override public String toString() { return "AnrSolutions [cellId=" + cellId + ", removeableNeighbors=" + removeableNeighbors + "]"; } - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java index 0f6dd98..97668ed 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.onap.dcaegen2.services.sonhms.ConfigPolicy; import org.onap.dcaegen2.services.sonhms.Configuration; import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException; import org.onap.dcaegen2.services.sonhms.model.AnrInput; @@ -73,13 +72,7 @@ public class OofRestClient { Map callbackHeader = new HashMap<>(); callbackHeader.put("Content-Type", "application/json"); requestInfo.setCallbackHeader(callbackHeader); - ConfigPolicy config = ConfigPolicy.getInstance(); int timeout = 60; - try { - timeout = (int) config.getConfig().get("PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS"); - } catch (NullPointerException e) { - log.debug("No config policy available. Using default timeout 60 sec"); - } requestInfo.setTimeout(timeout); CellInfo cellInfo = new CellInfo(); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java index eec3fd8..039285c 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/PciSolutions.java @@ -27,8 +27,9 @@ public class PciSolutions { int pci; public PciSolutions() { - + } + public String getCellId() { return cellId; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java index 8e694a3..c39a20d 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/Solutions.java @@ -25,14 +25,15 @@ import java.util.ArrayList; import java.util.List; public class Solutions { - + String networkId = null; List pciSolutions = new ArrayList<>(); List anrSolutions = new ArrayList<>(); - + public Solutions() { - + } + public String getNetworkId() { return networkId; } @@ -53,6 +54,7 @@ public class Solutions { this.pciSolutions = pciSolutions; } + public List getAnrSolutions() { return anrSolutions; } @@ -67,7 +69,4 @@ public class Solutions { + "]"; } - - - } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java index a25fd54..7228f78 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/utils/ClusterUtils.java @@ -177,7 +177,7 @@ public class ClusterUtils { /** * Get clusters for FM Cell. */ - public Either getClusterForFMCell(String cellId, List newClusters) { + public Either getClusterForFmCell(String cellId, List newClusters) { if (newClusters.isEmpty()) { log.info("getClusterForFMCell 404"); return Either.right(404); @@ -222,8 +222,10 @@ public class ClusterUtils { return clusterCells; } - // generic create cluster for both fm and sdnr - + + /** + * Create cluster. + */ public Graph createCluster(Map> clusterMap) throws ConfigDbNotFoundException { Graph cluster = new Graph(); -- cgit 1.2.3-korg