import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.RpcService;
*/
@Singleton
@Component(service = { })
-public final class SampleFlowCapableNodeListener
- implements ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
+public final class SampleFlowCapableNodeListener implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SampleFlowCapableNodeListener.class);
private static final BundleId BUNDLE_ID = new BundleId(Uint32.ONE);
final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
.augmentation(FlowCapableNode.class);
final DataTreeIdentifier<FlowCapableNode> identifier =
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, path);
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, path);
- listenerReg = dataBroker.registerDataTreeChangeListener(identifier, SampleFlowCapableNodeListener.this);
+ listenerReg = dataBroker.registerTreeChangeListener(identifier, SampleFlowCapableNodeListener.this);
}
@PreDestroy
@Override
public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
for (var modification : modifications) {
- if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
- LOG.info("Node connected: {}",
- modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
+ if (modification.getRootNode().modificationType() == ModificationType.WRITE) {
+ final var nodePath = modification.getRootPath().path().firstIdentifierOf(Node.class);
+ LOG.info("Node connected: {}", nodePath);
- final var nodeRef =
- new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
+ final var nodeRef = new NodeRef(nodePath);
final var openBundleInput = new ControlBundleInputBuilder()
.setNode(nodeRef)