import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
import org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Timestamp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.BgpParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.bgp.parameters.OptionalCapabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.bgp.parameters.optional.capabilities.CParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev150512.peers.peer.PrePolicyRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev150512.peers.peer.Stats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev150512.routers.Router;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTree;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.QName;
private static final TablesKey DEFAULT_TABLE = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private static final InstanceIdentifier<SentOpen> SENT_OPEN_IID = InstanceIdentifier.builder(BmpMonitor.class)
+ private static final InstanceIdentifier<PeerSession> PEER_SESSION_ID = InstanceIdentifier.builder(BmpMonitor.class)
.child(Monitor.class)
.child(Router.class)
.child(Peer.class)
- .child(PeerSession.class)
- .child(SentOpen.class)
- .build();
- private static final InstanceIdentifier<ReceivedOpen> RECEIVED_OPEN_IID = InstanceIdentifier.builder(BmpMonitor.class)
- .child(Monitor.class)
- .child(Router.class)
- .child(Peer.class)
- .child(PeerSession.class)
- .child(ReceivedOpen.class)
- .build();
+ .child(PeerSession.class).build();
+
+ private static final InstanceIdentifier<SentOpen> SENT_OPEN_IID = PEER_SESSION_ID.child(SentOpen.class);
+
+ private static final InstanceIdentifier<ReceivedOpen> RECEIVED_OPEN_IID = PEER_SESSION_ID.child(ReceivedOpen.class);
private final DOMTransactionChain domTxChain;
private final PeerId peerId;
this.domTxChain = Preconditions.checkNotNull(domTxChain);
this.peerId = peerId;
this.peerYangIId = YangInstanceIdentifier.builder(peersYangIId).nodeWithKey(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue()).build();
+ this.sentOpenCodec = tree.getSubtreeCodec(SENT_OPEN_IID);
+ this.receivedOpenCodec = tree.getSubtreeCodec(RECEIVED_OPEN_IID);
final Set<TablesKey> peerTables = setPeerTables(peerUp.getReceivedOpen());
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
this.domTxChain, extensions, peerTables, tree);
this.postPolicyWriter = BmpRibInWriter.create(this.peerYangIId.node(PostPolicyRib.QNAME).node(BMP_TABLES_QNAME),
this.domTxChain, extensions, peerTables, tree);
- this.sentOpenCodec = tree.getSubtreeCodec(SENT_OPEN_IID);
- this.receivedOpenCodec = tree.getSubtreeCodec(RECEIVED_OPEN_IID);
}
public static BmpRouterPeer createRouterPeer(final DOMTransactionChain domTxChain,
if (this.up) {
final AdjRibInType ribType = routeMonitoring.getPeerHeader().getAdjRibInType();
switch (ribType) {
- case PrePolicy:
- this.prePolicyWriter.onMessage(routeMonitoring.getUpdate());
- break;
- case PostPolicy:
- this.postPolicyWriter.onMessage(routeMonitoring.getUpdate());
- break;
- default:
- break;
+ case PrePolicy:
+ this.prePolicyWriter.onMessage(routeMonitoring.getUpdate());
+ break;
+ case PostPolicy:
+ this.postPolicyWriter.onMessage(routeMonitoring.getUpdate());
+ break;
+ default:
+ break;
}
}
}
close();
}
- @Override
- public PeerId getPeerId() {
- return this.peerId;
- }
-
@Override
public void close() {
Preconditions.checkState(this.up, "Already closed.");
.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()));
+ .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 (this.receivedOpenCodec != null) {
- builder.withChild(Builders.containerBuilder(
- (ContainerNode) this.receivedOpenCodec.serialize(peerUp
- .getReceivedOpen())).build());
+ builder.withChild((ContainerNode) this.receivedOpenCodec.serialize(peerUp.getReceivedOpen()));
}
if (this.sentOpenCodec != null) {
- builder.withChild(Builders.containerBuilder(
- (ContainerNode) this.sentOpenCodec.serialize(peerUp
- .getSentOpen())).build());
+ builder.withChild((ContainerNode) this.sentOpenCodec.serialize(peerUp.getSentOpen()));
}
return builder.build();
}
.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());
+ .withChild(
+ Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME))
+ .withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
if (peerHeader.getDistinguisher() != null) {
mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, peerHeader.getDistinguisher().getDistinguisher()));
}
}
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, tlvs.getPerAfiSafiAdjRibInTlv().getCount().getValue()))
- .withNodeIdentifier(TablesUtil.toYangTablesKey(AF_QNAME, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))
- .build()).build()).build());
+ .withChild(ImmutableNodes.mapNodeBuilder(AF_QNAME)
+ .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.leafNode(COUNT_QNAME, tlvs.getPerAfiSafiAdjRibInTlv().getCount().getValue()))
+ .withNodeIdentifier(TablesUtil.toYangTablesKey(AF_QNAME, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))
+ .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(TablesUtil.toYangTablesKey(AF_QNAME, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))
- .build()).build()).build());
+ .withChild(ImmutableNodes.mapNodeBuilder(AF_QNAME)
+ .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.leafNode(COUNT_QNAME, tlvs.getPerAfiSafiLocRibTlv().getCount().getValue()))
+ .withNodeIdentifier(TablesUtil.toYangTablesKey(AF_QNAME, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))
+ .build()).build()).build());
}
if (tlvs.getUpdatesTreatedAsWithdrawTlv() != null) {
builder.withChild(ImmutableNodes.leafNode(STAT11_QNAME, tlvs.getUpdatesTreatedAsWithdrawTlv().getCount().getValue()));
private ContainerNode createMirrors(final Mirror mirror, final Timestamp timestamp) {
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder =
Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Mirrors.QNAME));
- builder.withChild(ImmutableNodes.leafNode(PEER_MIRROR_INFORMATION_QNAME, MirrorInformationCode.forValue(mirror.getTlvs().getMirrorInformationTlv().getCode().getIntValue())));
+ 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) {
+ switch (informationCode) {
+ case ErroredPdu:
+ return "errored-pdu";
+ case MessageLost:
+ return "message-lost";
+ default:
+ return null;
+ }
+ }
+
private static String getStringIpAddress(final IpAddress ipAddress) {
if (ipAddress.getIpv4Address() != null) {