Remove references to ClusteredDataTreeChangeListener, as we are using
the correct method already. Also migrate other users of MD-SAL-deprecated
methods.
Change-Id: Ibf2b194550e50676776f61643eeb0e5069161a77
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import java.util.Set;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import java.util.Set;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataBroker.DataTreeChangeExtension;
import org.opendaylight.mdsal.dom.api.DOMDataBroker.DataTreeChangeExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
* For purposed of import policies such as Best Path Selection, application
* peer needs to have a BGP-ID that is configurable.
*/
* For purposed of import policies such as Best Path Selection, application
* peer needs to have a BGP-ID that is configurable.
*/
-public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTreeChangeListener {
+public class ApplicationPeer extends AbstractPeer implements DOMDataTreeChangeListener {
private static final Logger LOG = LoggerFactory.getLogger(ApplicationPeer.class);
private static final String APP_PEER_GROUP = "application-peers";
private static final Logger LOG = LoggerFactory.getLogger(ApplicationPeer.class);
private static final String APP_PEER_GROUP = "application-peers";
createDomChain();
adjRibInWriter = AdjRibInWriter.create(rib.getYangRibId(), PeerRole.Internal, this);
final RIBSupportContextRegistry context = rib.getRibSupportContext();
createDomChain();
adjRibInWriter = AdjRibInWriter.create(rib.getYangRibId(), PeerRole.Internal, this);
final RIBSupportContextRegistry context = rib.getRibSupportContext();
- final RegisterAppPeerListener registerAppPeerListener = () -> {
- synchronized (this) {
- if (getDomChain() != null) {
- registration = dataTreeChangeService.registerTreeChangeListener(appPeerDOMId, this);
- }
- }
- };
peerPath = createPeerPath(peerId);
peerPath = createPeerPath(peerId);
- adjRibInWriter = adjRibInWriter.transform(peerId, peerPath, context, localTables,
- Map.of(), registerAppPeerListener);
+ adjRibInWriter = adjRibInWriter.transform(peerId, peerPath, context, localTables, Map.of(),
+ () -> {
+ synchronized (this) {
+ if (getDomChain() != null) {
+ registration = dataTreeChangeService.registerTreeChangeListener(appPeerDOMId, this);
+ }
+ }
+ });
final var chain = rib.createPeerDOMChain();
chain.addCallback(this);
final var chain = rib.createPeerDOMChain();
chain.addCallback(this);
}
synchronized void onGlobalChanged(final DataObjectModification<Global> dataObjectModification) {
}
synchronized void onGlobalChanged(final DataObjectModification<Global> dataObjectModification) {
- switch (dataObjectModification.getModificationType()) {
+ switch (dataObjectModification.modificationType()) {
case DELETE:
LOG.debug("Removing RIB instance: {}", bgpIid);
if (ribImpl != null) {
case DELETE:
LOG.debug("Removing RIB instance: {}", bgpIid);
if (ribImpl != null) {
break;
case SUBTREE_MODIFIED:
case WRITE:
break;
case SUBTREE_MODIFIED:
case WRITE:
- final Global global = dataObjectModification.getDataAfter();
+ final Global global = dataObjectModification.dataAfter();
if (ribImpl == null) {
onGlobalCreated(global);
} else if (!ribImpl.isGlobalEqual(requireNonNull(global))) {
if (ribImpl == null) {
onGlobalCreated(global);
} else if (!ribImpl.isGlobalEqual(requireNonNull(global))) {
@VisibleForTesting
@Holding("this")
void onNeighborsChanged(final DataObjectModification<Neighbors> dataObjectModification) {
@VisibleForTesting
@Holding("this")
void onNeighborsChanged(final DataObjectModification<Neighbors> dataObjectModification) {
- for (final DataObjectModification<?> neighborModification : dataObjectModification.getModifiedChildren()) {
- switch (neighborModification.getModificationType()) {
+ for (var neighborModification : dataObjectModification.modifiedChildren()) {
+ switch (neighborModification.modificationType()) {
- onNeighborRemoved((Neighbor) neighborModification.getDataBefore());
+ onNeighborRemoved((Neighbor) neighborModification.dataBefore());
break;
case SUBTREE_MODIFIED:
case WRITE:
break;
case SUBTREE_MODIFIED:
case WRITE:
- onNeighborModified((Neighbor) neighborModification.getDataAfter());
+ onNeighborModified((Neighbor) neighborModification.dataAfter());
import javax.inject.Inject;
import javax.inject.Singleton;
import org.checkerframework.checker.lock.qual.GuardedBy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
+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.ReadTransaction;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
@Singleton
// Non-final because of Mockito.spy()
@Singleton
// Non-final because of Mockito.spy()
-public class DefaultBgpDeployer implements ClusteredDataTreeChangeListener<Bgp>, PeerGroupConfigLoader, AutoCloseable {
+public class DefaultBgpDeployer implements DataTreeChangeListener<Bgp>, PeerGroupConfigLoader, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DefaultBgpDeployer.class);
private final InstanceIdentifier<NetworkInstance> networkInstanceIId;
private static final Logger LOG = LoggerFactory.getLogger(DefaultBgpDeployer.class);
private final InstanceIdentifier<NetworkInstance> networkInstanceIId;
@PostConstruct
// Split out of constructor to support partial mocking
public synchronized void init() {
@PostConstruct
// Split out of constructor to support partial mocking
public synchronized void init() {
- registration = dataBroker.registerDataTreeChangeListener(
+ registration = dataBroker.registerTreeChangeListener(
DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
networkInstanceIId.child(Protocols.class).child(Protocol.class)
.augmentation(NetworkInstanceProtocol.class).child(Bgp.class)), this);
DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
networkInstanceIId.child(Protocols.class).child(Protocol.class)
.augmentation(NetworkInstanceProtocol.class).child(Bgp.class)), this);
- for (final DataTreeModification<Bgp> dataTreeModification : changes) {
- final InstanceIdentifier<Bgp> rootIdentifier = dataTreeModification.getRootPath().getRootIdentifier();
+ for (var dataTreeModification : changes) {
+ final InstanceIdentifier<Bgp> rootIdentifier = dataTreeModification.getRootPath().path();
final DataObjectModification<Bgp> rootNode = dataTreeModification.getRootNode();
final DataObjectModification<Bgp> rootNode = dataTreeModification.getRootNode();
- final List<DataObjectModification<? extends DataObject>> deletedConfig
- = rootNode.getModifiedChildren().stream()
- .filter(mod -> mod.getModificationType() == DataObjectModification.ModificationType.DELETE)
- .collect(Collectors.toList());
- final List<DataObjectModification<? extends DataObject>> changedConfig
- = rootNode.getModifiedChildren().stream()
- .filter(mod -> mod.getModificationType() != DataObjectModification.ModificationType.DELETE)
- .collect(Collectors.toList());
+ final List<DataObjectModification<? extends DataObject>> deletedConfig = rootNode.modifiedChildren()
+ .stream()
+ .filter(mod -> mod.modificationType() == DataObjectModification.ModificationType.DELETE)
+ .collect(Collectors.toList());
+ final List<DataObjectModification<? extends DataObject>> changedConfig = rootNode.modifiedChildren()
+ .stream()
+ .filter(mod -> mod.modificationType() != DataObjectModification.ModificationType.DELETE)
+ .collect(Collectors.toList());
handleDeletions(deletedConfig, rootIdentifier);
handleModifications(changedConfig, rootIdentifier);
}
handleDeletions(deletedConfig, rootIdentifier);
handleModifications(changedConfig, rootIdentifier);
}
private void handleModifications(final List<DataObjectModification<? extends DataObject>> changedConfig,
final InstanceIdentifier<Bgp> rootIdentifier) {
final List<DataObjectModification<? extends DataObject>> globalMod = changedConfig.stream()
private void handleModifications(final List<DataObjectModification<? extends DataObject>> changedConfig,
final InstanceIdentifier<Bgp> rootIdentifier) {
final List<DataObjectModification<? extends DataObject>> globalMod = changedConfig.stream()
- .filter(mod -> mod.getDataType().equals(Global.class))
+ .filter(mod -> mod.dataType().equals(Global.class))
.collect(Collectors.toList());
final List<DataObjectModification<? extends DataObject>> peerMod = changedConfig.stream()
.collect(Collectors.toList());
final List<DataObjectModification<? extends DataObject>> peerMod = changedConfig.stream()
- .filter(mod -> !mod.getDataType().equals(Global.class))
+ .filter(mod -> !mod.dataType().equals(Global.class))
.collect(Collectors.toList());
if (!globalMod.isEmpty()) {
handleGlobalChange(globalMod, rootIdentifier);
.collect(Collectors.toList());
if (!globalMod.isEmpty()) {
handleGlobalChange(globalMod, rootIdentifier);
private void handleDeletions(final List<DataObjectModification<? extends DataObject>> deletedConfig,
final InstanceIdentifier<Bgp> rootIdentifier) {
final List<DataObjectModification<? extends DataObject>> globalMod = deletedConfig.stream()
private void handleDeletions(final List<DataObjectModification<? extends DataObject>> deletedConfig,
final InstanceIdentifier<Bgp> rootIdentifier) {
final List<DataObjectModification<? extends DataObject>> globalMod = deletedConfig.stream()
- .filter(mod -> mod.getDataType().equals(Global.class))
+ .filter(mod -> mod.dataType().equals(Global.class))
.collect(Collectors.toList());
final List<DataObjectModification<? extends DataObject>> peerMod = deletedConfig.stream()
.collect(Collectors.toList());
final List<DataObjectModification<? extends DataObject>> peerMod = deletedConfig.stream()
- .filter(mod -> !mod.getDataType().equals(Global.class))
+ .filter(mod -> !mod.dataType().equals(Global.class))
.collect(Collectors.toList());
if (!globalMod.isEmpty()) {
handleGlobalChange(globalMod, rootIdentifier);
.collect(Collectors.toList());
if (!globalMod.isEmpty()) {
handleGlobalChange(globalMod, rootIdentifier);
final List<DataObjectModification<? extends DataObject>> config,
final InstanceIdentifier<Bgp> rootIdentifier) {
for (final DataObjectModification<? extends DataObject> dataObjectModification : config) {
final List<DataObjectModification<? extends DataObject>> config,
final InstanceIdentifier<Bgp> rootIdentifier) {
for (final DataObjectModification<? extends DataObject> dataObjectModification : config) {
- if (dataObjectModification.getDataType().equals(Neighbors.class)) {
+ if (dataObjectModification.dataType().equals(Neighbors.class)) {
onNeighborsChanged((DataObjectModification<Neighbors>) dataObjectModification, rootIdentifier);
onNeighborsChanged((DataObjectModification<Neighbors>) dataObjectModification, rootIdentifier);
- } else if (dataObjectModification.getDataType().equals(PeerGroups.class)) {
+ } else if (dataObjectModification.dataType().equals(PeerGroups.class)) {
rebootNeighbors((DataObjectModification<PeerGroups>) dataObjectModification);
}
}
}
private synchronized void rebootNeighbors(final DataObjectModification<PeerGroups> dataObjectModification) {
rebootNeighbors((DataObjectModification<PeerGroups>) dataObjectModification);
}
}
}
private synchronized void rebootNeighbors(final DataObjectModification<PeerGroups> dataObjectModification) {
- PeerGroups extPeerGroups = dataObjectModification.getDataAfter();
+ PeerGroups extPeerGroups = dataObjectModification.dataAfter();
if (extPeerGroups == null) {
if (extPeerGroups == null) {
- extPeerGroups = dataObjectModification.getDataBefore();
+ extPeerGroups = dataObjectModification.dataBefore();
}
if (extPeerGroups == null) {
return;
}
if (extPeerGroups == null) {
return;