package org.opendaylight.protocol.bmp.impl.app;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.protocol.bmp.impl.app.TablesUtil.BMP_TABLES_QNAME;
import com.google.common.base.Preconditions;
private final BindingCodecTreeNode<ReceivedOpen> receivedOpenCodec;
private boolean up = true;
- private BmpRouterPeerImpl(final DOMTransactionChain domTxChain, final YangInstanceIdentifier peersYangIId, final PeerId peerId,
- final RIBExtensionConsumerContext extensions, final PeerUpNotification peerUp,
- final BindingCodecTree tree) {
- this.domTxChain = Preconditions.checkNotNull(domTxChain);
+ private BmpRouterPeerImpl(final DOMTransactionChain domTxChain, final YangInstanceIdentifier peersYangIId,
+ final PeerId peerId, final RIBExtensionConsumerContext extensions, final PeerUpNotification peerUp,
+ final BindingCodecTree tree) {
+ this.domTxChain = requireNonNull(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);
}
}
- private void onStatsReports(final StatsReportsMessage statsReports) {
+ private synchronized void onStatsReports(final StatsReportsMessage statsReports) {
if (this.up) {
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Stats.QNAME),
}
}
- private void onRouteMirror(final RouteMirroringMessage mirror) {
+ private synchronized void onRouteMirror(final RouteMirroringMessage mirror) {
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Mirrors.QNAME),
createMirrors(mirror, mirror.getPeerHeader().getTimestampSec()));
}
- private void onPeerDown() {
+ private synchronized void onPeerDown() {
final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.peerYangIId);
wTx.submit();
close();
}
- @Override
- public PeerId getPeerId() {
- return this.peerId;
- }
-
@Override
public void close() {
Preconditions.checkState(this.up, "Already closed.");
this.up = false;
}
- private Set<TablesKey> setPeerTables(final ReceivedOpen open) {
+ private static Set<TablesKey> setPeerTables(final ReceivedOpen open) {
final Set<TablesKey> tables = Sets.newHashSet(DEFAULT_TABLE);
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
return mapEntryBuilder.build();
}
- private ContainerNode createStats(final Stat stat, final Timestamp timestamp) {
+ private static ContainerNode createStats(final Stat stat, final Timestamp timestamp) {
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder =
Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME));
builder.withChild(ImmutableNodes.leafNode(PEER_STATS_TIMESTAMP_QNAME, timestamp.getValue()));
}
}
- private ContainerNode createMirrors(final Mirror mirror, final Timestamp timestamp) {
+ private static 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, toDom(MirrorInformationCode.forValue(