X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Flisteners%2FDeviceListener710.java;h=13b044345871e0d198ca9eceb27003550fa90e6c;hb=d03abd5d1287ce81ae3c6c4ff58fe255c77fc427;hp=2e24236e32dd7decc8117f0e5cd88796564f5a2f;hpb=d122f702163dae63be448259ab108fdcac29a5ac;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710.java index 2e24236e3..13b044345 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710.java @@ -13,11 +13,12 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +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.rev210426.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.ChangeNotification; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OrgOpenroadmDeviceListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.OtdrScanResult; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.Edit; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.Ports; @@ -31,7 +32,7 @@ import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DeviceListener710 implements OrgOpenroadmDeviceListener { +public class DeviceListener710 { private static final Logger LOG = LoggerFactory.getLogger(DeviceListener710.class); private final String nodeId; @@ -43,15 +44,21 @@ public class DeviceListener710 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 - @SuppressWarnings("unchecked") - public void onChangeNotification(ChangeNotification notification) { + void onChangeNotification(ChangeNotification notification) { LOG.debug("device71 notification received = {}", notification); if (notification.getEdit() == null) { LOG.warn("unable to handle {} notificatin received - list of edit is null", ChangeNotification.QNAME); @@ -68,12 +75,10 @@ public class DeviceListener710 implements OrgOpenroadmDeviceListener { switch (edit.getTarget().getTargetType().getSimpleName()) { case "Ports": edit.getTarget().getPathArguments().forEach(p -> path.add(p)); - InstanceIdentifier portIID = (InstanceIdentifier) InstanceIdentifier - .create(path); + InstanceIdentifier portIID = InstanceIdentifier.unsafeOf(path); String portName = InstanceIdentifier.keyOf(portIID).getPortName(); path.removeLast(); - InstanceIdentifier cpIID = (InstanceIdentifier) InstanceIdentifier - .create(path); + InstanceIdentifier cpIID = InstanceIdentifier.unsafeOf(path); String cpName = InstanceIdentifier.keyOf(cpIID).getCircuitPackName(); LOG.info("port {} of circruit-pack {} modified on device {}", portName, cpName, this.nodeId); Mapping oldMapping = portMapping.getMapping(nodeId, cpName, portName); @@ -94,14 +99,13 @@ public class DeviceListener710 implements OrgOpenroadmDeviceListener { case "OduSwitchingPools": LOG.info("odu-switching-pools modified on device {}", nodeId); edit.getTarget().getPathArguments().forEach(p -> path.add(p)); - ospIID = (InstanceIdentifier) InstanceIdentifier.create(path); + ospIID = InstanceIdentifier.unsafeOf(path); break; case "PortList": edit.getTarget().getPathArguments().forEach(p -> path.add(p)); - InstanceIdentifier plIID = (InstanceIdentifier) InstanceIdentifier.create(path); + InstanceIdentifier plIID = InstanceIdentifier.unsafeOf(path); path.removeLast(); - InstanceIdentifier nblIID = - (InstanceIdentifier) InstanceIdentifier.create(path); + InstanceIdentifier nblIID = InstanceIdentifier.unsafeOf(path); Uint16 nblNb = InstanceIdentifier.keyOf(nblIID).getNblNumber(); List> iidList = nbliidMap.containsKey(nblNb) ? nbliidMap.get(nblNb) : new ArrayList<>(); @@ -127,8 +131,7 @@ public class DeviceListener710 implements OrgOpenroadmDeviceListener { } } - @Override - public void onCreateTechInfoNotification(CreateTechInfoNotification notification) { + private void onCreateTechInfoNotification(CreateTechInfoNotification notification) { } /** @@ -137,8 +140,7 @@ public class DeviceListener710 implements OrgOpenroadmDeviceListener { * @param notification * OtdrScanResult object */ - @Override - public void onOtdrScanResult(OtdrScanResult notification) { + private void onOtdrScanResult(OtdrScanResult notification) { LOG.info("Notification {} received {}", OtdrScanResult.QNAME, notification); }