X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Fdto%2FNodeRegistration.java;h=61fd4b7f48c3e9a96494e402ae5c6199ad94b925;hb=d03abd5d1287ce81ae3c6c4ff58fe255c77fc427;hp=e802091b5e2d7fcaa1997dfa5975e1914e649231;hpb=0da8cea9fcd1c78753493ed6929f6e3241da06df;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/dto/NodeRegistration.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/dto/NodeRegistration.java index e802091b5..61fd4b7f4 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/dto/NodeRegistration.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/dto/NodeRegistration.java @@ -7,60 +7,122 @@ */ package org.opendaylight.transportpce.networkmodel.dto; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev161014.OrgOpenroadmAlarmListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev161014.OrgOpenroadmDeOperationsListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.OrgOpenroadmLldpListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev161014.OrgOpenroadmTcaListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.transportpce.common.StringConstants; +import org.opendaylight.transportpce.common.mapping.PortMapping; +import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener; +import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener221; +import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener710; +import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener; +import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener221; +import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener710; +import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener121; +import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener221; +import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener710; +import org.opendaylight.transportpce.networkmodel.listeners.TcaListener; +import org.opendaylight.transportpce.networkmodel.listeners.TcaListener221; +import org.opendaylight.transportpce.networkmodel.listeners.TcaListener710; +import org.opendaylight.yangtools.concepts.Registration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NodeRegistration { - + private static final Logger LOG = LoggerFactory.getLogger(NodeRegistration.class); private final String nodeId; - private final ListenerRegistration accessAlarmNotificationListenerRegistration; - private final ListenerRegistration - accessDeOperationasNotificationListenerRegistration; - private final ListenerRegistration accessDeviceNotificationListenerRegistration; - private final ListenerRegistration accessLldpNotificationListenerRegistration; - private final ListenerRegistration accessTcaNotificationListenerRegistration; - - public NodeRegistration(String nodeId, - ListenerRegistration accessAlarmNotificationListenerRegistration, - ListenerRegistration accessDeOperationasNotificationListenerRegistration, - ListenerRegistration accessDeviceNotificationListenerRegistration, - ListenerRegistration accessLldpNotificationListenerRegistration, - ListenerRegistration accessTcaNotificationListenerRegistration) { + private final String nodeVersion; + private final NotificationService notificationService; + private final DataBroker dataBroker; + private final PortMapping portMapping; + private final List listeners; + + public NodeRegistration(String nodeId, String nodeVersion, NotificationService notificationService, + DataBroker dataBroker, PortMapping portMapping) { this.nodeId = nodeId; - this.accessAlarmNotificationListenerRegistration = accessAlarmNotificationListenerRegistration; - this.accessDeOperationasNotificationListenerRegistration = accessDeOperationasNotificationListenerRegistration; - this.accessDeviceNotificationListenerRegistration = accessDeviceNotificationListenerRegistration; - this.accessLldpNotificationListenerRegistration = accessLldpNotificationListenerRegistration; - this.accessTcaNotificationListenerRegistration = accessTcaNotificationListenerRegistration; + this.nodeVersion = nodeVersion; + this.notificationService = notificationService; + this.dataBroker = dataBroker; + this.portMapping = portMapping; + listeners = new ArrayList(); } - public String getNodeId() { - return nodeId; + public void registerListeners() { + switch (this.nodeVersion) { + case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1: + registerListeners121(); + break; + case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1: + registerListeners221(); + break; + case StringConstants.OPENROADM_DEVICE_VERSION_7_1: + registerListeners710(); + break; + default: + LOG.debug("Unable to register listeners - unknown device version for {}", this.nodeId); + break; + } } - public ListenerRegistration getAccessAlarmNotificationListenerRegistration() { - return accessAlarmNotificationListenerRegistration; + public void unregisterListeners() { + LOG.info("Unregistering notification listeners for node: {}", this.nodeId); + for (Registration listenerRegistration : listeners) { + listenerRegistration.close(); + } } - public ListenerRegistration - getAccessDeOperationasNotificationListenerRegistration() { - return accessDeOperationasNotificationListenerRegistration; - } + private void registerListeners121() { + AlarmNotificationListener alarmListener = new AlarmNotificationListener(this.dataBroker); + LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(alarmListener.getCompositeListener())); - public ListenerRegistration getAccessDeviceNotificationListenerRegistration() { - return accessDeviceNotificationListenerRegistration; - } + DeOperationsListener deOperationsListener = new DeOperationsListener(); + LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deOperationsListener.getCompositeListener())); + + DeviceListener121 deviceListener = new DeviceListener121(nodeId, this.portMapping); + LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deviceListener.getCompositeListener())); - public ListenerRegistration getAccessLldpNotificationListenerRegistration() { - return accessLldpNotificationListenerRegistration; + TcaListener tcaListener = new TcaListener(); + LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(tcaListener.getCompositeListener())); } - public ListenerRegistration getAccessTcaNotificationListenerRegistration() { - return accessTcaNotificationListenerRegistration; + private void registerListeners221() { + AlarmNotificationListener221 alarmListener = new AlarmNotificationListener221(dataBroker); + LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(alarmListener.getCompositeListener())); + + DeOperationsListener221 deOperationsListener = new DeOperationsListener221(); + LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deOperationsListener.getCompositeListener())); + + DeviceListener221 deviceListener = new DeviceListener221(nodeId, this.portMapping); + LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deviceListener.getCompositeListener())); + + TcaListener221 tcaListener = new TcaListener221(); + LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(tcaListener.getCompositeListener())); } + private void registerListeners710() { + AlarmNotificationListener710 alarmListener = new AlarmNotificationListener710(dataBroker); + LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(alarmListener.getCompositeListener())); + + DeOperationsListener710 deOperationsListener = new DeOperationsListener710(); + LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deOperationsListener.getCompositeListener())); + + DeviceListener710 deviceListener = new DeviceListener710(nodeId, this.portMapping); + LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(deviceListener.getCompositeListener())); + + TcaListener710 tcaListener = new TcaListener710(); + LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId); + listeners.add(notificationService.registerCompositeListener(tcaListener.getCompositeListener())); + } }