+ AdjRibInWriter transform(final PeerId newPeerId, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final boolean isAppPeer) {
+ final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
+
+ final YangInstanceIdentifier newTablesRoot;
+ if (!newPeerId.equals(this.peerId)) {
+ if (this.peerId != null) {
+ // Wipe old peer data completely
+ tx.delete(LogicalDatastoreType.OPERATIONAL, this.ribPath.node(Peer.QNAME).node(new NodeIdentifierWithPredicates(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue())));
+ }
+
+ // Install new empty peer structure
+ final NodeIdentifierWithPredicates peerKey = IdentifierUtils.domPeerId(newPeerId);
+ final YangInstanceIdentifier newPeerPath = this.ribPath.node(Peer.QNAME).node(peerKey);
+
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> pb = Builders.mapEntryBuilder();
+ pb.withNodeIdentifier(peerKey);
+ pb.withChild(ImmutableNodes.leafNode(PEER_ID, newPeerId.getValue()));
+ pb.withChild(ImmutableNodes.leafNode(PEER_ROLE, this.role));
+ pb.withChild(EMPTY_ADJRIBIN);
+ pb.withChild(EMPTY_EFFRIBIN);
+ if (!isAppPeer) {
+ pb.withChild(EMPTY_ADJRIBOUT);
+ }
+
+ tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath, pb.build());
+ LOG.debug("New peer {} structure installed.", newPeerPath);