X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Flisteners%2FDeviceListener221.java;h=d069c0196470f4460e82a33442c5c84d317d4833;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=7135e8f24e9e41891815ec47b467b171b212e899;hpb=a333c0c0b3bbe22066e3bcc4af4007d066c10e89;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221.java index 7135e8f24..d069c0196 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221.java @@ -9,22 +9,23 @@ package org.opendaylight.transportpce.networkmodel.listeners; import java.util.LinkedList; +import java.util.Set; +import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener; import org.opendaylight.transportpce.common.mapping.PortMapping; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.ChangeNotification; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CreateTechInfoNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OrgOpenroadmDeviceListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OtdrScanResult; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.change.notification.Edit; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface; +import org.opendaylight.yangtools.yang.binding.DataObjectStep; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DeviceListener221 implements OrgOpenroadmDeviceListener { +public class DeviceListener221 { private static final Logger LOG = LoggerFactory.getLogger(DeviceListener221.class); private final String nodeId; @@ -36,14 +37,21 @@ public class DeviceListener221 implements OrgOpenroadmDeviceListener { this.portMapping = portMapping; } + public CompositeListener getCompositeListener() { + return new CompositeListener(Set.of( + new CompositeListener.Component<>(ChangeNotification.class, this::onChangeNotification), + new CompositeListener.Component<>(CreateTechInfoNotification.class, this::onCreateTechInfoNotification), + new CompositeListener.Component<>(OtdrScanResult.class, this::onOtdrScanResult) + )); + } + /** * Callback for change-notification. * * @param notification * ChangeNotification object */ - @Override - public void onChangeNotification(ChangeNotification notification) { + void onChangeNotification(ChangeNotification notification) { LOG.info("notification received from device {}: {}", this.nodeId, notification.toString()); if (notification.getEdit() == null) { LOG.warn("unable to handle {} notificatin received - list of edit is null", ChangeNotification.QNAME); @@ -56,7 +64,7 @@ public class DeviceListener221 implements OrgOpenroadmDeviceListener { // 1. Detect the org-openroadm-device object modified switch (edit.getTarget().getTargetType().getSimpleName()) { case "Ports": - LinkedList path = new LinkedList<>(); + LinkedList> path = new LinkedList<>(); edit.getTarget().getPathArguments().forEach(p -> path.add(p)); InstanceIdentifier portIID = InstanceIdentifier.unsafeOf(path); String portName = InstanceIdentifier.keyOf(portIID).getPortName(); @@ -80,7 +88,7 @@ public class DeviceListener221 implements OrgOpenroadmDeviceListener { thread.start(); break; case "Interface": - LinkedList pathInter = new LinkedList<>(); + LinkedList> pathInter = new LinkedList<>(); edit.getTarget().getPathArguments().forEach(p -> pathInter.add(p)); InstanceIdentifier interfIID = InstanceIdentifier.unsafeOf(pathInter); String interfName = InstanceIdentifier.keyOf(interfIID).getName(); @@ -107,8 +115,7 @@ public class DeviceListener221 implements OrgOpenroadmDeviceListener { } } - @Override - public void onCreateTechInfoNotification(CreateTechInfoNotification notification) { + private void onCreateTechInfoNotification(CreateTechInfoNotification notification) { } /** @@ -117,8 +124,7 @@ public class DeviceListener221 implements OrgOpenroadmDeviceListener { * @param notification * OtdrScanResult object */ - @Override - public void onOtdrScanResult(OtdrScanResult notification) { + private void onOtdrScanResult(OtdrScanResult notification) { LOG.info("Notification {} received {}", OtdrScanResult.QNAME, notification); }