From 4949855dff35b340038bffc489b1e68f340cf5ce Mon Sep 17 00:00:00 2001 From: malar Date: Wed, 9 Nov 2022 11:21:02 +0000 Subject: Modify ANR Payload aligned to A1 schema in SDNR Issue-ID: DCAEGEN2-3311 Signed-off-by: Malarvizhi Paramasivam Change-Id: I809f59972b207b1a9e68f0a2339514b6c7761bb7 --- .../dcaegen2/services/sonhms/Configuration.java | 12 +- .../services/sonhms/PmNotificationHandler.java | 21 ++- .../services/sonhms/child/ChildThreadUtils.java | 2 +- .../dcaegen2/services/sonhms/model/A1Payload.java | 56 +++++++ .../dcaegen2/services/sonhms/model/ANRPayload.java | 176 ++++++++++++++------- .../onap/dcaegen2/services/sonhms/model/Input.java | 70 ++++++++ .../dcaegen2/services/sonhms/model/Neighbours.java | 9 +- .../dcaegen2/services/sonhms/model/PolicyData.java | 10 ++ .../services/sonhms/restclient/CpsClient.java | 10 +- .../services/sonhms/restclient/CpsClientTest.java | 8 +- 10 files changed, 300 insertions(+), 74 deletions(-) create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/A1Payload.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Input.java (limited to 'src') diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java index ce8e016..a2ed3c0 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -53,6 +53,7 @@ public class Configuration { private String getPciUrl; private String getPnfUrl; private String getRicIdUrl; + private String nearRtricUrl; private String oofService; private String oofEndpoint; private String cg; @@ -470,6 +471,14 @@ public class Configuration { return getRicIdUrl; } + public void setNearRtricUrl(String nearRtricUrl) { + this.nearRtricUrl = nearRtricUrl; + } + + public String getNearRtricUrl() { + return nearRtricUrl; + } + public static void setInstance(Configuration instance) { Configuration.instance = instance; } @@ -479,7 +488,7 @@ public class Configuration { return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cpsServiceUrl=" + cpsServiceUrl + ", CpsUsername=" + CpsUsername + ",CpsPassword=" + CpsPassword + ",ConfigClientType=" + ConfigClientType + ", getCellDataUrl=" + getCellDataUrl + ", getNbrListUrl=" - + getNbrListUrl + ", getPciUrl=" + getPciUrl + ", getPnfUrl=" + getPnfUrl + ", getRicIdUrl=" + getRicIdUrl + ",oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid + + getNbrListUrl + ", getPciUrl=" + getPciUrl + ", getPnfUrl=" + getPnfUrl + ", getRicIdUrl=" + getRicIdUrl + ", nearRtricUrl=" + nearRtricUrl + ",oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion=" + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", pciOptimizer=" + pciOptimizer + ", pciAnrOptimizer=" + pciAnrOptimizer @@ -557,6 +566,7 @@ public class Configuration { getPnfUrl = jsonObject.get("cps.get.pnf.url").getAsString(); getPciUrl = jsonObject.get("cps.get.pci.url").getAsString(); getNbrListUrl = jsonObject.get("cps.get.nbr.list.url").getAsString(); + nearRtricUrl = jsonObject.get("sonhandler.nearRtricUrl").getAsString(); ConfigClientType = jsonObject.get("sonhandler.clientType").getAsString(); log.info("configuration from CBS {}", this); 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 a1127fe..ce50090 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java @@ -32,12 +32,14 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import org.onap.dcaegen2.services.sonhms.Configuration; import org.onap.dcaegen2.services.sonhms.child.ChildThreadUtils; import org.onap.dcaegen2.services.sonhms.child.PnfUtils; import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository; import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics; import org.onap.dcaegen2.services.sonhms.model.AdditionalMeasurements; +import org.onap.dcaegen2.services.sonhms.model.A1Payload; import org.onap.dcaegen2.services.sonhms.model.ANRPayload; import org.onap.dcaegen2.services.sonhms.model.CellConfig; import org.onap.dcaegen2.services.sonhms.model.Common; @@ -46,6 +48,7 @@ import org.onap.dcaegen2.services.sonhms.model.Data; import org.onap.dcaegen2.services.sonhms.model.FapService; import org.onap.dcaegen2.services.sonhms.model.Flag; import org.onap.dcaegen2.services.sonhms.model.HoDetails; +import org.onap.dcaegen2.services.sonhms.model.Input; import org.onap.dcaegen2.services.sonhms.model.Lte; import org.onap.dcaegen2.services.sonhms.model.LteCell; import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; @@ -65,6 +68,7 @@ public class PmNotificationHandler { private static Logger log = LoggerFactory.getLogger(PmNotificationHandler.class); PolicyDmaapClient policyDmaapClient; + Configuration configuration = Configuration.getInstance(); public PmNotificationHandler() { @@ -108,7 +112,7 @@ public class PmNotificationHandler { .getAdditionalMeasurements()) { int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO")); int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO")); - int successRate = (int)((float) successCount / attemptsCount) * 100; + int successRate = (int)(((float) successCount / attemptsCount) * 100); Neighbours neighbourCell = new Neighbours(); neighbourCell.setHoKpi(successRate); @@ -158,21 +162,25 @@ public class PmNotificationHandler { ObjectMapper mapper = new ObjectMapper(); try { mapper.setSerializationInclusion(Include.NON_NULL); + String nearRtricUrl = configuration.getNearRtricUrl(); String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); String pnfName = pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(); String plmnId = pmNotification.getEvent().getMeasurementFields() .getAdditionalMeasurements().get(0).getHashMap().get("networkId"); - String ric_id = CpsClient.getRicId(cellId); - ANRPayload payload = new ANRPayload("CreatePolicy",1,1,ric_id, - (new PolicyData(pnfName,plmnId,cellId,neighbourList))); - log.info("payload : {}", payload); + UUID uuid = UUID.randomUUID(); + + A1Payload payload = new A1Payload(new Input(nearRtricUrl, + new ANRPayload(uuid.toString(),"ANR","a1-terminator", + new PolicyData(pnfName,plmnId,cellId,neighbourList),"",false,""))); + String anrUpdateString = mapper.writeValueAsString(payload); + log.info("After converting A1Paylod to String: " + anrUpdateString); ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(), new PolicyDmaapClient(new DmaapUtils(), Configuration.getInstance()), new HoMetricsComponent()); String requestId = UUID.randomUUID().toString(); String notification = childUtils.getNotificationString( pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId, - anrUpdateString, System.currentTimeMillis(), "ModifyA1Policy"); + anrUpdateString, System.currentTimeMillis(), "putA1Policy"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); @@ -201,3 +209,4 @@ public class PmNotificationHandler { return true; } } + 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 61653cf..524fabc 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 @@ -275,7 +275,7 @@ public class ChildThreadUtils { } String requestId = UUID.randomUUID().toString(); String notification = getNotificationString(pnfName, requestId, payloadString, - System.currentTimeMillis(), "ModifyA1Policy"); + System.currentTimeMillis(), "putA1Policy"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/A1Payload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/A1Payload.java new file mode 100644 index 0000000..51764ae --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/A1Payload.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 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; + +import java.util.List; + +public class A1Payload { + + @JsonProperty("input") + private Input input; + + public A1Payload() { + + } + + public A1Payload(Input input) { + super(); + this.input = input; + } + + public Input getInput() { + return input; + } + + public void setInput(Input input) { + this.input = input; + } + + @Override + public String toString() { + return "Payload [input=" + input + "]"; + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java index c8ff5e4..0debdad 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java @@ -31,85 +31,141 @@ import java.util.List; public class ANRPayload { - @JsonProperty("action") - private String action; + @JsonProperty("policy_id") + private String policy_id; - @JsonProperty("policy_id") - private int policy_id; + @JsonProperty("policytype_id") + private String policy_type_id; - @JsonProperty("policy_type_id") - private int policy_type_id; + @JsonProperty("ric_id") + private String ric_id; - @JsonProperty("ric_id") - private String ric_id; + @JsonProperty("policy_data") + private PolicyData policy_data; - @JsonProperty("policy_data") - private PolicyData policy_data; + @JsonProperty("service_id") + private String service_id; - /** - * Constructor - */ + @JsonProperty("transient") + private boolean transient1; - public ANRPayload() { + @JsonProperty("status_notification_uri") + private String status; - } + /** + * Constructor + */ - /** - * Constructor - */ + public ANRPayload() { - public ANRPayload(String action, int policy_id, int policy_type_id, String ric_id, PolicyData policy_data) { - super(); - this.action = action; - this.policy_id = policy_id; - this.policy_type_id = policy_type_id; - this.ric_id = ric_id; - this.policy_data=policy_data; - } + } - public String getAction() { - return action; - } + - public void setAction(String action) { - this.action = action; - } + public ANRPayload(String policy_id, String policy_type_id, String ric_id, PolicyData policy_data, + String service_id, boolean transient1, String status) { + super(); + this.policy_id = policy_id; + this.policy_type_id = policy_type_id; + this.ric_id = ric_id; + this.policy_data = policy_data; + this.service_id = service_id; + this.transient1 = transient1; + this.status = status; + } - public int getPolicyId(){ - return policy_id; - } - public void setPolicyId(int policy_id){ - this.policy_id = policy_id; - } + public String getPolicy_id() { + return policy_id; + } - public int getPolicyTypeId(){ - return policy_type_id; - } - public void setPolicyTypeId(int policy_type_id){ - this.policy_type_id = policy_type_id; - } - public String getRicId(){ - return ric_id; - } + public void setPolicy_id(String policy_id) { + this.policy_id = policy_id; + } - public void setRicId(String ric_id){ - this.ric_id = ric_id; - } - public PolicyData getPolicyData(){ - return policy_data; - } - public void setPolicyData(PolicyData policy_data){ - this.policy_data = policy_data; - } + public String getPolicy_type_id() { + return policy_type_id; + } - @Override - public String toString() { - return "Payload [=" + action + "]"; - } + + public void setPolicy_type_id(String policy_type_id) { + this.policy_type_id = policy_type_id; + } + + + + public String getRic_id() { + return ric_id; + } + + + + public void setRic_id(String ric_id) { + this.ric_id = ric_id; + } + + + + public PolicyData getPolicy_data() { + return policy_data; + } + + + + public void setPolicy_data(PolicyData policy_data) { + this.policy_data = policy_data; + } + + + + public String getService_id() { + return service_id; + } + + + + public void setService_id(String service_id) { + this.service_id = service_id; + } + + + + public boolean isTransient1() { + return transient1; + } + + + + public void setTransient1(boolean transient1) { + this.transient1 = transient1; + } + + + + public String getStatus() { + return status; + } + + + + public void setStatus(String status) { + this.status = status; + } + + + + @Override + public String toString() { + return "ANRPayload [ policy_id=" + policy_id + ", policy_type_id=" + policy_type_id + + ", ric_id=" + ric_id + ", policy_data=" + policy_data + ", service_id=" + service_id + ", transient1=" + + transient1 + ", status=" + status + "]"; + } + + } + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Input.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Input.java new file mode 100644 index 0000000..e0df78a --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Input.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 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 Input { + + @JsonProperty(value = "near-rt-ric-url") + private String url; + + @JsonProperty("body") + private ANRPayload anrPayload; + + public Input() { + + } + + /** + * Parameterized constructor. + */ + public Input(String url, ANRPayload anrPayload) { + super(); + this.url = url; + this.anrPayload = anrPayload; + } + + + public String getUrl() { + return url; + } + + + public void setUrl(String url) { + this.url = url; + } + + public ANRPayload getAnrPayload(){ + return anrPayload; + } + + public void setAnrPayload(ANRPayload anrPayload){ + this.anrPayload = anrPayload; + } + + @Override + public String toString() { + return "Input [url=" + url + ", anrPayload=" + anrPayload + "]"; + } +} + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java index 73c3cd5..f38ccaa 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java @@ -88,7 +88,14 @@ public class Neighbours { } public void setHoKpi(int hoKpi) { - this.hoKpi = hoKpi; + this.hoKpi = hoKpi; + } + + @Override + public String toString() { + return "Neighbours [pnfName=" + pnfName + ", plmnId=" + plmnId + ", cellId=" + cellId + ", hoKpi=" + hoKpi + + "]"; } } + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java index ff5b48e..6eec6a5 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java @@ -86,4 +86,14 @@ public class PolicyData { this.neighbours=neighbours; } + @Override + public String toString() { + return "PolicyData [pnfName=" + pnfName + ", plmnId=" + plmnId + ", cellId=" + cellId + ", neighbours=" + + neighbours + "]"; + } + + + + } + diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java index caf94f1..2fa9514 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java @@ -139,14 +139,20 @@ public class CpsClient extends ConfigInterface { public static String getRicId(String cellId) throws CpsNotFoundException { Configuration configuration = Configuration.getInstance(); + String responseObject = ""; String requestUrl = configuration.getCpsServiceUrl() + "/" + configuration.getGetRicIdUrl(); JSONObject inputparam = new JSONObject(); JSONObject reqbody = new JSONObject(); inputparam.put("cellId", cellId); reqbody.put("inputParameters", inputparam); String response = sendRequest(requestUrl, reqbody); - JSONObject responseObject = new JSONObject(response); - return responseObject.getString("idNearRTRIC"); + log.info("Response from CPS is : " + response); + JSONArray requestArray = new JSONArray(response); + for (int i=0;i