exchanging new version yang models on firmware upgrade 11/4511/1
authorcschowdam <chandrasekhar.chowdam@commscope.com>
Wed, 5 Aug 2020 14:35:41 +0000 (14:35 +0000)
committercschowdam <chandrasekhar.chowdam@commscope.com>
Wed, 5 Aug 2020 14:35:50 +0000 (14:35 +0000)
Exchanging the new yang models with SDNR to support new configuration

Issue-Id: OAM-138
Change-Id: Ibb59af8d2f35da24f921d9e6bdc01108cb0a7b95
Signed-off-by: cschowdam <chandrasekhar.chowdam@commscope.com>
19 files changed:
acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/handler/ConnectionReqEventHandler.java
acs/nbi/src/main/java/org/commscope/tr069adapter/acs/nbi/impl/DeviceInformForwarder.java
acs/nbi/src/main/java/org/commscope/tr069adapter/acs/nbi/impl/DeviceRPCResponseForwarder.java
acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/handler/DeviceRPCRequestHandler.java
mapper/src/main/java/org/commscope/tr069adapter/mapper/acs/impl/ACSNotificationHandlerImpl.java
mapper/src/main/java/org/commscope/tr069adapter/mapper/model/NetConfNotificationDTO.java
mapper/src/main/java/org/commscope/tr069adapter/mapper/model/NetConfServerDetails.java
netconf-server/pom.xml
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/boot/NetConfServiceBooter.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/error/NetconfNotificationException.java [new file with mode: 0644]
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/notification/NetConfNotificationQueue.java [new file with mode: 0644]
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/notification/NetConfSessionUtil.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/notification/NotificationHandler.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/restapi/NetConfServerManagerRestApi.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/rpc/CreateSubscription.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetConfServerManagerImpl.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetconfServerStarter.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/RestartNetconfServerHandler.java
netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/utils/NetConfServerConstants.java

index c8e76f7..afa6a3f 100644 (file)
@@ -21,9 +21,7 @@ package org.commscope.tr069adapter.acs.cpe.handler;
 \r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.CR_REQ_CF;\r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.CR_REQ_Q;\r
-\r
 import java.io.IOException;\r
-\r
 import org.commscope.tr069adapter.acs.common.dto.TR069DeviceDetails;\r
 import org.commscope.tr069adapter.acs.common.exception.SessionManagerException;\r
 import org.commscope.tr069adapter.acs.cpe.processor.ConnectionReqEventProcessor;\r
@@ -47,7 +45,8 @@ public class ConnectionReqEventHandler {
 \r
   @JmsListener(destination = CR_REQ_Q, containerFactory = CR_REQ_CF)\r
   @Transactional(rollbackFor = Exception.class)\r
-  public void onMessage(TR069DeviceDetails tr069DeviceDetails) {\r
+  public void onMessage(TR069DeviceDetails tr069DeviceDetails)\r
+      throws SessionManagerException, IOException {\r
     try {\r
       if (tr069DeviceDetails != null) {\r
         MDC.put(CLIENT_STR, tr069DeviceDetails.getDeviceId());\r
@@ -60,8 +59,6 @@ public class ConnectionReqEventHandler {
             "Received a JMS message for initiating connection request with no device details, "\r
                 + "hence could not initiate connection request");\r
       }\r
-    } catch (SessionManagerException | IOException e) {\r
-      logger.error(e.getMessage());\r
     } finally {\r
       MDC.remove(CLIENT_STR);\r
     }\r
index 6b86297..2833f4a 100644 (file)
@@ -20,7 +20,6 @@ package org.commscope.tr069adapter.acs.nbi.impl;
 \r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_CF;\r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_Q;\r
-\r
 import org.commscope.tr069adapter.acs.common.DeviceInform;\r
 import org.commscope.tr069adapter.acs.nbi.mapper.service.DeviceEventsMapperNotificationService;\r
 import org.slf4j.Logger;\r
@@ -41,19 +40,14 @@ public class DeviceInformForwarder {
   @JmsListener(destination = NBI_NOTIFICATION_Q, containerFactory = NBI_NOTIFICATION_CF)\r
   @Transactional(rollbackFor = Exception.class)\r
   public void onMessage(DeviceInform notification) {\r
-    try {\r
-      if (null != notification) {\r
-        logger.debug(\r
-            "DeviceNotification message is received for deviceId : {} , Notification Type(s): {}",\r
-            notification.getDeviceDetails().getDeviceId(), notification.getInformTypeList());\r
-        deviceEventsMapperNotificationService.processDeviceNotification(notification);\r
-        logger.debug("Successfully processed device notification.");\r
-      } else {\r
-        logger.error("Null device response is received!!!");\r
-      }\r
-    } catch (Exception e) {\r
-      logger.error("Error while processing the notification, Reason: {}", e.getMessage());\r
+    if (null != notification) {\r
+      logger.debug(\r
+          "DeviceNotification message is received for deviceId : {} , Notification Type(s): {}",\r
+          notification.getDeviceDetails().getDeviceId(), notification.getInformTypeList());\r
+      deviceEventsMapperNotificationService.processDeviceNotification(notification);\r
+      logger.debug("Successfully processed device notification.");\r
+    } else {\r
+      logger.error("Null device response is received!!!");\r
     }\r
   }\r
-\r
 }\r
index 72f97a5..4971056 100644 (file)
@@ -20,7 +20,6 @@ package org.commscope.tr069adapter.acs.nbi.impl;
 \r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_CF;\r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_Q;\r
-\r
 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;\r
 import org.commscope.tr069adapter.acs.nbi.mapper.service.DeviceEventsMapperNotificationService;\r
 import org.slf4j.Logger;\r
@@ -41,17 +40,13 @@ public class DeviceRPCResponseForwarder {
   @JmsListener(destination = NBI_OP_RESULT_Q, containerFactory = NBI_OP_RESULT_CF)\r
   @Transactional(rollbackFor = Exception.class)\r
   public void onMessage(DeviceRPCResponse opResult) {\r
-    try {\r
-      if (null != opResult) {\r
-        logger.debug("NBIOperationResult message is received for deviceId : {}, , OprationId: {}",\r
-            opResult.getDeviceDetails().getDeviceId(), opResult.getOperationId());\r
-        deviceEventsMapperNotificationService.processOperationResponse(opResult);\r
-        logger.debug("Successfully processed NBI operation result.");\r
-      } else {\r
-        logger.error("Null device response is received!!!");\r
-      }\r
-    } catch (Exception e) {\r
-      logger.error("Error while processing the notification, Reason: {}", e.getMessage());\r
+    if (null != opResult) {\r
+      logger.debug("NBIOperationResult message is received for deviceId : {}, , OprationId: {}",\r
+          opResult.getDeviceDetails().getDeviceId(), opResult.getOperationId());\r
+      deviceEventsMapperNotificationService.processOperationResponse(opResult);\r
+      logger.debug("Successfully processed NBI operation result.");\r
+    } else {\r
+      logger.error("Null device response is received!!!");\r
     }\r
   }\r
 }\r
index 49ec0a7..0f98e60 100644 (file)
@@ -21,7 +21,6 @@ package org.commscope.tr069adapter.acs.requestprocessor.handler;
 \r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.TR069_NBI_REQUEST_CF;\r
 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.TR069_NBI_REQUEST_Q;\r
-\r
 import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;\r
 import org.commscope.tr069adapter.acs.common.exception.SessionConcurrentAccessException;\r
 import org.commscope.tr069adapter.acs.common.exception.TR069EventProcessingException;\r
@@ -47,7 +46,7 @@ public class DeviceRPCRequestHandler {
   @JmsListener(destination = TR069_NBI_REQUEST_Q, containerFactory = TR069_NBI_REQUEST_CF)\r
   @Transactional(rollbackFor = Exception.class)\r
   public void onMessage(DeviceRPCRequest mapperDeviceOperationRequest)\r
-      throws SessionConcurrentAccessException {\r
+      throws SessionConcurrentAccessException, TR069EventProcessingException {\r
     logger.debug("Received a JMS message from Mapper for TR069 Device RPC operation");\r
     try {\r
       if (mapperDeviceOperationRequest != null) {\r
@@ -59,8 +58,6 @@ public class DeviceRPCRequestHandler {
             mapperDeviceOperationRequest.getOperationId());\r
 \r
       }\r
-    } catch (TR069EventProcessingException ex) {\r
-      logger.error(ex.getMessage());\r
     } finally {\r
       MDC.remove(CLIENT_STR);\r
     }\r
index b6adad7..4d39d57 100644 (file)
@@ -36,7 +36,6 @@ import org.commscope.tr069adapter.mapper.MapperConfigProperties;
 import org.commscope.tr069adapter.mapper.acs.ACSNotificationHandler;\r
 import org.commscope.tr069adapter.mapper.dao.DeviceOperationsDAO;\r
 import org.commscope.tr069adapter.mapper.entity.DeviceOperationDetails;\r
-import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
 import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;\r
 import org.commscope.tr069adapter.mapper.model.NetconfServerManagementError;\r
 import org.commscope.tr069adapter.mapper.netconf.NetConfNotificationSender;\r
@@ -118,30 +117,38 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
       vesnotiSender.sendNotification(bootstrapNotification, serverInfo);\r
       BootstrapInform bsInform =\r
           getDeviceBootStrapNotification(bootstrapNotification, TR069InformType.BOOTSTRAP);\r
+      ValueChangeInform vcInform = null;\r
       if (bootstrapNotification.getValueChangeNotification() != null) {\r
         logger.info("Bootstrap notification received along with VC");\r
-        ValueChangeInform vcInform =\r
+        vcInform =\r
             getDeviceValueChangeNotification(bootstrapNotification, TR069InformType.VALUECHANGE);\r
         processVCNotification(vcInform, isAlarmVC);\r
       }\r
       notiSender.sendNotification(bsInform);\r
+      if (vcInform != null)\r
+        processVCNotification(vcInform, isAlarmVC);\r
     } else if (notification instanceof BootInform) {\r
       logger.info("Boot notification received");\r
+\r
+      NetConfServerDetails serverInfo = createNtConfServer(notification);\r
+      if (serverInfo == null)\r
+        return;\r
+\r
       checkForActivateNotification(notification);\r
       BootInform bootNotification = (BootInform) notification;\r
       BootInform bInform = getDeviceBootNotification(bootNotification, TR069InformType.BOOT);\r
+      ValueChangeInform vcInform = null;\r
       if (bootNotification.getValueChangeNotification() != null) {\r
         logger.info("Boot notification received along with VC");\r
-        ValueChangeInform vcInform =\r
-            getDeviceValueChangeNotification(bootNotification, TR069InformType.VALUECHANGE);\r
-        processVCNotification(vcInform, isAlarmVC);\r
+        vcInform = getDeviceValueChangeNotification(bootNotification, TR069InformType.VALUECHANGE);\r
       }\r
       notiSender.sendNotification(bInform);\r
+      processVCNotification(vcInform, isAlarmVC);\r
     } else if (notification instanceof PeriodicInform) {\r
       PeriodicInform pINotificaiton = (PeriodicInform) notification;\r
       vesnotiSender.sendNotification(pINotificaiton, null);\r
       notiSender.sendNotification(pINotificaiton);\r
-      logger.info("VC notification received");\r
+      logger.info("PI notification received");\r
     } else if (notification instanceof ConnectionRequestInform) {\r
       ConnectionRequestInform crNotificaiton = (ConnectionRequestInform) notification;\r
       vesnotiSender.sendNotification(crNotificaiton, null);\r
@@ -162,21 +169,20 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
     pnpPreProvisioningHandler.onDeviceNotification(notification);\r
   }\r
 \r
-  private NetConfServerDetails createNtConfServer(BootstrapInform bootstrapNotification) {\r
+  private NetConfServerDetails createNtConfServer(DeviceInform inform) {\r
     String eNodeBName = pnpPreProvisioningHandler.getEnodeBName(\r
-        bootstrapNotification.getDeviceDetails().getDeviceId(),\r
-        bootstrapNotification.getDeviceDetails().getSoftwareVersion(),\r
-        bootstrapNotification.getDeviceDetails().getHardwareVersion());\r
+        inform.getDeviceDetails().getDeviceId(), inform.getDeviceDetails().getSoftwareVersion(),\r
+        inform.getDeviceDetails().getHardwareVersion());\r
     if (eNodeBName == null)\r
-      eNodeBName = bootstrapNotification.getDeviceDetails().getDeviceId();\r
+      eNodeBName = inform.getDeviceDetails().getDeviceId();\r
     NetConfServerDetails serverInfo =\r
-        netconfManager.createNetconfServer(bootstrapNotification.getDeviceDetails().getDeviceId(),\r
-            eNodeBName, bootstrapNotification.getDeviceDetails().getSoftwareVersion(),\r
-            bootstrapNotification.getDeviceDetails().getHardwareVersion());\r
+        netconfManager.createNetconfServer(inform.getDeviceDetails().getDeviceId(), eNodeBName,\r
+            inform.getDeviceDetails().getSoftwareVersion(),\r
+            inform.getDeviceDetails().getHardwareVersion());\r
     if (serverInfo != null && !NetconfServerManagementError.SUCCESS.equals(serverInfo.getError())) {\r
-      logger.error("Failed to handle bootstrap notification. Server INFO: {}", serverInfo);\r
+      logger.error("Failed to handle boot/bootstrap notification. Server INFO: {}", serverInfo);\r
       logger.error("Failed to create the netconf server for device ID: {}  Error: {}",\r
-          bootstrapNotification.getDeviceDetails().getDeviceId(), serverInfo.getError());\r
+          inform.getDeviceDetails().getDeviceId(), serverInfo.getError());\r
       return null;\r
     } else if (serverInfo == null) {\r
       logger.error(\r
index 7ac902f..dfd0c4e 100644 (file)
@@ -1,56 +1,56 @@
-/*
- * ============LICENSE_START========================================================================
- * ONAP : tr-069-adapter
- * =================================================================================================
- * Copyright (C) 2020 CommScope Inc Intellectual Property.
- * =================================================================================================
- * This tr-069-adapter software file is distributed by CommScope Inc 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
- *
- * This file 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.commscope.tr069adapter.mapper.model;
-
-import java.io.Serializable;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
-public class NetConfNotificationDTO implements Serializable {
-
-  private static final long serialVersionUID = 4928942484595767042L;
-  private String notificaiton;
-  private String deviceID;
-
-  public NetConfNotificationDTO() {
-    super();
-  }
-
-  public NetConfNotificationDTO(String deviceID, String notificaiton) {
-    super();
-    this.deviceID = deviceID;
-    this.notificaiton = notificaiton;
-  }
-
-  public String getDeviceID() {
-    return deviceID;
-  }
-
-  public void setDeviceID(String deviceID) {
-    this.deviceID = deviceID;
-  }
-
-  public String getNotificaiton() {
-    return notificaiton;
-  }
-
-  public void setNotificaiton(String notificaiton) {
-    this.notificaiton = notificaiton;
-  }
-}
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.mapper.model;\r
+\r
+import java.io.Serializable;\r
+import com.fasterxml.jackson.annotation.JsonTypeInfo;\r
+\r
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")\r
+public class NetConfNotificationDTO implements Serializable {\r
+\r
+  private static final long serialVersionUID = 4928942484595767042L;\r
+  private String deviceID;\r
+  private String notificaiton;\r
+\r
+  public NetConfNotificationDTO() {\r
+    super();\r
+  }\r
+\r
+  public NetConfNotificationDTO(String deviceID, String notificaiton) {\r
+    super();\r
+    this.deviceID = deviceID;\r
+    this.notificaiton = notificaiton;\r
+  }\r
+\r
+  public String getDeviceID() {\r
+    return deviceID;\r
+  }\r
+\r
+  public void setDeviceID(String deviceID) {\r
+    this.deviceID = deviceID;\r
+  }\r
+\r
+  public String getNotificaiton() {\r
+    return notificaiton;\r
+  }\r
+\r
+  public void setNotificaiton(String notificaiton) {\r
+    this.notificaiton = notificaiton;\r
+  }\r
+}\r
index a264472..d79a679 100644 (file)
@@ -102,8 +102,7 @@ public class NetConfServerDetails implements Serializable {
   @Override\r
   public String toString() {\r
     return "NetConfServerDetails [deviceId=" + deviceId + ", enodeBName=" + enodeBName\r
-        + ", listenAddress=" + listenAddress + ", listenPort=" + listenPort + ", error=" + error\r
-        + "]";\r
+        + ", listenAddress=" + listenAddress + ", listenPort=" + listenPort + ", swversion="\r
+        + swVersion + ", hwversion=" + hwVersion + ", error=" + error + "]";\r
   }\r
-\r
 }\r
index 3dcd8b9..f801ba7 100644 (file)
          <groupId>org.springframework.boot</groupId>\r
          <artifactId>spring-boot-starter-activemq</artifactId>\r
       </dependency>\r
+      <dependency>\r
+                <groupId>org.springframework</groupId>\r
+                <artifactId>spring-jms</artifactId>\r
+         </dependency>\r
       <dependency>\r
          <groupId>com.fasterxml.jackson.core</groupId>\r
          <artifactId>jackson-databind</artifactId>\r
index b4ea478..9614865 100644 (file)
 \r
 package org.commscope.tr069adapter.netconf.boot;\r
 \r
+import java.util.Arrays;\r
+import javax.jms.ConnectionFactory;\r
+import org.apache.activemq.ActiveMQConnectionFactory;\r
+import org.apache.activemq.RedeliveryPolicy;\r
+import org.apache.activemq.broker.BrokerService;\r
+import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap;\r
+import org.apache.activemq.command.ActiveMQQueue;\r
 import org.commscope.tr069adapter.netconf.server.NetConfServerManagerImpl;\r
+import org.commscope.tr069adapter.netconf.server.utils.NetConfServerConstants;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 import org.springframework.boot.SpringApplication;\r
 import org.springframework.boot.autoconfigure.SpringBootApplication;\r
 import org.springframework.boot.autoconfigure.domain.EntityScan;\r
+import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;\r
 import org.springframework.context.ApplicationContext;\r
+import org.springframework.context.annotation.Bean;\r
 import org.springframework.context.annotation.ComponentScan;\r
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;\r
+import org.springframework.jms.annotation.EnableJms;\r
+import org.springframework.jms.config.DefaultJmsListenerContainerFactory;\r
+import org.springframework.jms.config.JmsListenerContainerFactory;\r
+import org.springframework.jms.listener.MessageListenerContainer;\r
+import org.springframework.jms.support.converter.MappingJackson2MessageConverter;\r
+import org.springframework.jms.support.converter.MessageConverter;\r
+import org.springframework.jms.support.converter.MessageType;\r
 import org.springframework.retry.annotation.EnableRetry;\r
 \r
+@EnableJms\r
 @SpringBootApplication\r
 @ComponentScan({"org.commscope.tr069adapter.netconf", "org.opendaylight.netconf.test",\r
     "org.commscope.tr069adapter.common"})\r
@@ -57,4 +75,61 @@ public class NetConfServiceBooter {
   public static ApplicationContext getApplicationContext() {\r
     return appContext;\r
   }\r
+\r
+  /*\r
+   * JMS Configuration Defining the connection factories used in the application Setting the\r
+   * Re-delivery configuration goes here\r
+   */\r
+  @Bean\r
+  public BrokerService broker() throws Exception {\r
+    final BrokerService broker = new BrokerService();\r
+    broker.addConnector("tcp://localhost:61616");\r
+    broker.addConnector("vm://localhost");\r
+    broker.setPersistent(false);\r
+    return broker;\r
+  }\r
+\r
+  @Bean\r
+  public ConnectionFactory jmsConnectionFactory() {\r
+    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();\r
+    connectionFactory\r
+        .setTrustedPackages(Arrays.asList("org.commscope", "org.commscope.tr069adapter"));\r
+    connectionFactory.setMaxThreadPoolSize(7);\r
+\r
+    ActiveMQQueue notificationQueue = new ActiveMQQueue(NetConfServerConstants.NETCONF_NOTIFICATION_Q);\r
+    RedeliveryPolicy notificationQueuePolicy = new RedeliveryPolicy();\r
+    notificationQueuePolicy.setInitialRedeliveryDelay(2* 60 * 1000L);\r
+    notificationQueuePolicy.setUseCollisionAvoidance(true);\r
+    notificationQueuePolicy.setRedeliveryDelay(2* 60 * 1000L);\r
+    notificationQueuePolicy.setUseExponentialBackOff(false);\r
+    notificationQueuePolicy.setMaximumRedeliveries(3);\r
+    notificationQueuePolicy.setDestination(notificationQueue);\r
+\r
+    RedeliveryPolicyMap rdMap = connectionFactory.getRedeliveryPolicyMap();\r
+    rdMap.put(notificationQueue, notificationQueuePolicy);\r
+    return connectionFactory;\r
+  }\r
+\r
+  @Bean\r
+  public JmsListenerContainerFactory<MessageListenerContainer> netConfNotificationCF(\r
+      ConnectionFactory connectionFactory,\r
+      DefaultJmsListenerContainerFactoryConfigurer configurer) {\r
+    return handleJMSCommonConfiguration(connectionFactory, configurer);\r
+  }\r
+\r
+  public JmsListenerContainerFactory handleJMSCommonConfiguration(\r
+      ConnectionFactory connectionFactory,\r
+      DefaultJmsListenerContainerFactoryConfigurer configurer) {\r
+    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();\r
+    configurer.configure(factory, connectionFactory);\r
+    return factory;\r
+  }\r
+\r
+  @Bean\r
+  public MessageConverter jacksonJmsMessageConverter() {\r
+    MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();\r
+    converter.setTargetType(MessageType.TEXT);\r
+    converter.setTypeIdPropertyName("_type");\r
+    return converter;\r
+  }\r
 }\r
diff --git a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/error/NetconfNotificationException.java b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/error/NetconfNotificationException.java
new file mode 100644 (file)
index 0000000..c3c54ab
--- /dev/null
@@ -0,0 +1,31 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.netconf.error;\r
+\r
+public class NetconfNotificationException extends Exception {\r
+  private static final long serialVersionUID = -7152022827444291350L;\r
+\r
+  public NetconfNotificationException(String message) {\r
+    super(message);\r
+  }\r
+\r
+  public NetconfNotificationException(String message, Throwable cause) {\r
+    super(message, cause);\r
+  }\r
+}\r
diff --git a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/notification/NetConfNotificationQueue.java b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/notification/NetConfNotificationQueue.java
new file mode 100644 (file)
index 0000000..d407ed4
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.netconf.notification;\r
+\r
+import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
+import org.commscope.tr069adapter.netconf.error.NetconfNotificationException;\r
+import org.commscope.tr069adapter.netconf.server.utils.NetConfServerConstants;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.jms.annotation.JmsListener;\r
+import org.springframework.stereotype.Component;\r
+import org.springframework.transaction.annotation.Transactional;\r
+\r
+@Component\r
+public class NetConfNotificationQueue {\r
+\r
+  private static final Logger logger = LoggerFactory.getLogger(NetConfNotificationQueue.class);\r
+\r
+  @Autowired\r
+  NetConfSessionUtil netConfSessionUtil;;\r
+\r
+  @JmsListener(destination = NetConfServerConstants.NETCONF_NOTIFICATION_Q,\r
+      containerFactory = NetConfServerConstants.NETCONF_NOTIFICATION_CF)\r
+  @Transactional(rollbackFor = NetconfNotificationException.class)\r
+  public void onMessage(NetConfNotificationDTO netConNotifDTO) throws NetconfNotificationException {\r
+    if (null != netConNotifDTO) {\r
+      logger.debug("Netconf notification is received for deviceId : {} ",\r
+          netConNotifDTO.getDeviceID());\r
+      netConfSessionUtil.sendNetConfNotification(netConNotifDTO);\r
+      logger.debug("Successfully processed device notification.");\r
+    } else {\r
+      logger.error("Null device response is received!!!");\r
+    }\r
+  }\r
+}\r
index 70965a0..55c40b2 100644 (file)
@@ -1,72 +1,50 @@
-/*
- * ============LICENSE_START========================================================================
- * ONAP : tr-069-adapter
- * =================================================================================================
- * Copyright (C) 2020 CommScope Inc Intellectual Property.
- * =================================================================================================
- * This tr-069-adapter software file is distributed by CommScope Inc 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
- *
- * This file 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.commscope.tr069adapter.netconf.notification;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;
-import org.commscope.tr069adapter.netconf.rpc.CreateSubscription;
-import org.opendaylight.netconf.api.NetconfMessage;
-import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-@Component
-public class NetConfSessionUtil {
-
-  private static final Logger LOG = LoggerFactory.getLogger(NetConfSessionUtil.class);
-
-  public void sendNetConfNotification(NetConfNotificationDTO netConNotifDTO) {
-    NetconfMessage netconfMessage = convertToNetConfMessage(netConNotifDTO);
-    LOG.debug("Notification converted to NetConf format" + netconfMessage);
-    CreateSubscription.sendNotification(netconfMessage, netConNotifDTO.getDeviceID());
-  }
-
-  private NetconfMessage convertToNetConfMessage(NetConfNotificationDTO netConNotifDTO) {
-    try {
-      return new NetconfMessage(XmlUtil.readXmlToDocument(netConNotifDTO.getNotificaiton()));
-    } catch (SAXException | IOException e) {
-      throw new IllegalArgumentException("Cannot parse notifications", e);
-    }
-  }
-
-  public static String convertDocumentToString(Element element) {
-    String strxml = null;
-    try {
-      TransformerFactory transformerFactory = TransformerFactory.newInstance();
-      Transformer transformer = transformerFactory.newTransformer();
-      DOMSource source = new DOMSource(element);
-      StreamResult result = new StreamResult(new StringWriter());
-      transformer.transform(source, result);
-      strxml = result.getWriter().toString();
-    } catch (Exception e) {
-      LOG.error("Error while converting Element to String" + e);
-    }
-    LOG.debug("Converted XML is : " + strxml);
-    return strxml;
-  }
-
-}
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.netconf.notification;\r
+\r
+import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
+import org.commscope.tr069adapter.netconf.error.NetconfNotificationException;\r
+import org.commscope.tr069adapter.netconf.rpc.CreateSubscription;\r
+import org.opendaylight.netconf.api.NetconfMessage;\r
+import org.opendaylight.netconf.api.xml.XmlUtil;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.stereotype.Component;\r
+\r
+@Component\r
+public class NetConfSessionUtil {\r
+\r
+  private static final Logger LOG = LoggerFactory.getLogger(NetConfSessionUtil.class);\r
+\r
+  public void sendNetConfNotification(NetConfNotificationDTO netConNotifDTO)\r
+      throws NetconfNotificationException {\r
+    NetconfMessage netconfMessage = convertToNetConfMessage(netConNotifDTO);\r
+    CreateSubscription.sendNotification(netconfMessage, netConNotifDTO.getDeviceID());\r
+  }\r
+\r
+  private NetconfMessage convertToNetConfMessage(NetConfNotificationDTO netConNotifDTO)\r
+      throws NetconfNotificationException {\r
+    try {\r
+      return new NetconfMessage(XmlUtil.readXmlToDocument(netConNotifDTO.getNotificaiton()));\r
+    } catch (Exception e) {\r
+      LOG.error("Error while converting to netcon notification ");\r
+      throw new NetconfNotificationException("Cannot parse notifications", e);\r
+    }\r
+  }\r
+}\r
index 71197d0..fe80c4a 100644 (file)
 package org.commscope.tr069adapter.netconf.notification;\r
 \r
 import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
+import org.commscope.tr069adapter.netconf.server.utils.NetConfServerConstants;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
+import org.slf4j.MDC;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.jms.core.JmsTemplate;\r
 import org.springframework.stereotype.Component;\r
 \r
 @Component\r
 public class NotificationHandler {\r
 \r
-  private static final Logger LOG = LoggerFactory.getLogger(NotificationHandler.class);\r
+  private static final Logger logger = LoggerFactory.getLogger(NotificationHandler.class);\r
+  private static final String CLIENT_STR = "client";\r
 \r
   @Autowired\r
   NetConfSessionUtil netConfSessionUtil;\r
 \r
+  @Autowired\r
+  private JmsTemplate jmsTemplate;\r
+\r
   public void handleNetConfNotification(NetConfNotificationDTO netConNotifDTO) {\r
-    LOG.debug("processing netconf notification " + netConNotifDTO);\r
-    netConfSessionUtil.sendNetConfNotification(netConNotifDTO);\r
-  }\r
+    logger.debug("processing netconf notification {}", netConNotifDTO);\r
+    try {\r
+      MDC.put(CLIENT_STR, netConNotifDTO.getDeviceID());\r
 \r
+      logger.debug("NetConf notificaiton reviced for {}", netConNotifDTO.getDeviceID());\r
+      jmsTemplate.convertAndSend(NetConfServerConstants.NETCONF_NOTIFICATION_Q, netConNotifDTO);\r
+      logger.debug("Successfully posted the notiticaiton to JMS to forward to SDNR");\r
+    } catch (Exception e) {\r
+      logger.error("Posting notification failed; Reason: {}", e.getMessage());\r
+    } finally {\r
+      MDC.remove(CLIENT_STR);\r
+    }\r
+  }\r
 }\r
index 5d01486..6057c67 100644 (file)
@@ -44,22 +44,22 @@ public class NetConfServerManagerRestApi {
   public NetConfServerDetails createNetConfServerInstance(@RequestParam String deviceId,\r
       @RequestParam String enodeBName, @RequestParam String swVersion,\r
       @RequestParam String hwVersion) {\r
-    LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}", deviceId,\r
-        enodeBName);\r
+    LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}, swversion: {}", deviceId,\r
+        enodeBName, swVersion);\r
     NetConfServerDetails serverDetails =\r
         manager.createServer(deviceId, enodeBName, swVersion, hwVersion);\r
     LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails);\r
     return serverDetails;\r
   }\r
 \r
-  @PostMapping("/restartServer")\r
-  public NetConfServerDetails resatrtNetConfServerInstance(@RequestParam String deviceId,\r
+  @PostMapping("/restartOnVersionChange")\r
+  public NetConfServerDetails restartOnVersionChange(@RequestParam String deviceId,\r
       @RequestParam String enodeBName, @RequestParam String swVersion,\r
       @RequestParam String hwVersion) {\r
     LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}", deviceId,\r
         enodeBName);\r
     NetConfServerDetails serverDetails =\r
-        manager.restartServer(deviceId, enodeBName, swVersion, hwVersion);\r
+        manager.restartOnVersionChange(deviceId, enodeBName, swVersion, hwVersion);\r
     LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails);\r
     return serverDetails;\r
   }\r
index ebb2074..a5ac333 100644 (file)
@@ -18,9 +18,6 @@
 \r
 package org.commscope.tr069adapter.netconf.rpc;\r
 \r
-import com.google.common.base.Preconditions;\r
-import com.google.common.collect.Maps;\r
-\r
 import java.io.File;\r
 import java.io.IOException;\r
 import java.text.SimpleDateFormat;\r
@@ -34,12 +31,11 @@ import java.util.Optional;
 import java.util.concurrent.Executors;\r
 import java.util.concurrent.ScheduledExecutorService;\r
 import java.util.concurrent.TimeUnit;\r
-\r
 import javax.xml.bind.JAXBContext;\r
 import javax.xml.bind.JAXBException;\r
 import javax.xml.bind.Unmarshaller;\r
 import javax.xml.bind.annotation.XmlRootElement;\r
-\r
+import org.commscope.tr069adapter.netconf.error.NetconfNotificationException;\r
 import org.opendaylight.netconf.api.NetconfMessage;\r
 import org.opendaylight.netconf.api.xml.XmlElement;\r
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;\r
@@ -52,6 +48,8 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;\r
 import org.w3c.dom.Element;\r
 import org.xml.sax.SAXException;\r
+import com.google.common.base.Preconditions;\r
+import com.google.common.collect.Maps;\r
 \r
 public class CreateSubscription extends AbstractLastNetconfOperation\r
     implements DefaultNetconfOperation {\r
@@ -163,17 +161,26 @@ public class CreateSubscription extends AbstractLastNetconfOperation
     netconfServerSessionMap.put(deviceID, newSession);\r
   }\r
 \r
-  public static void sendNotification(NetconfMessage netconfMessage, String deviceID) {\r
+  public static void sendNotification(NetconfMessage netconfMessage, String deviceID)\r
+      throws NetconfNotificationException {\r
     logger.debug("Request to send notification. NetConfMessage : {}", netconfMessage);\r
     NetconfServerSession session = netconfServerSessionMap.get(deviceID);\r
     if (session != null && session.isUp()) {\r
-      session.sendMessage(netconfMessage);\r
-      logger.debug("Successfully send notification for deviceID: {}", deviceID);\r
+      try {\r
+        session.sendMessage(netconfMessage);\r
+        logger.debug("Successfully send notification for deviceID: {}", deviceID);\r
+      } catch (Exception e) {\r
+        logger.error("Failed to send notification. while posting got error. {}", e.toString());\r
+        throw new NetconfNotificationException("Exception while posting the netconf message", e);\r
+      }\r
+\r
     } else {\r
-      logger.debug("Failed to send notification. None of valid netconf session is available.");\r
+      logger.debug(\r
+          "Failed to send notification. None of valid netconf session is available for {}.",\r
+          deviceID);\r
+      logger.debug("Available netconf sessions : {}", netconfServerSessionMap);\r
+      throw new NetconfNotificationException("NetConf active session deosn't not exist");\r
     }\r
-    logger.debug("Available netconf sessions : {}", netconfServerSessionMap);\r
-\r
   }\r
 \r
   @XmlRootElement(name = "notifications")\r
index 80c65e9..852d205 100644 (file)
@@ -112,7 +112,7 @@ public class NetConfServerManagerImpl {
         }\r
       }\r
     } catch (Exception e) {\r
-      LOG.error("Load schemas failed in netconf server {}", e.getMessage());\r
+      LOG.error("Load schema's failed in netconf server {}", e.getMessage());\r
       return false;\r
     }\r
     LOG.debug("Loading yang schema completed");\r
@@ -132,7 +132,7 @@ public class NetConfServerManagerImpl {
         try {\r
           restartServersHandler.restart(entity);\r
         } catch (RetryFailedException e) {\r
-          e.printStackTrace();\r
+          LOG.error("submit task for restarting is failed {}", e.toString());\r
         }\r
       }\r
     }\r
@@ -154,15 +154,17 @@ public class NetConfServerManagerImpl {
       return null;\r
     }\r
 \r
-    if (null != entity) {\r
+    if (null != entity && ncServerStarter.isNetConfServerRunning(deviceId)) {\r
+      if (isVersionChanged(entity, swVersion, hwVersion)) {\r
+        return restartOnVersionChange(deviceId, enodeBName, swVersion, hwVersion);\r
+      }\r
+\r
       // found the entity. server is already running. double check and run\r
       // if\r
       // required. else return the details.\r
 \r
       // update the ENB Name if Changed\r
       entity.setEnodeBName(enodeBName);\r
-      entity.setSwVersion(swVersion);\r
-      entity.setHwVersion(hwVersion);\r
       netconfDAO.save(entity);\r
       result = getNetConfServerDetails(deviceId, entity);\r
       return result;\r
@@ -221,29 +223,50 @@ public class NetConfServerManagerImpl {
     return result;\r
   }\r
 \r
-  public NetConfServerDetails restartServer(String deviceId, String enodeBName, String swVersion,\r
-      String hwVersion) {\r
+  public NetConfServerDetails restartOnVersionChange(String deviceId, String enodeBName,\r
+      String swVersion, String hwVersion) {\r
 \r
     NetConfServerDetailsEntity entity = null;\r
     if (deviceId != null) {\r
       entity = netconfDAO.findByDeviceId(deviceId);\r
     }\r
-    if (entity != null) {\r
-      boolean result = this.ncServerStarter.stopServer(deviceId);\r
-      restartServersOnStartup(entity);\r
+    if (entity == null) {\r
+      return null;\r
     }\r
 \r
-    return null;\r
+    boolean isVersionChanged = isVersionChanged(entity, swVersion, hwVersion);\r
+    if (isVersionChanged) {\r
+      LOG.debug("software version changed, stopping the the existing netconf instance");\r
+      boolean result = this.ncServerStarter.stopServer(deviceId);\r
+      if (result) {\r
+        LOG.debug(\r
+            "successfully stopped the netconf instance; trying to start with new version yang models");\r
+        entity.setSwVersion(swVersion);\r
+        entity.setHwVersion(hwVersion);\r
+        netconfDAO.save(entity);\r
+\r
+        boolean isSuccess = startNetConfServerInstance(entity);\r
+\r
+        if (!isSuccess) {\r
+          try {\r
+            restartServersHandler.restart(entity);\r
+          } catch (RetryFailedException e) {\r
+            LOG.debug("");\r
+          }\r
+        }\r
+      }\r
+    }\r
+    return getNetConfServerDetails(deviceId, entity);\r
   }\r
 \r
 \r
-  public boolean restartServersOnStartup(NetConfServerDetailsEntity entity) {\r
+  public boolean startNetConfServerInstance(NetConfServerDetailsEntity entity) {\r
     boolean isSuccess = false;\r
 \r
     boolean isServerStarted = ncServerStarter.startServer(entity.getListenPort(),\r
         entity.getDeviceId(), entity.getSwVersion(), entity.getHwVersion());\r
     if (isServerStarted) {\r
-      LOG.info("Successfully restarted NETCONF server {}  on port {}  upon application startup.",\r
+      LOG.info("Successfully restarted NETCONF server {}  on port {} .",\r
           entity.getDeviceId(), entity.getListenPort());\r
       // we need to push the pnfEntry for IP updated\r
       NetConfServerDetails details = getNetConfServerDetails(entity.getDeviceId(), entity);\r
@@ -308,6 +331,7 @@ public class NetConfServerManagerImpl {
       resultMsg = "Failed to unregister the device " + deviceId + ", enodeBName=" + enodeBName\r
           + ". Invalid deviceId/enodeBName specified.";\r
       LOG.info(resultMsg);\r
+      return resultMsg;\r
     }\r
     boolean result = this.ncServerStarter.stopServer(deviceId);\r
     if (result) {\r
@@ -386,6 +410,14 @@ public class NetConfServerManagerImpl {
     return null;\r
   }\r
 \r
+  private boolean isVersionChanged(NetConfServerDetailsEntity entity, String swVersion,\r
+      String hwVersion) {\r
+    String existingProfileId =\r
+        versionManager.getAssociatedProfileId(entity.getSwVersion(), entity.getHwVersion());\r
+    String newProfiled = versionManager.getAssociatedProfileId(swVersion, hwVersion);\r
+    return !existingProfileId.equalsIgnoreCase(newProfiled) ? true : false;\r
+  }\r
+\r
   class ServerStartTask implements Runnable {\r
 \r
     NetConfServerDetailsEntity entity;\r
@@ -399,7 +431,7 @@ public class NetConfServerManagerImpl {
 \r
     @Override\r
     public void run() {\r
-      boolean isSuccess = netconfServerManager.restartServersOnStartup(entity);\r
+      boolean isSuccess = netconfServerManager.startNetConfServerInstance(entity);\r
       if (!isSuccess) {\r
         try {\r
           netconfServerManager.restartServersHandler.restart(entity);\r
index 10ab624..392b693 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;\r
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
-import org.apache.commons.io.FileUtils;\r
 import org.commscope.tr069adapter.common.deviceversion.DeviceVersionManager;\r
 import org.commscope.tr069adapter.netconf.config.NetConfServerProperties;\r
 import org.commscope.tr069adapter.netconf.operations.CustomOperationsCreator;\r
@@ -100,7 +99,7 @@ public class NetconfServerStarter {
     configuration.setSsh(Boolean.TRUE);\r
     configuration.setCapabilities(Configuration.DEFAULT_BASE_CAPABILITIES_EXI);\r
     configuration.setIp("0.0.0.0");\r
-    \r
+\r
     String versionPath = versionManager.getNetconfYangSchemaPath(swVersion, hwVersion);\r
     if (versionPath == null && swVersion != null) {\r
       LOG.error("Failed to get version path for software version {}, calling base version",\r
@@ -136,6 +135,7 @@ public class NetconfServerStarter {
       NetconfDevice netconf = serversMap.get(macID);\r
       netconf.setAutoClose(true);\r
       netconf.close();\r
+      serversMap.remove(macID);\r
       LOG.debug("Completed stopping Netconf server for MACID {}", macID);\r
       return true;\r
     } catch (Exception e) {\r
@@ -178,6 +178,14 @@ public class NetconfServerStarter {
     return true;\r
   }\r
 \r
+  public boolean isNetConfServerRunning(String deviceId) {\r
+    NetconfDevice nc = serversMap.get(deviceId);\r
+    if (null != nc)\r
+      return true;\r
+    else\r
+      return false;\r
+  }\r
+\r
   private void loadSchemaPattren(String line, File file, Pattern revisionregex) {\r
     if (line != null) {\r
       final Matcher m = revisionregex.matcher(line);\r
index 6f7f9f2..bce2534 100644 (file)
@@ -40,14 +40,14 @@ public class RestartNetconfServerHandler {
   @Autowired\r
   ServerPortAllocationHelper serverPortAllocator;\r
 \r
-  @Retryable(value = {RetryFailedException.class}, maxAttempts = 100,\r
+  @Retryable(value = {RetryFailedException.class}, maxAttempts = 10,\r
       backoff = @Backoff(delay = 15000))\r
   public void restart(NetConfServerDetailsEntity entity) throws RetryFailedException {\r
     boolean isSucess = false;\r
     try {\r
       // restart netconf servers\r
       serverPortAllocator.checkAndReserveServerPort(entity.getListenPort());\r
-      isSucess = manager.restartServersOnStartup(entity);\r
+      isSucess = manager.startNetConfServerInstance(entity);\r
     } catch (Exception e) {\r
       logger.error("Retry to netconf servers has  is failed. {}", e.toString());\r
       throw new RetryFailedException(e);\r
index 11b3946..222f6bb 100644 (file)
  * ===============LICENSE_END=======================================================================
  */
 
-package org.commscope.tr069adapter.netconf.server.utils;\r
-\r
-public class NetConfServerConstants {\r
-  private NetConfServerConstants() {\r
-    throw new IllegalStateException("Utility class");\r
-  }\r
-\r
-  public static final String HEART_BEAT = "heartbeat";\r
-  public static final int SUCCESS = 0;\r
-}\r
+package org.commscope.tr069adapter.netconf.server.utils;
+
+public class NetConfServerConstants {
+  private NetConfServerConstants() {
+    throw new IllegalStateException("Utility class");
+  }
+
+  public static final String NETCONF_NOTIFICATION_Q = "NetConfNotificationQueue";
+  public static final String NETCONF_NOTIFICATION_CF = "netConfNotificationCF";
+  public static final String HEART_BEAT = "heartbeat";
+  public static final int SUCCESS = 0;
+}