Add second control loop name, Change restclient to support SSL 80/88380/3 dublin 1.0.3 4.0.0-ONAP
authorkrishna <krishna.moorthy6@wipro.com>
Thu, 23 May 2019 14:45:02 +0000 (20:15 +0530)
committerkrishna <krishna.moorthy6@wipro.com>
Thu, 23 May 2019 17:24:31 +0000 (22:54 +0530)
Change-Id: I5ab334676f7f79cf2c42a9325ec1b7bfe8add6c5
Issue-ID: DCAEGEN2-1529
Signed-off-by: krishna <krishna.moorthy6@wipro.com>
18 files changed:
dpo/blueprints/k8s-sonhms-inputs.yaml
dpo/blueprints/k8s-sonhms.yaml
pom.xml
src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java
src/main/java/org/onap/dcaegen2/services/sonhms/HoMetricsComponent.java
src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThread.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java
src/main/java/org/onap/dcaegen2/services/sonhms/child/StateOof.java
src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java
src/main/java/org/onap/dcaegen2/services/sonhms/dmaap/PolicyDmaapClient.java
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CellInfo.java
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/OofRestClient.java
src/main/java/org/onap/dcaegen2/services/sonhms/utils/SonHandlerRestTemplate.java
src/test/java/org/onap/dcaegen2/services/sonhms/ConfigurationTest.java
src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java
src/test/resources/policy_notification.json
version.properties

index 21e0d78..7902892 100644 (file)
@@ -18,7 +18,7 @@
  
 pgaas_cluster_name: dcae-pg-primary.onap
 database_name: sonhms
-tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.2
+tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.3
 replicas: 1
 aaf_username: 
 aaf_password: 
@@ -37,6 +37,7 @@ cg: sonhms-cg
 cid: sonhms-cid
 config_db: http://sdnc.onap:8181
 oof: http://oof-osdf.onap:8699
+oof_endpoint: /api/oof/v1/pci
 pci_optimizer: pci
 pci_anr_optimizer: pci_anr
 log_path: /dockerdata-nfs/son-handler
index aa4178a..2d96706 100644 (file)
@@ -30,7 +30,7 @@ inputs:
   tag_version:
     type: string
     description: docker image name and version
-    default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.2"
+    default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.son-handler:1.0.3"
   pgaas_cluster_name:
     type: string
     description: pg cluster
@@ -103,6 +103,10 @@ inputs:
   oof:
     type: string
     description: oof location
+  oof_endpoint:
+    type: string
+    description: oof endpoint
+    default: /api/oof/v1/pci
   pci_optimizer:
     type: string
     description: pci optimizer name in oof
@@ -264,6 +268,7 @@ node_templates:
         sonhandler.cid: { get_input: cid }
         sonhandler.configDb.service: { get_input: config_db }
         sonhandler.oof.service: { get_input: oof }
+        sonhandler.oof.endpoint: { get_input: oof_endpoint }
         sonhandler.pciOptimizer: { get_input: pci_optimizer }
         sonhandler.pciAnrOptimizer: { get_input: pci_anr_optimizer }
         sonhandler.poorCountThreshold: { get_input: poorCountThreshold}
diff --git a/pom.xml b/pom.xml
index 046dc57..64a184f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
        <groupId>org.onap.dcaegen2.services.son-handler</groupId>
        <artifactId>son-handler</artifactId>
        <name>dcaegen2-services-son-handler</name>
-       <version>1.0.2-SNAPSHOT</version>
+       <version>1.0.3-SNAPSHOT</version>
 
        <!--parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> 
                <version>2.0.4.RELEASE</version> </parent -->
index 5cb145a..faa1b4e 100644 (file)
@@ -34,6 +34,7 @@ public class Configuration {
     private List<String> dmaapServers;
     private String configDbService;
     private String oofService;
+    private String oofEndpoint;
     private String cg;
     private String cid;
     private int pollingInterval;
@@ -330,20 +331,29 @@ public class Configuration {
         this.pciAnrOptimizer = pciAnrOptimizer;
     }
 
+    public String getOofEndpoint() {
+        return oofEndpoint;
+    }
+
+    public void setOofEndpoint(String oofEndpoint) {
+        this.oofEndpoint = oofEndpoint;
+    }
+
     @Override
     public String toString() {
         return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword="
                 + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService
-                + ", oofService=" + oofService + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval
-                + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion="
-                + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", pciOptimizer="
-                + pciOptimizer + ", pciAnrOptimizer=" + pciAnrOptimizer + ", numSolutions=" + numSolutions
-                + ", bufferTime=" + bufferTime + ", maximumClusters=" + maximumClusters + ", aafUsername=" + aafUsername
-                + ", aafPassword=" + aafPassword + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes="
-                + streamsPublishes + ", badThreshold=" + badThreshold + ", poorThreshold=" + poorThreshold
-                + ", poorCountThreshold=" + poorCountThreshold + ", badCountThreshold=" + badCountThreshold
-                + ", oofTriggerCountTimer=" + oofTriggerCountTimer + ", oofTriggerCountThreshold="
-                + oofTriggerCountThreshold + ", policyRespTimer=" + policyRespTimer + "]";
+                + ", oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid
+                + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision="
+                + minCollision + ", minConfusion=" + minConfusion + ", sourceId=" + sourceId + ", callbackUrl="
+                + callbackUrl + ", pciOptimizer=" + pciOptimizer + ", pciAnrOptimizer=" + pciAnrOptimizer
+                + ", numSolutions=" + numSolutions + ", bufferTime=" + bufferTime + ", maximumClusters="
+                + maximumClusters + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword
+                + ", streamsSubscribes=" + streamsSubscribes + ", streamsPublishes=" + streamsPublishes
+                + ", badThreshold=" + badThreshold + ", poorThreshold=" + poorThreshold + ", poorCountThreshold="
+                + poorCountThreshold + ", badCountThreshold=" + badCountThreshold + ", oofTriggerCountTimer="
+                + oofTriggerCountTimer + ", oofTriggerCountThreshold=" + oofTriggerCountThreshold + ", policyRespTimer="
+                + policyRespTimer + "]";
     }
     
     
index eca0930..801eaa3 100644 (file)
@@ -64,16 +64,23 @@ public class HoMetricsComponent {
         }
     }
 
+    /**
+     * Update HO metrics.
+     */
     public Boolean update(String hoDetails, String srcCellId) {
         try {
-        HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
-        handOverMetricsRepository.updateHoMetrics(hoDetails, srcCellId);
-        return true;
-        }catch(Exception e) {
-            log.info("Exception in updating ho metrics {}",e);
+            HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
+            handOverMetricsRepository.updateHoMetrics(hoDetails, srcCellId);
+            return true;
+        } catch (Exception e) {
+            log.info("Exception in updating ho metrics {}", e);
             return false;
         }
     }
+
+    /**
+     * Get all HO metrics.
+     */
     public Either<List<HandOverMetrics>, Integer> getAll() {
         HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
         try {
index fe809ec..b9ab254 100644 (file)
@@ -235,7 +235,6 @@ public class PmNotificationHandler {
     }
 
     private Boolean saveToHandOverMetrics(List<HoDetails> hoDetailsList, String srcCellId) {
-        HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
         ObjectMapper mapper = new ObjectMapper();
         String hoDetailsString = null;
         try {
@@ -247,6 +246,7 @@ public class PmNotificationHandler {
         HandOverMetrics handOverMetrics = new HandOverMetrics();
         handOverMetrics.setHoDetails(hoDetailsString);
         handOverMetrics.setSrcCellId(srcCellId);
+        HandOverMetricsRepository handOverMetricsRepository = BeanUtil.getBean(HandOverMetricsRepository.class);
         handOverMetricsRepository.save(handOverMetrics);
         return true;
     }
index 0170f90..87c5081 100644 (file)
@@ -49,6 +49,7 @@ import org.onap.dcaegen2.services.sonhms.dao.SonRequestsRepository;
 import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient;
 import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics;
 import org.onap.dcaegen2.services.sonhms.exceptions.ConfigDbNotFoundException;
+import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
 import org.onap.dcaegen2.services.sonhms.model.AnrInput;
 import org.onap.dcaegen2.services.sonhms.model.CellPciPair;
 import org.onap.dcaegen2.services.sonhms.model.ClusterMap;
@@ -227,7 +228,7 @@ public class ChildThread implements Runnable {
                 }
                 policyTriggerFlag.setHolder("CHILD");
                 policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() + 1);
-                
+
                 Timer timerOof = BeanUtil.getBean(Timer.class);
                 if (!timerOof.getIsTimer()) {
                     log.info("Starting timer");
@@ -238,13 +239,13 @@ public class ChildThread implements Runnable {
                     log.info("startTime {}", startTime);
 
                 }
-                Timestamp currentTime = new Timestamp(System.currentTimeMillis());
-                Long difference = currentTime.getTime() - timerOof.getStartTime().getTime();
                 int timerThreshold = (Configuration.getInstance().getOofTriggerCountTimer() * 60000);
                 int triggerCountThreshold = Configuration.getInstance().getOofTriggerCountThreshold();
                 log.info("Time threshold {}, triggerCountThreshold {}", timerThreshold, triggerCountThreshold);
                 log.info("oof trigger count {}", timerOof.getCount());
-                timerOof.setCount(timerOof.getCount()+1);
+                timerOof.setCount(timerOof.getCount() + 1);
+                Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+                Long difference = currentTime.getTime() - timerOof.getStartTime().getTime();
                 if (difference < timerThreshold && timerOof.getCount() > triggerCountThreshold) {
                     log.info("difference {}", difference);
 
@@ -258,7 +259,6 @@ public class ChildThread implements Runnable {
                         }
                         transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
 
-
                     } else {
                         log.info("ANR trigger response left {}", anrTriggerResponse.left().value());
                         List<AnrInput> anrInputList = anrTriggerResponse.left().value();
@@ -268,9 +268,9 @@ public class ChildThread implements Runnable {
                     }
 
                 } else {
-                    
+
                     transactionId = oof.triggerOof(cellidList, networkId, new ArrayList<>());
-                    
+
                     if (difference > timerThreshold) {
                         timerOof.setIsTimer(false);
                         timerOof.setCount(0);
@@ -330,8 +330,17 @@ public class ChildThread implements Runnable {
 
             }
 
+        } catch (OofNotFoundException e) {
+            log.error("OOF not found, Removing flag and cleaning up");
+            Flag policyTriggerFlag = BeanUtil.getBean(Flag.class);
+            policyTriggerFlag.setNumChilds(policyTriggerFlag.getNumChilds() - 1);
+            if (policyTriggerFlag.getNumChilds() == 0) {
+                policyTriggerFlag.setHolder("NONE");
+            }
         } catch (Exception e) {
             log.error("{}", e);
+            
+            
         }
 
         cleanup();
@@ -444,7 +453,7 @@ public class ChildThread implements Runnable {
         Configuration configuration = Configuration.getInstance();
         List<HoDetails> hoDetailsList;
         Either<List<HandOverMetrics>, Integer> hoMetrics = hoMetricsComponent.getAll();
-        if(hoMetrics.isRight()) {
+        if (hoMetrics.isRight()) {
             log.error("Error in getting HO details from db");
             return Either.right(500);
         }
@@ -462,11 +471,10 @@ public class ChildThread implements Runnable {
             List<String> removeableNeighbors = new ArrayList<>();
             log.info("Checking poor count for src cell {}", hoMetric.getSrcCellId());
             for (HoDetails hoDetail : hoDetailsList) {
-                    if (hoDetail.getPoorCount() >= configuration.getPoorCountThreshold()) {
-                        removeableNeighbors.add(hoDetail.getDstCellId());
-                    }
+                if (hoDetail.getPoorCount() >= configuration.getPoorCountThreshold()) {
+                    removeableNeighbors.add(hoDetail.getDstCellId());
                 }
-         
+            }
 
             if (!removeableNeighbors.isEmpty()) {
                 AnrInput anrInput = new AnrInput(hoMetric.getSrcCellId(), removeableNeighbors);
index d567c8a..852d087 100644 (file)
@@ -70,7 +70,8 @@ public class ChildThreadUtils {
     /**
      * Parameterized constructor.
      */
-    public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient, HoMetricsComponent hoMetricsComponent) {
+    public ChildThreadUtils(ConfigPolicy configPolicy, PnfUtils pnfUtils, PolicyDmaapClient policyDmaapClient,
+            HoMetricsComponent hoMetricsComponent) {
         this.configPolicy = configPolicy;
         this.pnfUtils = pnfUtils;
         this.policyDmaapClient = policyDmaapClient;
@@ -120,11 +121,22 @@ public class ChildThreadUtils {
     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");
-        } catch (NullPointerException e) {
-            log.error("Config policy not found, Using default");
+        String closedLoopControlName = "";
+        if (action.equals("ModifyConfig")) {
+            closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459";
+            try {
+                closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME");
+            } catch (NullPointerException e) {
+                log.error("Config policy not found, Using default");
+            }
+        }
+        else {
+            closedLoopControlName = "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61";
+            try {
+                closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIGANR_POLICY_NAME");
+            } catch (NullPointerException e) {
+                log.error("Config policy not found, Using default");
+            }
         }
 
         PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, requestId, alarmStartTime,
@@ -226,12 +238,12 @@ public class ChildThreadUtils {
                                 null);
                         configurations.add(configuration);
                         Either<List<HoDetails>, Integer> hoMetrics = hoMetricsComponent.getHoMetrics(cellId);
-                        if(hoMetrics.isLeft()) {
+                        if (hoMetrics.isLeft()) {
                             List<HoDetails> hoDetailsList = hoMetrics.left().value();
-                            for(LteCell lteCell:lteCellList) {
+                            for (LteCell lteCell : lteCellList) {
                                 String removedNbr = lteCell.getCid();
-                                for(HoDetails hoDetail:hoDetailsList) {
-                                    if(removedNbr.equals(hoDetail.getDstCellId())) {
+                                for (HoDetails hoDetail : hoDetailsList) {
+                                    if (removedNbr.equals(hoDetail.getDstCellId())) {
                                         hoDetailsList.remove(hoDetail);
                                         break;
                                     }
@@ -246,27 +258,27 @@ public class ChildThreadUtils {
                                 return false;
                             }
                             hoMetricsComponent.update(hoDetailsString, cellId);
+                        }
+
                     }
-                    
-                }
-                Payload payload = new Payload(configurations);
-                ObjectMapper mapper = new ObjectMapper();
-                mapper.setSerializationInclusion(Include.NON_NULL);
-                String payloadString = null;
-                try {
-                    payloadString = mapper.writeValueAsString(payload);
-                } catch (JsonProcessingException e) {
-                    log.error("Exception in writing anrupdate string", e);
-                }
-                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");
-                
+                    Payload payload = new Payload(configurations);
+                    ObjectMapper mapper = new ObjectMapper();
+                    mapper.setSerializationInclusion(Include.NON_NULL);
+                    String payloadString = null;
+                    try {
+                        payloadString = mapper.writeValueAsString(payload);
+                    } catch (JsonProcessingException e) {
+                        log.error("Exception in writing anrupdate string", e);
+                    }
+                    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");
+
                 }
 
             }
index 8eb5a40..a00c166 100644 (file)
@@ -71,12 +71,12 @@ public class StateOof {
 
         pciOptimizerList.add(config.getPciOptimizer());
         pciAnrOptimizerList.add(config.getPciAnrOptimizer());
-        
-        String oofResponse =null;
-        if(!anrInputList.isEmpty()) {
+
+        String oofResponse = null;
+        if (!anrInputList.isEmpty()) {
             oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
                     networkId, pciAnrOptimizerList, anrInputList);
-        }else {
+        } else {
             oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
                     networkId, pciOptimizerList, anrInputList);
         }
index 7ec446c..c2e7b63 100644 (file)
@@ -118,6 +118,7 @@ public class ConfigFetchFromCbs {
         String pciAnrOptimizer = jsonObject.get("sonhandler.pciAnrOptimizer").getAsString();
 
         String oofService = jsonObject.get("sonhandler.oof.service").getAsString();
+        String oofEndpoint = jsonObject.get("sonhandler.oof.endpoint").getAsString();
         int pollingTimeout = jsonObject.get("sonhandler.pollingTimeout").getAsInt();
 
         int badThreshold = jsonObject.get("sonhandler.badThreshold").getAsInt();
@@ -150,6 +151,7 @@ public class ConfigFetchFromCbs {
         configuration.setPciOptimizer(pciOptimizer);
         configuration.setPciAnrOptimizer(pciAnrOptimizer);
         configuration.setOofService(oofService);
+        configuration.setOofEndpoint(oofEndpoint);
         configuration.setPollingTimeout(pollingTimeout);
         configuration.setBadThreshold(badThreshold);
         configuration.setPoorThreshold(poorThreshold);
index a0a1274..1a8456f 100644 (file)
@@ -38,16 +38,15 @@ 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.
@@ -71,7 +70,7 @@ public class PolicyDmaapClient {
         }
         return true;
     }
-    
+
     /**
      * Handles policy response.
      */
@@ -91,7 +90,7 @@ public class PolicyDmaapClient {
         Timestamp currentTime = new Timestamp(System.currentTimeMillis());
         Long difference = currentTime.getTime() - startTimer.getTime();
         int policyRespTimer = configuration.getPolicyRespTimer(); // Timer in seconds
-        while (difference < (policyRespTimer*1000)) {
+        while (difference < (policyRespTimer * 1000)) {
             Iterable<String> policyResponseMessages;
             try {
                 policyResponseMessages = policyResponseCambriaConsumer.fetch();
index 2501e53..ccca473 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 
 import org.onap.dcaegen2.services.sonhms.model.AnrInput;
 
+
 public class CellInfo {
     String networkId = null;
     List<String> cellIdList = new ArrayList<>();
index 97668ed..d6b6c74 100644 (file)
@@ -96,15 +96,19 @@ public class OofRestClient {
         }
         log.info("requestBody{}", requestBody);
 
-        String requestUrl = configuration.getOofService() + "/api/oof/pci/v1";
-        log.debug("requestUrl {}", requestUrl);
+        String requestUrl = configuration.getOofService() + configuration.getOofEndpoint();
+        log.info("requestUrl {}", requestUrl);
         ResponseEntity<String> response = null;
         response = SonHandlerRestTemplate.sendPostRequestToOof(requestUrl, requestBody,
                 new ParameterizedTypeReference<String>() {
                 });
+        
         if (response == null) {
             throw new OofNotFoundException("Request to oof failed");
         }
+        else if (response.getStatusCodeValue() != 202) {
+            throw new OofNotFoundException("Request to oof failed with status code" + response.getStatusCodeValue());
+        }
         log.info("response {}", response);
 
         return response.getBody();
index c46d912..d32a78c 100644 (file)
 
 package org.onap.dcaegen2.services.sonhms.utils;
 
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
 import java.util.Collections;
 
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
 import org.slf4j.Logger;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.HttpEntity;
@@ -31,9 +47,11 @@ import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
+@SuppressWarnings("deprecation")
 @Component
 public class SonHandlerRestTemplate {
 
@@ -42,9 +60,9 @@ public class SonHandlerRestTemplate {
     private static final Logger log = org.slf4j.LoggerFactory.getLogger(SonHandlerRestTemplate.class);
 
     private SonHandlerRestTemplate() {
-        
+
     }
-    
+
     /**
      * Send Post Request.
      */
@@ -64,7 +82,6 @@ public class SonHandlerRestTemplate {
         }
     }
 
-
     /**
      * Send Get Request.
      */
@@ -114,12 +131,33 @@ public class SonHandlerRestTemplate {
         headers.add(AUTH, "Basic cGNpX3Rlc3Q6cGNpX3Rlc3Rwd2Q=");
         HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
         try {
-            RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class);
+            RestTemplate restTemplate = new RestTemplate(useApacheHttpClientWithSelfSignedSupport());
             return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType);
         } catch (Exception e) {
-            log.debug(EXCEPTION_MSG, e);
+            log.error(EXCEPTION_MSG, e);
             return new ResponseEntity<>(HttpStatus.NOT_FOUND);
         }
     }
 
+    private static HttpComponentsClientHttpRequestFactory useApacheHttpClientWithSelfSignedSupport() {
+
+        TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
+        SSLContext sslContext = null;
+        try {
+            sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
+        } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
+            log.error(EXCEPTION_MSG, e);
+        }
+        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
+        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
+                .register("https", sslsf).register("http", new PlainConnectionSocketFactory()).build();
+        BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(
+                socketFactoryRegistry);
+        CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
+                .setConnectionManager(connectionManager).build();
+        HttpComponentsClientHttpRequestFactory useApacheHttpClient = new HttpComponentsClientHttpRequestFactory();
+        useApacheHttpClient.setHttpClient(httpClient);
+        return useApacheHttpClient;
+    }
+
 }
index f762a5b..8fb4087 100644 (file)
@@ -59,8 +59,13 @@ public class ConfigurationTest {
         configuration.setMinConfusion(5);
         configuration.setNumSolutions(1);
         configuration.setOofService("oofService");
+        configuration.setOofEndpoint("/api/oof/v1/pci");
+        configuration.setOofTriggerCountTimer(30);
+        configuration.setOofTriggerCountThreshold(5);
         configuration.setBadThreshold(50);
         configuration.setPoorThreshold(70);
+        configuration.setBadCountThreshold(3);
+        configuration.setPoorCountThreshold(3);
         configuration.setPciOptimizer("pci");
         configuration.setPciAnrOptimizer("pci-anr");
         configuration.setPollingInterval(30);
@@ -78,6 +83,9 @@ public class ConfigurationTest {
         assertEquals(5, configuration.getMinConfusion());
         assertEquals(1, configuration.getNumSolutions());
         assertEquals("oofService", configuration.getOofService());
+        assertEquals("/api/oof/v1/pci", configuration.getOofEndpoint());
+        assertEquals(30, configuration.getOofTriggerCountTimer());
+        assertEquals(5, configuration.getOofTriggerCountThreshold());
         assertEquals("pci", configuration.getPciOptimizer());
         assertEquals("pci-anr", configuration.getPciAnrOptimizer());
         assertEquals("user", configuration.getPgUsername());
@@ -91,6 +99,8 @@ public class ConfigurationTest {
         assertEquals("sourceId", configuration.getSourceId());
         assertEquals(50, configuration.getBadThreshold());
         assertEquals(70, configuration.getPoorThreshold());
+        assertEquals(3, configuration.getBadCountThreshold());
+        assertEquals(3, configuration.getPoorCountThreshold());
         assertEquals(subscribes, configuration.getStreamsSubscribes());
         assertEquals(subscribes, configuration.getStreamsPublishes());
     }
index 92b2da1..f8a6ae2 100644 (file)
@@ -163,7 +163,7 @@ public class TestChildThreadUtils {
                String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731";
                Long alarmStart = Long.parseLong("1542445563201");
 
-               String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "action");
+               String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "ModifyConfig");
                PolicyNotification actual = new PolicyNotification();
                try {
                        actual = mapper.readValue(result, PolicyNotification.class);
index b99a8b9..35fe06c 100644 (file)
@@ -14,5 +14,5 @@
                "generic-vnf.is-closed-loop-disabled": "false",
                "generic-vnf.vnf-id": "ncserver23"
        },
-       "Action": "action"
+       "Action": "ModifyConfig"
 }
index 7d597d7..2159a4d 100644 (file)
@@ -20,7 +20,7 @@
 ###############################################################################\r
 major=1\r
 minor=0\r
-patch=2\r
+patch=3\r
 base_version=${major}.${minor}.${patch}\r
 release_version=${base_version}\r
 snapshot_version=${base_version}-SNAPSHOT\r