import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.networkmodel.dto.NodeRegistration;
import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscription;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240118.ConnectionOper.ConnectionStatus;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240118.connection.oper.available.capabilities.AvailableCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240611.ConnectionOper.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev240611.connection.oper.available.capabilities.AvailableCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev240611.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
public class NetConfTopologyListener implements DataTreeChangeListener<Node> {
private static final Logger LOG = LoggerFactory.getLogger(NetConfTopologyListener.class);
- private static final String RPC_SERVICE_FAILED = "Failed to get RpcService for node {}";
private final NetworkModelService networkModelService;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
}
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
+ public void onDataTreeChanged(List<DataTreeModification<Node>> changes) {
LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName());
for (DataTreeModification<Node> change : changes) {
DataObjectModification<Node> rootNode = change.getRootNode();
- if (rootNode.getDataBefore() == null) {
+ if (rootNode.dataBefore() == null) {
continue;
}
- String nodeId = rootNode.getDataBefore().key().getNodeId().getValue();
- NetconfNode netconfNodeBefore = rootNode.getDataBefore().augmentation(NetconfNode.class);
- switch (rootNode.getModificationType()) {
+ String nodeId = rootNode.dataBefore().key().getNodeId().getValue();
+ NetconfNode netconfNodeBefore = rootNode.dataBefore().augmentation(NetconfNode.class);
+ switch (rootNode.modificationType()) {
case DELETE:
if (this.networkModelService.deleteOpenRoadmnode(nodeId)) {
onDeviceDisConnected(nodeId);
}
break;
case WRITE:
- NetconfNode netconfNodeAfter = rootNode.getDataAfter().augmentation(NetconfNode.class);
+ NetconfNode netconfNodeAfter = rootNode.dataAfter().augmentation(NetconfNode.class);
if (ConnectionStatus.Connecting.equals(netconfNodeBefore.getConnectionStatus())
&& ConnectionStatus.Connected.equals(netconfNodeAfter.getConnectionStatus())) {
LOG.info("Connecting Node: {}", nodeId);
}
break;
default:
- LOG.debug("Unknown modification type {}", rootNode.getModificationType().name());
+ LOG.debug("Unknown modification type {}", rootNode.modificationType().name());
break;
}
}
MountPoint mountPoint = mountPointOpt.orElseThrow();
final Optional<NotificationService> notificationService = mountPoint.getService(NotificationService.class);
if (notificationService.isEmpty()) {
- LOG.error(RPC_SERVICE_FAILED, nodeId);
+ LOG.error("Failed to get NotificationService for node {}", nodeId);
return;
}
NodeRegistration nodeRegistration =
private void onDeviceDisConnected(final String nodeId) {
LOG.info("onDeviceDisConnected: {}", nodeId);
- this.registrations.remove(nodeId).unregisterListeners();
+ if (this.registrations.containsKey(nodeId)) {
+ this.registrations.remove(nodeId).unregisterListeners();
+ }
}
private boolean subscribeStream(MountPoint mountPoint, String nodeId) {
- final Optional<RpcConsumerRegistry> service = mountPoint.getService(RpcConsumerRegistry.class);
+ final Optional<RpcService> service = mountPoint.getService(RpcService.class);
if (service.isEmpty()) {
return false;
}
- final NotificationsService rpcService = service.orElseThrow().getRpcService(NotificationsService.class);
+ final CreateSubscription rpcService = service.orElseThrow().getRpc(CreateSubscription.class);
if (rpcService == null) {
- LOG.error(RPC_SERVICE_FAILED, nodeId);
+ LOG.error("Failed to get RpcService for node {}", nodeId);
return false;
}
// Set the default stream as OPENROADM
for (String streamName : getSupportedStream(nodeId)) {
LOG.info("Triggering notification stream {} for node {}", streamName, nodeId);
- ListenableFuture<RpcResult<CreateSubscriptionOutput>> subscription =
- rpcService.createSubscription(
+ ListenableFuture<RpcResult<CreateSubscriptionOutput>> subscription = rpcService.invoke(
new CreateSubscriptionInputBuilder().setStream(new StreamNameType(streamName)).build());
if (checkSupportedStream(streamName, subscription)) {
return true;