From 59ec623b673959cb44937ba601abbe15c9b4501e Mon Sep 17 00:00:00 2001 From: vvarvate Date: Tue, 29 Nov 2022 00:30:51 +0530 Subject: INT-2142 RAN App Integration with A1 Terminator RAN App will interact with A1 Terminator to start receiving A1 Policies Added license Anotations for all files Issue-ID: INT-2129 Signed-off-by: vvarvate Change-Id: I61c90086b87766119ba7939a06e93bd2e7d22bad --- ANR-App/README.md | 15 +++ ANR-App/config/application.properties | 10 +- ANR-App/pom.xml | 3 +- .../java/org/onap/ranapp/WebclientApplication.java | 17 ++- .../ranapp/controller/A1Controller_OSC_2_1_0.java | 16 ++- .../org/onap/ranapp/data/PolicyNotification.java | 9 +- .../ranapp/data/PolicyNotificationActionEnum.java | 9 +- .../kafka/client/KafkaClientRanappTopic.java | 29 +++-- .../ranapp/kafka/listener/RanAppEventConsumer.java | 65 +++++---- .../kafka/model/appmodels/ANRInputMessage.java | 15 +++ .../kafka/model/appmodels/ANROutputMessage.java | 15 +++ .../org/onap/ranapp/kafka/model/appmodels/Aai.java | 15 +++ .../appmodels/AppDescriptorKafkaTemplate.java | 17 ++- .../ranapp/kafka/model/appmodels/CellConfig.java | 15 +++ .../onap/ranapp/kafka/model/appmodels/Common.java | 15 +++ .../kafka/model/appmodels/Configuration.java | 15 +++ .../onap/ranapp/kafka/model/appmodels/Data.java | 28 ++-- .../ranapp/kafka/model/appmodels/FAPService.java | 15 +++ .../org/onap/ranapp/kafka/model/appmodels/LTE.java | 15 +++ .../onap/ranapp/kafka/model/appmodels/LTECell.java | 15 +++ .../kafka/model/appmodels/NeighborListInUse.java | 15 +++ .../ranapp/kafka/model/appmodels/Neighbour.java | 15 +++ .../onap/ranapp/kafka/model/appmodels/Payload.java | 145 +++++++++++---------- .../kafka/model/appmodels/PayloadOutput.java | 15 +++ .../ranapp/kafka/model/appmodels/PolicyData.java | 76 ----------- .../model/appmodels/PolicytypetoTopicMapping.java | 18 ++- .../org/onap/ranapp/kafka/model/appmodels/RAN.java | 15 +++ .../ranapp/kafka/model/appmodels/ResponsetoA1.java | 2 - .../java/org/onap/ranapp/models/DeviceData.java | 20 +-- .../org/onap/ranapp/models/DeviceDataDecoder.java | 19 +-- .../org/onap/ranapp/models/DeviceDataEncoder.java | 20 +-- .../java/org/onap/ranapp/models/MessageType.java | 2 +- .../org/onap/ranapp/websocket/WebsocketClient.java | 36 +---- 33 files changed, 444 insertions(+), 307 deletions(-) delete mode 100644 ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicyData.java diff --git a/ANR-App/README.md b/ANR-App/README.md index a2bb5f8..63aa48c 100644 --- a/ANR-App/README.md +++ b/ANR-App/README.md @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ RAN App - abstraction of xApp functionality A new RAN App module in RAN-Sim is an abstraction of the function provided by an xApp to support A1-based actions. For Kohn release, RAN App will provide the following functions to support A1-based action for the ANR SON use case: 1.Receive A1 policy message over Kafka bus from A1 Termination diff --git a/ANR-App/config/application.properties b/ANR-App/config/application.properties index 947987e..c319429 100644 --- a/ANR-App/config/application.properties +++ b/ANR-App/config/application.properties @@ -1,14 +1,14 @@ server.port=9091 -kafka.bootstrapAddress=localhost:9092 -spring.kafka.producer.bootstrap-servers=localhost:9092 +kafka.bootstrapAddress=10.31.4.44:9092 +#spring.kafka.producer.bootstrap-servers=10.31.4.44:9092 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer ranapp.testing.topic.name=xapptest-topic -ranapp.testing.topic.id=group1 +ranapp.testing.topic.id=testtopic restapi.version=v1 -websocketserver.address=43.204.239.187:8081 +websocketserver.address=10.31.4.44:8081 websocketserver.endpoint=/ransim/RansimAgent/ANR-xAPP:9091 ranapp.name=ANR-RanAPP:9091 ranapp.policytype=ANR ranapp.hokpi1_threshold=100 -kafkadispatcher.url=http://localhost:7075/policytypetotopicmapping/ +kafkadispatcher.url=http://10.31.4.44:7075/policytypetotopicmapping/ diff --git a/ANR-App/pom.xml b/ANR-App/pom.xml index 7006923..b2110be 100644 --- a/ANR-App/pom.xml +++ b/ANR-App/pom.xml @@ -13,7 +13,7 @@ ranapp ranapp project on spring boot for creating websocket client and netconf client - + 16 nexus3.onap.org:10001 nexus3.onap.org:10003 @@ -64,7 +64,6 @@ 20200518 - docker diff --git a/ANR-App/src/main/java/org/onap/ranapp/WebclientApplication.java b/ANR-App/src/main/java/org/onap/ranapp/WebclientApplication.java index e63c141..5c2fbc8 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/WebclientApplication.java +++ b/ANR-App/src/main/java/org/onap/ranapp/WebclientApplication.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp; import org.springframework.context.ApplicationContext; import org.onap.ranapp.kafka.client.KafkaClientRanappTopic; @@ -11,12 +26,10 @@ import org.springframework.context.annotation.Bean; public class WebclientApplication { @Autowired private WebsocketClient websocketClient; - @Autowired private KafkaClientRanappTopic kafkaclient; public static void main(String[] args) { SpringApplication.run(WebclientApplication.class, args); - } /* *Starts the Websocket client service. @param ctx the diff --git a/ANR-App/src/main/java/org/onap/ranapp/controller/A1Controller_OSC_2_1_0.java b/ANR-App/src/main/java/org/onap/ranapp/controller/A1Controller_OSC_2_1_0.java index 1fa8f07..f4f1cbb 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/controller/A1Controller_OSC_2_1_0.java +++ b/ANR-App/src/main/java/org/onap/ranapp/controller/A1Controller_OSC_2_1_0.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.controller; import java.io.IOException; import java.net.URISyntaxException; @@ -55,5 +70,4 @@ public class A1Controller_OSC_2_1_0 { throws URISyntaxException { return null; } - } \ No newline at end of file diff --git a/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotification.java b/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotification.java index e3907a5..1884138 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotification.java +++ b/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotification.java @@ -1,14 +1,17 @@ /* - * Copyright (C) 2021 Samsung Electronics + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * * 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 + * 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 + * limitations under the License. */ package org.onap.ranapp.data; import lombok.AllArgsConstructor; diff --git a/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotificationActionEnum.java b/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotificationActionEnum.java index e77a4ad..60a50d3 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotificationActionEnum.java +++ b/ANR-App/src/main/java/org/onap/ranapp/data/PolicyNotificationActionEnum.java @@ -1,14 +1,17 @@ /* - * Copyright (C) 2021 Samsung Electronics + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * * 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 + * 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 + * limitations under the License. */ package org.onap.ranapp.data; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/client/KafkaClientRanappTopic.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/client/KafkaClientRanappTopic.java index e80b8e1..090fbfd 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/client/KafkaClientRanappTopic.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/client/KafkaClientRanappTopic.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.kafka.client; import java.util.Arrays; import java.util.Properties; @@ -22,31 +37,22 @@ import lombok.Getter; import reactor.core.Disposable; @Component public class KafkaClientRanappTopic { - private static final Logger logger = LoggerFactory.getLogger(KafkaClientRanappTopic.class); - @Value("${kafkadispatcher.url}") private String kafkaclient_url; @Value("${ranapp.policytype}") private String policytype_name; - @Value(value = "${kafka.bootstrapAddress}") private String bootstrapAddress; @Value(value = "${ranapp.testing.topic.id}") private String groupId; - public static String requestTopicName = ""; - public static String responseTopicName = ""; - @Getter(AccessLevel.PROTECTED) private Disposable refreshTask = null; - @Autowired RanAppEventConsumer ranappeventconsumer; - private RestTemplate restTemplate = new RestTemplate(); - @Bean public RetryTemplate retryTemplate() { int maxAttempt = Integer.parseInt("10"); @@ -60,22 +66,18 @@ public class KafkaClientRanappTopic { template.setBackOffPolicy(backOffPolicy); return template; } - public void getRanApp_KafkaTopicnames() { logger.info("Requesting for KafkaTopics"); stop(); refreshTask=retryTemplate().execute(context -> { String url = kafkaclient_url + policytype_name ; System.out.println("retrying Connection: "+url); - - ResponseEntity requestData = restTemplate.getForEntity(url, PolicytypetoTopicMapping.class); PolicytypetoTopicMapping policytoTopicMapping=requestData.getBody(); requestTopicName=policytoTopicMapping.getRequest_topic(); responseTopicName=policytoTopicMapping.getResponse_topic(); logger.info("Request Topic for Policy "+ policytype_name +" "+ requestTopicName); logger.info("Response Topic for Policy "+ policytype_name +" "+ responseTopicName); - Properties properties=new Properties(); properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,bootstrapAddress); properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); @@ -91,7 +93,6 @@ public class KafkaClientRanappTopic { throw new IllegalStateException("Something went wrong"); }); } - public void stop() { if (refreshTask != null) { refreshTask.dispose(); diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/listener/RanAppEventConsumer.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/listener/RanAppEventConsumer.java index 037dd54..b251f0f 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/listener/RanAppEventConsumer.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/listener/RanAppEventConsumer.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.kafka.listener; import java.time.Duration; import java.util.LinkedList; @@ -34,25 +49,17 @@ public class RanAppEventConsumer { private final Logger logger = LoggerFactory.getLogger(RanAppEventConsumer.class); public RanAppEventConsumer() { } - - @Value("${ranapp.hokpi1_threshold}") private int hokpiThreshold; - @Value(value = "${kafka.bootstrapAddress}") private String bootstrapAddress; ObjectMapper objectMapper = new ObjectMapper(); - @Autowired KafkaTemplate Kafkatemplate; - @Autowired WebsocketClient websocketclient; - ResponsetoA1 response=new ResponsetoA1(); - - public static String requestTopicName,responseTopicName; - + public static String requestTopicName,responseTopicName,kafkakeyName; //@KafkaListener(topics = "#{topicUtil.suffixTopics()}", groupId = "${ranapp.testing.topic.id}", containerFactory = "kafkaListenerFactory") public void consume(KafkaConsumer consumer, String requesttopicName, String responsetopicName) { try { @@ -60,15 +67,17 @@ public class RanAppEventConsumer { responseTopicName=responsetopicName; WebsocketClient.requestTopicName=requesttopicName; WebsocketClient.responseTopicName=responsetopicName; - while(true){ - ConsumerRecords records=consumer.poll(Duration.ofMillis(1000)); + ConsumerRecords records=consumer.poll(Duration.ofMillis(5000)); for(ConsumerRecord record: records){ - logger.info("Key: "+ record.key() + ", Value:" +record.value()); + String msg=record.value().translateEscapes().strip().stripIndent().trim().replaceAll("(?m)^[ \t]*\r?\n", ""); + msg=msg.substring( 1, msg.length() - 1 ); + logger.info("Key: "+ record.key() + ", Value:" +msg); logger.info("Partition:" + record.partition()+",Offset:"+record.offset()); - JSONObject obj_name = new JSONObject(record.value()); + JSONObject obj_name = new JSONObject(msg); logger.info(String.format("ranapp message recieved \n-> %s \n", obj_name)); - + kafkakeyName=record.key(); + WebsocketClient.kafkakeyName=record.key(); ANRInputMessage ANRInputMessage=null; try { logger.info(String.format("Parsing the incoming json object to ANRInputMessage class")); @@ -77,7 +86,6 @@ public class RanAppEventConsumer { logger.info(String.format( "Invalid Message received . Exception while parsing JSON object -> %s", ex.getLocalizedMessage())); - ex.printStackTrace(); return; } @@ -86,14 +94,12 @@ public class RanAppEventConsumer { ANROutputMessage ANROutputMessage= convertInputMessagetoANROutput(ANRInputMessage); logger.info(String.format("ANROutputMessage")); logger.info(String.format(objectMapper.writeValueAsString(ANROutputMessage))); - // Output Payload is sent as Websocket message to RC DeviceData devicedata=new DeviceData(); devicedata.setMessage(objectMapper.writeValueAsString(ANROutputMessage.getPayload())); devicedata.setType(MessageType.KAFKA_MSG); logger.info(String.format("Sending Output Payload to RC WS Server")); websocketclient.sendMessage(devicedata); - } catch (Exception e) { e.getLocalizedMessage(); e.printStackTrace(); @@ -108,9 +114,6 @@ public class RanAppEventConsumer { // TODO Auto-generated method stub logger.info(String.format("Creating OutputMessage from ANRInput Function")); ANROutputMessage ANROutputMessage=new ANROutputMessage(); - - - logger.info(String.format("initializing output parameters")); //initializing Output Params PayloadOutput payloadOutput=new PayloadOutput(); @@ -124,21 +127,18 @@ public class RanAppEventConsumer { Common common=new Common(); NeighborListInUse neighbourlistinuse=new NeighborListInUse(); List listltecell=new LinkedList(); - - - logger.info(String.format("Iterating Neighbour cells to validate KPI")); // Parsing the payload.policydata into output message payload - common.setCellIdentity(ANRInputMessage.getPayload().getPolicyData().getCellID()); - int length=ANRInputMessage.getPayload().getPolicyData().getNeighbours().size(); + common.setCellIdentity(ANRInputMessage.getPayload().getCellID()); + int length=ANRInputMessage.getPayload().getNeighbours().size(); for(int i=0;i additionalProperties = new HashMap(); -@JsonProperty("action") -public String getAction() { -return action; -} -@JsonProperty("action") -public void setAction(String action) { -this.action = action; -} -@JsonProperty("policy_id") -public Integer getPolicyId() { -return policyId; -} -@JsonProperty("policy_id") -public void setPolicyId(Integer policyId) { -this.policyId = policyId; -} -@JsonProperty("policy_type_id") -public Integer getPolicyTypeId() { -return policyTypeId; -} -@JsonProperty("policy_type_id") -public void setPolicyTypeId(Integer policyTypeId) { -this.policyTypeId = policyTypeId; -} -@JsonProperty("ric_id") -public String getRicId() { -return ricId; -} -@JsonProperty("ric_id") -public void setRicId(String ricId) { -this.ricId = ricId; -} -@JsonProperty("policy_data") -public PolicyData getPolicyData() { -return policyData; -} -@JsonProperty("policy_data") -public void setPolicyData(PolicyData policyData) { -this.policyData = policyData; -} -@JsonAnyGetter -public Map getAdditionalProperties() { -return this.additionalProperties; -} -@JsonAnySetter -public void setAdditionalProperty(String name, Object value) { -this.additionalProperties.put(name, value); -} -@Override -public String toString() { - return "Payload [action=" + action + ", policyId=" + policyId + ", policyTypeId=" + policyTypeId + ", ricId=" - + ricId + ", policyData=" + policyData + "]"; -} + @JsonProperty("PNFName") + private String pNFName; + @JsonProperty("PLMNID") + private String plmnid; + @JsonProperty("CellID") + private String cellID; + @JsonProperty("neighbours") + private List neighbours = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + @JsonProperty("PNFName") + public String getPNFName() { + return pNFName; + } + @JsonProperty("PNFName") + public void setPNFName(String pNFName) { + this.pNFName = pNFName; + } + @JsonProperty("PLMNID") + public String getPlmnid() { + return plmnid; + } + @JsonProperty("PLMNID") + public void setPlmnid(String plmnid) { + this.plmnid = plmnid; + } + @JsonProperty("CellID") + public String getCellID() { + return cellID; + } + @JsonProperty("CellID") + public void setCellID(String cellID) { + this.cellID = cellID; + } + @JsonProperty("neighbours") + public List getNeighbours() { + return neighbours; + } + @JsonProperty("neighbours") + public void setNeighbours(List neighbours) { + this.neighbours = neighbours; + } + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + @Override + public String toString() { + return "Payload [pNFName=" + pNFName + ", plmnid=" + plmnid + ", cellID=" + cellID + ", neighbours=" + neighbours + + "]"; + } } \ No newline at end of file diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PayloadOutput.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PayloadOutput.java index 0f3d42c..cdd308c 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PayloadOutput.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PayloadOutput.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.kafka.model.appmodels; import java.util.HashMap; import java.util.List; diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicyData.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicyData.java deleted file mode 100644 index 6f53145..0000000 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicyData.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.onap.ranapp.kafka.model.appmodels; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"PNFName", -"PLMNID", -"CellID", -"neighbours" -}) -@Generated("jsonschema2pojo") -public class PolicyData { -@JsonProperty("PNFName") -private String pNFName; -@JsonProperty("PLMNID") -private String plmnid; -@JsonProperty("CellID") -private String cellID; -@JsonProperty("neighbours") -private List neighbours = null; -@JsonIgnore -private Map additionalProperties = new HashMap(); -@JsonProperty("PNFName") -public String getPNFName() { -return pNFName; -} -@JsonProperty("PNFName") -public void setPNFName(String pNFName) { -this.pNFName = pNFName; -} -@JsonProperty("PLMNID") -public String getPlmnid() { -return plmnid; -} -@JsonProperty("PLMNID") -public void setPlmnid(String plmnid) { -this.plmnid = plmnid; -} -@JsonProperty("CellID") -public String getCellID() { -return cellID; -} -@JsonProperty("CellID") -public void setCellID(String cellID) { -this.cellID = cellID; -} -@JsonProperty("neighbours") -public List getNeighbours() { -return neighbours; -} -@JsonProperty("neighbours") -public void setNeighbours(List neighbours) { -this.neighbours = neighbours; -} -@JsonAnyGetter -public Map getAdditionalProperties() { -return this.additionalProperties; -} -@JsonAnySetter -public void setAdditionalProperty(String name, Object value) { -this.additionalProperties.put(name, value); -} -@Override -public String toString() { - return "PolicyData [pNFName=" + pNFName + ", plmnid=" + plmnid + ", cellID=" + cellID + ", neighbours=" + neighbours - + "]"; -} -} \ No newline at end of file diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicytypetoTopicMapping.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicytypetoTopicMapping.java index c6198d2..5b0ac5a 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicytypetoTopicMapping.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/PolicytypetoTopicMapping.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.kafka.model.appmodels; import com.fasterxml.jackson.annotation.JsonProperty; public class PolicytypetoTopicMapping { @@ -25,7 +40,4 @@ public class PolicytypetoTopicMapping { public String toString() { return "PolicytypetoTopicMapping [request_topic=" + request_topic + ", response_topic=" + response_topic + "]"; } - - - } diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/RAN.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/RAN.java index e6d7287..d4af8e8 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/RAN.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/RAN.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * + * 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. + */ package org.onap.ranapp.kafka.model.appmodels; import java.util.HashMap; import java.util.Map; diff --git a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/ResponsetoA1.java b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/ResponsetoA1.java index 91fa7fe..a9b9203 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/ResponsetoA1.java +++ b/ANR-App/src/main/java/org/onap/ranapp/kafka/model/appmodels/ResponsetoA1.java @@ -7,8 +7,6 @@ public class ResponsetoA1 { } @JsonProperty("response-code") private int response_code; - - @JsonProperty("error-info") private String error_info; @JsonProperty("response-code") diff --git a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceData.java b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceData.java index 8172173..8c54a42 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceData.java +++ b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceData.java @@ -1,33 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * Ran Simulator Controller - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ================================================================================ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * * 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 + * You may obtain a copy of the License at: * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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.ranapp.models; import java.io.Serializable; public class DeviceData implements Serializable { - private static final long serialVersionUID = 4388248209444904611L; - private MessageType type; private String message; - - - public MessageType getType() { return type; } @@ -37,7 +28,6 @@ public class DeviceData implements Serializable { public void setMessage(String message) { this.message = message; } - public String getMessage() { return message; } diff --git a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataDecoder.java b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataDecoder.java index 8d0cd58..e48fba0 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataDecoder.java +++ b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataDecoder.java @@ -1,37 +1,30 @@ -/*- - * ============LICENSE_START======================================================= - * Ran Simulator Controller - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ================================================================================ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * * 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 + * You may obtain a copy of the License at: * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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.ranapp.models; import javax.websocket.DecodeException; import javax.websocket.Decoder; import javax.websocket.EndpointConfig; public class DeviceDataDecoder implements Decoder.Text { - // public class DeviceDataDecoder implements Decoder.Text @Override public void destroy() { } - @Override public void init(EndpointConfig arg0) { } - @Override public DeviceData decode(String msgInfo) throws DecodeException { DeviceData data = new DeviceData(); @@ -44,11 +37,9 @@ public class DeviceDataDecoder implements Decoder.Text { data.setType(MessageType.valueOf(strInfo[0])); return data; } - @Override public boolean willDecode(String arg0) { // TODO Auto-generated method stub return true; } - } diff --git a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataEncoder.java b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataEncoder.java index 1b70cee..05e08cd 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataEncoder.java +++ b/ANR-App/src/main/java/org/onap/ranapp/models/DeviceDataEncoder.java @@ -1,44 +1,34 @@ -/*- - * ============LICENSE_START======================================================= - * Ran Simulator Controller - * ================================================================================ - * Copyright (C) 2018 Wipro Limited. - * ================================================================================ +/* + * Copyright (C) 2022 CAPGEMINI ENGINEERING. + * * 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 + * You may obtain a copy of the License at: * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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.ranapp.models; import javax.websocket.EncodeException; import javax.websocket.Encoder; import javax.websocket.EndpointConfig; public class DeviceDataEncoder implements Encoder.Text { - @Override public void destroy() { // TODO Auto-generated method stub - } - @Override public void init(EndpointConfig arg0) { // TODO Auto-generated method stub - } - @Override public String encode(DeviceData msg) throws EncodeException { String result = msg.getType() + ":" + msg.getMessage(); return result; } - } diff --git a/ANR-App/src/main/java/org/onap/ranapp/models/MessageType.java b/ANR-App/src/main/java/org/onap/ranapp/models/MessageType.java index 9d759e3..ea244cb 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/models/MessageType.java +++ b/ANR-App/src/main/java/org/onap/ranapp/models/MessageType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (C) 2022 CAPGEMINI ENGINEERING. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ANR-App/src/main/java/org/onap/ranapp/websocket/WebsocketClient.java b/ANR-App/src/main/java/org/onap/ranapp/websocket/WebsocketClient.java index 612ec3f..722d399 100644 --- a/ANR-App/src/main/java/org/onap/ranapp/websocket/WebsocketClient.java +++ b/ANR-App/src/main/java/org/onap/ranapp/websocket/WebsocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (C) 2022 CAPGEMINI ENGINEERING. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,37 +54,28 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component @ClientEndpoint(encoders = {DeviceDataEncoder.class}, decoders = {DeviceDataDecoder.class}) public class WebsocketClient { - private static final Logger LOG = LoggerFactory.getLogger(WebsocketClient.class); private Session clientSession; private String url; @Value("${websocketserver.address}") private String websocketaddress; - @Value("${websocketserver.endpoint}") private String websocketendpoint; - @Value("${ranapp.name}") private String ranappName; @Value(value = "${kafka.bootstrapAddress}") private String bootstrapAddress; - @Autowired KafkaTemplate Kafkatemplate; ResponsetoA1 response=new ResponsetoA1(); - ObjectMapper objectMapper = new ObjectMapper(); - public static String requestTopicName,responseTopicName; - + public static String kafkakeyName; @OnOpen public void onOpen(Session session,@PathParam("IpPort") String ipPort) throws IOException { - - LOG.info("WebSocket opened (jetty server) Session Id: {}", session.getId()); DeviceData devicedata=new DeviceData(); devicedata.setType(MessageType.INITIAL_CONFIRMATION); - devicedata.setMessage("------------Connection Established to RAN_SIM from "+ ranappName +" ------------"); try { session.getBasicRemote().sendObject(devicedata); @@ -103,7 +94,6 @@ public class WebsocketClient { clientSession = null; new RetryWebsocket(this).start(); } - @OnMessage public void onMessage(DeviceData deviceData, Session session) { try { @@ -116,18 +106,13 @@ public class WebsocketClient { LOG.info("Message Received: Type:{}, msg:{}, Session Id:{}", deviceData.getType(), deviceData.getMessage(), session.getId()); produce(deviceData.getMessage()); - - } } - } } catch (Exception e) { LOG.error("Exception in processing message {}", e.getMessage()); } } - - public void sendMessage(DeviceData deviceData) { try { LOG.info("Message to Send: Type:{}, msg:{}, Session Id:{}", deviceData.getType(), @@ -141,7 +126,6 @@ public class WebsocketClient { LOG.error("Exception while sending message {}", e.getMessage()); } } - public void initWebsocketClient() { LOG.info("Initializing web socket client"); this.url = "ws://" + websocketaddress + websocketendpoint ; @@ -174,25 +158,18 @@ public class WebsocketClient { public void connectWebsocket() throws Exception { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); LOG.info("Connecting to Server:"+ url); - clientSession = container.connectToServer(this, new URI(url)); LOG.info("Connected to server, Session id: {}", clientSession.getId()); } public void start() { // TODO Auto-generated method stub - - initWebsocketClient(); } public void produce(String responsetoA1) { JSONObject obj_name = new JSONObject(responsetoA1); LOG.info(String.format("response message recieved from Ransim \n-> %s \n", obj_name)); - try { - - response = objectMapper.readValue(obj_name.toString(), ResponsetoA1.class); - LOG.info(String.format("Parsing the incoming json object to ResponsetoA1 class: "+ response +", kafkaresponse topic: "+responseTopicName)); if(ObjectUtils.isEmpty(Kafkatemplate)) { LOG.info(String.format("Initializing Kakfa producer factory")); @@ -202,16 +179,14 @@ public class WebsocketClient { config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); ProducerFactory producerfactory= new DefaultKafkaProducerFactory(config); Kafkatemplate=new KafkaTemplate(producerfactory); - } - - ListenableFuture> future = Kafkatemplate.send(responseTopicName, response); + ListenableFuture> future = Kafkatemplate.send(responseTopicName, kafkakeyName, response); //Kafkatemplate.send(responseTopicName, response); future.addCallback(new ListenableFutureCallback>() { @Override public void onSuccess(SendResult result) { System.out.println("Sent message=[" + response.toString() + - "] with offset=[" + result.getRecordMetadata().offset() + "Data" + result + "]"); + "] with offset=[" + result.getRecordMetadata().offset() + "Data" + result + "with topic"+ kafkakeyName +"]"); } @Override public void onFailure(Throwable ex) { @@ -219,14 +194,11 @@ public class WebsocketClient { + response + "] due to : " + ex.getMessage()); } }); - - } catch (Exception ex) { LOG.info(String.format("Parsing the incoming json object to ResponsetoA1 class: "+ response +", kafkaresponse topic: "+responseTopicName)); LOG.info(String.format( "Invalid Message received . Exception while parsing JSON object -> %s", ex.getLocalizedMessage())); - ex.printStackTrace(); return; } -- cgit 1.2.3-korg