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