</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
+ <artifactId>yang-data-spi</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private synchronized void createEmptyMonitor() {
final DOMDataTreeWriteTransaction wTx = domDataBroker.newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL,
- YangInstanceIdentifier.builder().node(BmpMonitor.QNAME).node(Monitor.QNAME)
- .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, monitorId.getValue()).build(),
- ImmutableNodes.mapEntryBuilder(Monitor.QNAME, MONITOR_ID_QNAME, monitorId.getValue())
- .addChild(ImmutableNodes.leafNode(MONITOR_ID_QNAME, monitorId.getValue()))
- .addChild(ImmutableNodes.mapNodeBuilder(Router.QNAME).build())
- .build());
+ YangInstanceIdentifier.builder().node(BmpMonitor.QNAME).node(Monitor.QNAME)
+ .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, monitorId.getValue()).build(),
+ ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Monitor.QNAME, MONITOR_ID_QNAME,
+ monitorId.getValue()))
+ .withChild(ImmutableNodes.leafNode(MONITOR_ID_QNAME, monitorId.getValue()))
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Router.QNAME))
+ .build())
+ .build());
try {
wTx.commit().get();
} catch (final ExecutionException | InterruptedException e) {
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private synchronized void createRouterEntry() {
Preconditions.checkState(isDatastoreWritable());
final DOMDataTreeWriteTransaction wTx = domTxChain.newWriteOnlyTransaction();
- wTx.put(LogicalDatastoreType.OPERATIONAL, routerYangIId,
- Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Router.QNAME, ROUTER_ID_QNAME, routerIp))
- .withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, routerIp))
- .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN))
- .withChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).build());
+ wTx.put(LogicalDatastoreType.OPERATIONAL, routerYangIId, ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Router.QNAME, ROUTER_ID_QNAME, routerIp))
+ .withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, routerIp))
+ .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN))
+ .withChild(ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(Peer.QNAME)).build())
+ .build());
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
private synchronized void onInitiate(final InitiationMessage initiation) {
Preconditions.checkState(isDatastoreWritable());
final DOMDataTreeWriteTransaction wTx = domTxChain.newWriteOnlyTransaction();
- wTx.merge(LogicalDatastoreType.OPERATIONAL, routerYangIId,
- Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Router.QNAME, ROUTER_ID_QNAME, routerIp))
- .withChild(ImmutableNodes.leafNode(ROUTER_NAME_QNAME, initiation.getTlvs().getNameTlv().getName()))
- .withChild(ImmutableNodes.leafNode(ROUTER_DESCRIPTION_QNAME, initiation.getTlvs().getDescriptionTlv()
- .getDescription()))
- .withChild(ImmutableNodes.leafNode(ROUTER_INFO_QNAME, getStringInfo(initiation.getTlvs()
- .getStringInformation())))
- .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, UP)).build());
+ wTx.merge(LogicalDatastoreType.OPERATIONAL, routerYangIId, ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Router.QNAME, ROUTER_ID_QNAME, routerIp))
+ .withChild(ImmutableNodes.leafNode(ROUTER_NAME_QNAME, initiation.getTlvs().getNameTlv().getName()))
+ .withChild(ImmutableNodes.leafNode(ROUTER_DESCRIPTION_QNAME,
+ initiation.getTlvs().getDescriptionTlv().getDescription()))
+ .withChild(ImmutableNodes.leafNode(ROUTER_INFO_QNAME,
+ getStringInfo(initiation.getTlvs().getStringInformation())))
+ .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, UP))
+ .build());
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Locale;
import java.util.Set;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.AdjRibInType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Mirror;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.MirrorInformationCode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Peer.PeerDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerUp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.RouteMonitoringMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Stat;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.StatsReportsMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.header.PeerHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.up.ReceivedOpen;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.up.SentOpen;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.stat.Tlvs;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void onPeerMessage(final Notification<?> message) {
if (message instanceof PeerDownNotification) {
onPeerDown();
- } else if (message instanceof RouteMonitoringMessage) {
- onRouteMonitoring((RouteMonitoringMessage) message);
- } else if (message instanceof StatsReportsMessage) {
- onStatsReports((StatsReportsMessage) message);
- } else if (message instanceof RouteMirroringMessage) {
- onRouteMirror((RouteMirroringMessage) message);
+ } else if (message instanceof RouteMonitoringMessage routeMonitoring) {
+ onRouteMonitoring(routeMonitoring);
+ } else if (message instanceof StatsReportsMessage statsReports) {
+ onStatsReports(statsReports);
+ } else if (message instanceof RouteMirroringMessage routeMirroring) {
+ onRouteMirror(routeMirroring);
}
}
}
private ContainerNode createPeerSessionUp(final PeerUp peerUp, final Timestamp timestamp) {
- final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(PeerSession.QNAME))
- .withChild(ImmutableNodes.leafNode(PEER_LOCAL_ADDRESS_QNAME,
- getStringIpAddress(peerUp.getLocalAddress())))
- .withChild(ImmutableNodes.leafNode(PEER_LOCAL_PORT_QNAME, peerUp
- .getLocalPort().getValue()))
- .withChild(ImmutableNodes.leafNode(PEER_REMOTE_PORT_QNAME, peerUp
- .getRemotePort().getValue()))
- .withChild(ImmutableNodes.leafNode(PEER_STATUS_QNAME, "up"))
- .withChild(ImmutableNodes.leafNode(PEER_UP_TIMESTAMP_QNAME,
- timestamp.getValue()));
+ final var builder = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(PeerSession.QNAME))
+ .withChild(ImmutableNodes.leafNode(PEER_LOCAL_ADDRESS_QNAME, getStringIpAddress(peerUp.getLocalAddress())))
+ .withChild(ImmutableNodes.leafNode(PEER_LOCAL_PORT_QNAME, peerUp.getLocalPort().getValue()))
+ .withChild(ImmutableNodes.leafNode(PEER_REMOTE_PORT_QNAME, peerUp.getRemotePort().getValue()))
+ .withChild(ImmutableNodes.leafNode(PEER_STATUS_QNAME, "up"))
+ .withChild(ImmutableNodes.leafNode(PEER_UP_TIMESTAMP_QNAME, timestamp.getValue()));
if (receivedOpenCodec != null) {
builder.withChild((ContainerNode) receivedOpenCodec.serialize(peerUp.getReceivedOpen()));
}
}
private MapEntryNode createPeerEntry(final PeerUpNotification peerUp) {
- final PeerHeader peerHeader = peerUp.getPeerHeader();
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder =
- Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(Peer.QNAME, PEER_ID_QNAME,
- peerId.getValue()))
- .withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, peerId.getValue()))
- .withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME,
- peerHeader.getType().name().toLowerCase(Locale.ENGLISH)))
- .withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME,
- getStringIpAddress(peerHeader.getAddress())))
- .withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue()))
- .withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue()))
- .withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec()))
- .withChild(
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME))
- .withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build())
- .withChild(
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME))
- .withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
+ final var peerHeader = peerUp.getPeerHeader();
+ final var mapEntryBuilder = ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Peer.QNAME, PEER_ID_QNAME, peerId.getValue()))
+ .withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, peerId.getValue()))
+ .withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME, peerHeader.getType().getName()))
+ .withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME,
+ getStringIpAddress(peerHeader.getAddress())))
+ .withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue()))
+ .withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue()))
+ .withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec()))
+ .withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME))
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(BMP_TABLES_QNAME))
+ .build())
+ .build())
+ .withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME))
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(BMP_TABLES_QNAME))
+ .build())
+ .build());
final PeerDistinguisher pd = peerHeader.getPeerDistinguisher();
if (pd != null) {
mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, pd.getRouteDistinguisher()));
}
private static ContainerNode createStats(final Stat stat, final Timestamp timestamp) {
- final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder =
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME));
+ final var builder = ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME));
builder.withChild(ImmutableNodes.leafNode(PEER_STATS_TIMESTAMP_QNAME, timestamp.getValue()));
final Tlvs tlvs = stat.getTlvs();
if (tlvs != null) {
tlvs.getInvalidatedAsConfedLoopTlv().getCount().getValue()));
}
if (tlvs.getAdjRibsInRoutesTlv() != null) {
- builder.withChild(ImmutableNodes.leafNode(STAT7_QNAME,
- tlvs.getAdjRibsInRoutesTlv().getCount().getValue()));
+ builder.withChild(ImmutableNodes.leafNode(STAT7_QNAME, tlvs.getAdjRibsInRoutesTlv().getCount().getValue()));
}
if (tlvs.getLocRibRoutesTlv() != null) {
- builder.withChild(ImmutableNodes.leafNode(STAT8_QNAME,
- tlvs.getLocRibRoutesTlv().getCount().getValue()));
+ builder.withChild(ImmutableNodes.leafNode(STAT8_QNAME, tlvs.getLocRibRoutesTlv().getCount().getValue()));
}
if (tlvs.getPerAfiSafiAdjRibInTlv() != null) {
- builder.withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(STAT9_QNAME))
- .withChild(ImmutableNodes.mapNodeBuilder(AF_QNAME).withChild(Builders.mapEntryBuilder()
- .withChild(ImmutableNodes.leafNode(COUNT_QNAME,
+ builder.withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(STAT9_QNAME))
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(AF_QNAME))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withChild(ImmutableNodes.leafNode(COUNT_QNAME,
tlvs.getPerAfiSafiAdjRibInTlv().getCount().getValue()))
- .withNodeIdentifier(AFI_ITEM)
- .build()).build()).build());
+ .withNodeIdentifier(AFI_ITEM)
+ .build())
+ .build())
+ .build());
}
if (tlvs.getPerAfiSafiLocRibTlv() != null) {
- builder.withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(STAT10_QNAME))
- .withChild(ImmutableNodes.mapNodeBuilder(AF_QNAME)
- .withChild(Builders.mapEntryBuilder()
- .withChild(ImmutableNodes.leafNode(COUNT_QNAME,
- tlvs.getPerAfiSafiLocRibTlv().getCount().getValue()))
- .withNodeIdentifier(AFI_ITEM)
- .build()).build()).build());
+ builder.withChild(ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(STAT10_QNAME))
+ .withChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(AF_QNAME))
+ .withChild(ImmutableNodes.newMapEntryBuilder()
+ .withChild(ImmutableNodes.leafNode(COUNT_QNAME,
+ tlvs.getPerAfiSafiLocRibTlv().getCount().getValue()))
+ .withNodeIdentifier(AFI_ITEM)
+ .build())
+ .build())
+ .build());
}
if (tlvs.getUpdatesTreatedAsWithdrawTlv() != null) {
builder.withChild(ImmutableNodes.leafNode(STAT11_QNAME,
}
private static ContainerNode createMirrors(final Mirror mirror, final Timestamp timestamp) {
- final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder =
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Mirrors.QNAME));
- builder.withChild(ImmutableNodes.leafNode(PEER_MIRROR_INFORMATION_QNAME, toDom(MirrorInformationCode.forValue(
- mirror.getTlvs().getMirrorInformationTlv().getCode().getIntValue()))));
- builder.withChild(ImmutableNodes.leafNode(PEER_MIRROR_TIMESTAMP_QNAME, timestamp.getValue()));
- return builder.build();
- }
-
- private static String toDom(final MirrorInformationCode informationCode) {
- return switch (informationCode) {
- case ErroredPdu -> "errored-pdu";
- case MessageLost -> "message-lost";
- default -> null;
- };
+ return ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Mirrors.QNAME))
+ .withChild(ImmutableNodes.leafNode(PEER_MIRROR_INFORMATION_QNAME,
+ mirror.getTlvs().getMirrorInformationTlv().getCode().getName()))
+ .withChild(ImmutableNodes.leafNode(PEER_MIRROR_TIMESTAMP_QNAME, timestamp.getValue()))
+ .build();
}
private static String getStringIpAddress(final IpAddressNoZone ipAddress) {
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
// This class is NOT thread-safe
final class TableContext {
- private static final ContainerNode EMPTY_TABLE_ATTRIBUTES = ImmutableNodes.containerNode(BMP_ATTRIBUTES_QNAME);
+ private static final ContainerNode EMPTY_TABLE_ATTRIBUTES = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(BMP_ATTRIBUTES_QNAME))
+ .build();
private static final NodeIdentifier BGP_ROUTES_NODE_ID = new NodeIdentifier(BMP_ROUTES_QNAME);
private final YangInstanceIdentifier tableId;
- private final RIBSupport tableSupport;
+ private final RIBSupport<?, ?> tableSupport;
private final BindingNormalizedNodeCachingCodec<Attributes> attributesCodec;
private final BindingNormalizedNodeCachingCodec<MpReachNlri> reachNlriCodec;
private final BindingNormalizedNodeCachingCodec<MpUnreachNlri> unreachNlriCodec;
}
void createTable(final DOMDataTreeWriteTransaction tx) {
- final var tb = ImmutableNodes.mapEntryBuilder()
+ final var tb = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier((NodeIdentifierWithPredicates) tableId.getLastPathArgument())
.withChild(EMPTY_TABLE_ATTRIBUTES);
}
tx.put(LogicalDatastoreType.OPERATIONAL, tableId,
- tb.withChild(Builders.choiceBuilder()
- .withNodeIdentifier(new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME))
- .build())
- .build());
+ tb.withChild(ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME))
+ .build())
+ .build());
}
void writeRoutes(final DOMDataTreeWriteTransaction tx, final MpReachNlri nlri, final Attributes attributes) {
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.net.InetSocketAddress;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.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.dom.codec.api.BindingCodecTree;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
import org.opendaylight.protocol.bmp.api.BmpDispatcher;
import org.opendaylight.protocol.bmp.impl.app.BmpMonitoringStationImpl;
-import org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation;
import org.opendaylight.protocol.util.Ipv4Util;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.OdlBmpMonitors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.odl.bmp.monitors.BmpMonitorConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.bmp.monitor.Monitor;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
@Singleton
@Component(service = {})
-public final class BmpDeployerImpl implements ClusteredDataTreeChangeListener<OdlBmpMonitors>, AutoCloseable {
+public final class BmpDeployerImpl implements DataTreeChangeListener<OdlBmpMonitors>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(BmpDeployerImpl.class);
private static final long TIMEOUT_NS = TimeUnit.SECONDS.toNanos(5);
private static final InstanceIdentifier<OdlBmpMonitors> ODL_BMP_MONITORS_IID =
InstanceIdentifier.create(OdlBmpMonitors.class);
private static final YangInstanceIdentifier BMP_MONITOR_YII = YangInstanceIdentifier.of(BmpMonitor.QNAME);
- private static final ContainerNode EMPTY_PARENT_NODE = Builders.containerBuilder()
+ private static final ContainerNode EMPTY_PARENT_NODE = ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build())
+ .addChild(ImmutableNodes.newSystemMapBuilder().withNodeIdentifier(new NodeIdentifier(Monitor.QNAME)).build())
.build();
private final BmpDispatcher dispatcher;
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
- registration = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, ODL_BMP_MONITORS_IID), this);
+ registration = dataBroker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, ODL_BMP_MONITORS_IID), this);
}
@Override
public synchronized void onDataTreeChanged(final List<DataTreeModification<OdlBmpMonitors>> changes) {
- final DataTreeModification<OdlBmpMonitors> dataTreeModification = Iterables.getOnlyElement(changes);
- final Collection<? extends DataObjectModification<? extends DataObject>> rootNode =
- dataTreeModification.getRootNode().getModifiedChildren();
+ // FIXME: what about multiple events?!
+ final var dataTreeModification = Iterables.getOnlyElement(changes);
+ final var rootNode = dataTreeModification.getRootNode().modifiedChildren();
if (rootNode.isEmpty()) {
return;
}
}
private synchronized void handleModification(final DataObjectModification<BmpMonitorConfig> config) {
- final ModificationType modificationType = config.getModificationType();
+ final var modificationType = config.modificationType();
LOG.trace("Bmp Monitor configuration has changed: {}, type modification {}", config, modificationType);
switch (modificationType) {
case DELETE:
- removeBmpMonitor(config.getDataBefore().getMonitorId());
+ removeBmpMonitor(config.dataBefore().getMonitorId());
break;
case SUBTREE_MODIFIED:
case WRITE:
- updateBmpMonitor(config.getDataAfter());
+ updateBmpMonitor(config.dataAfter());
break;
default:
break;
@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void removeBmpMonitor(final MonitorId monitorId) {
- final BmpMonitoringStation service = bmpMonitorServices.remove(monitorId);
+ final var service = bmpMonitorServices.remove(monitorId);
if (service != null) {
LOG.debug("Closing Bmp Monitor {}.", monitorId);
try {
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class BmpMonitorImplTest extends AbstractConcurrentDataBrokerTest {
private static final String REMOTE_ROUTER_ADDRESS_2 = "127.0.0.13";
private static final Ipv4AddressNoZone PEER1 = new Ipv4AddressNoZone("20.20.20.20");
private static final MonitorId MONITOR_ID = new MonitorId("monitor");
- private static final KeyedInstanceIdentifier<Monitor, MonitorKey> MONITOR_IID = InstanceIdentifier
- .create(BmpMonitor.class).child(Monitor.class, new MonitorKey(MONITOR_ID));
+ private static final KeyedInstanceIdentifier<Monitor, MonitorKey> MONITOR_IID =
+ InstanceIdentifier.create(BmpMonitor.class).child(Monitor.class, new MonitorKey(MONITOR_ID));
private static final PeerId PEER_ID = new PeerId(PEER1.getValue());
private static final InstanceIdentifier<BmpMonitor> BMP_II = InstanceIdentifier.create(BmpMonitor.class);
private AdapterContext mappingService;
MONITOR_LOCAL_PORT);
final DOMDataTreeWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
- final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(BmpMonitor.QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
+ final ContainerNode parentNode = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME))
+ .addChild(ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(Monitor.QNAME))
+ .build())
+ .build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
wTx.commit().get();
@Test
public void deploySecondInstance() throws Exception {
- final BmpMonitoringStation monitoringStation2 = new BmpMonitoringStationImpl(getDomBroker(), dispatcher,
+ try (var monitoringStation2 = new BmpMonitoringStationImpl(getDomBroker(), dispatcher,
ribExtension, mappingService.currentSerializer(), clusterSSProv2, new MonitorId("monitor2"),
- new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), null);
+ new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), null)) {
- readDataOperational(getDataBroker(), BMP_II, monitor -> {
- assertEquals(2, monitor.nonnullMonitor().size());
- return monitor;
- });
-
- monitoringStation2.close();
+ readDataOperational(getDataBroker(), BMP_II, monitor -> {
+ assertEquals(2, monitor.nonnullMonitor().size());
+ return monitor;
+ });
+ }
}
private static Channel connectTestClient(final String routerIp, final BmpMessageRegistry msgRegistry)