import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
+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.protocol.bgp.rib.impl.spi.Codecs;
import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.NlriBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* Instantiated for each peer and table, listens on a particular peer's adj-rib-out, performs transcoding to BA form
* (message) and sends it down the channel. This class is NOT thread-safe.
*/
-final class AdjRibOutListener implements ClusteredDOMDataTreeChangeListener, PrefixesSentCounters {
+final class AdjRibOutListener implements DOMDataTreeChangeListener, PrefixesSentCounters {
private static final Logger LOG = LoggerFactory.getLogger(AdjRibOutListener.class);
private static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
private static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
private final RIBSupport<?, ?> support;
// FIXME: this field needs to be eliminated: either subclass this class or create a filtering ribsupport
private final boolean mpSupport;
- private final ListenerRegistration<AdjRibOutListener> registerDataTreeChangeListener;
+ private final Registration registerDataTreeChangeListener;
private final LongAdder prefixesSentCounter = new LongAdder();
private boolean initalState;
private AdjRibOutListener(final PeerId peerId, final YangInstanceIdentifier ribId, final CodecsRegistry registry,
- final RIBSupport<?, ?> support, final DOMDataTreeChangeService service, final ChannelOutputLimiter session,
+ final RIBSupport<?, ?> support, final DataTreeChangeExtension service, final ChannelOutputLimiter session,
final boolean mpSupport) {
this.session = requireNonNull(session);
this.support = requireNonNull(support);
* send EOR marker. initialState flag is distinguishing between first ODTC execution and the rest.
*/
initalState = true;
- registerDataTreeChangeListener = service.registerDataTreeChangeListener(
- new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, adjRibOutId), this);
+ registerDataTreeChangeListener = service.registerTreeChangeListener(
+ DOMDataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, adjRibOutId), this);
}
static AdjRibOutListener create(
final @NonNull YangInstanceIdentifier ribId,
final @NonNull CodecsRegistry registry,
final @NonNull RIBSupport<?, ?> support,
- final @NonNull DOMDataTreeChangeService service,
+ final @NonNull DataTreeChangeExtension service,
final @NonNull ChannelOutputLimiter session,
final boolean mpSupport) {
return new AdjRibOutListener(peerId, ribId, registry, support, service, session, mpSupport);
public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
LOG.debug("Data change received for AdjRibOut {}", changes);
for (var tc : changes) {
- LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
- for (var child : tc.getRootNode().getChildNodes()) {
+ LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().modificationType());
+ for (var child : tc.getRootNode().childNodes()) {
for (var route : support.changedRoutes(child)) {
processRouteChange(route);
}
private void processRouteChange(final DataTreeCandidateNode route) {
final Update update;
- switch (route.getModificationType()) {
+ switch (route.modificationType()) {
case UNMODIFIED:
- LOG.debug("Skipping unmodified route {}", route.getIdentifier());
+ LOG.debug("Skipping unmodified route {}", route.name());
return;
case DELETE:
case DISAPPEARED:
// FIXME: we can batch deletions into a single batch
- update = withdraw((MapEntryNode) route.getDataBefore().orElseThrow());
+ update = withdraw((MapEntryNode) route.getDataBefore());
LOG.debug("Withdrawing routes {}", update);
break;
case APPEARED:
case SUBTREE_MODIFIED:
case WRITE:
- update = advertise((MapEntryNode) route.getDataAfter().orElseThrow());
+ update = advertise((MapEntryNode) route.getDataAfter());
LOG.debug("Advertising routes {}", update);
break;
default:
- LOG.warn("Ignoring unhandled modification type {}", route.getModificationType());
+ LOG.warn("Ignoring unhandled modification type {}", route.modificationType());
return;
}
session.write(update);