+ private void initializeTableWithExistentRoutes(final DataTreeCandidateNode table, final PeerId peerIdOfNewPeer, final YangInstanceIdentifier rootPath,
+ final DOMDataWriteTransaction tx) {
+ if (!table.getDataBefore().isPresent() && this.peerPolicyTracker.isTableSupported(peerIdOfNewPeer)) {
+ LOG.debug("Peer {} table has been created, inserting existent routes", peerIdOfNewPeer);
+ final PeerRole newPeerRole = this.peerPolicyTracker.getRole(IdentifierUtils.peerPath(rootPath));
+ final PeerExportGroup peerGroup = this.peerPolicyTracker.getPeerGroup(newPeerRole);
+ this.routeEntries.entrySet().forEach(entry -> entry.getValue().writeRoute(peerIdOfNewPeer, entry.getKey(), rootPath, peerGroup,
+ this.localTablesKey, this.peerPolicyTracker, this.ribSupport, this.cacheDisconnectedPeers, tx));
+ }
+ }
+
+ private void filterOutPeerRole(final PeerId peerId, final DataTreeCandidateNode rootNode, final YangInstanceIdentifier rootPath) {
+ final DataTreeCandidateNode roleChange = rootNode.getModifiedChild(PEER_ROLE_NID);
+ if (roleChange != null) {
+ if (rootNode.getModificationType() != ModificationType.DELETE) {
+ this.cacheDisconnectedPeers.reconnected(peerId);
+ }
+
+ // Check for removal
+ final Optional<NormalizedNode<?, ?>> maybePeerRole = roleChange.getDataAfter();
+ final YangInstanceIdentifier peerPath = IdentifierUtils.peerPath(rootPath);
+ LOG.debug("Data Changed for Peer role {} path {}, dataBefore {}, dataAfter {}", roleChange.getIdentifier(),
+ peerPath , roleChange.getDataBefore(), maybePeerRole);
+ final PeerRole role = PeerRoleUtil.roleForChange(maybePeerRole);
+ SimpleRoutingPolicy srp = getSimpleRoutingPolicy(rootNode);
+ if(PeerRole.Internal == role || SimpleRoutingPolicy.AnnounceNone == srp) {
+ return;
+ }
+ this.peerPolicyTracker.peerRoleChanged(peerPath, role);
+ }
+ }
+
+ private SimpleRoutingPolicy getSimpleRoutingPolicy(final DataTreeCandidateNode rootNode) {
+ final DataTreeCandidateNode statusChange = rootNode.getModifiedChild(SIMPLE_ROUTING_POLICY_NID);
+ if (statusChange != null) {
+ final Optional<NormalizedNode<?, ?>> maybePeerStatus = statusChange.getDataAfter();
+ if (maybePeerStatus.isPresent()) {
+ return SimpleRoutingPolicy.valueOf(BindingMapping.getClassName((String) (maybePeerStatus.get()).getValue()));
+ }
+ }
+ return null;
+ }
+
+ private void updateNodes(final DataTreeCandidateNode table, final PeerId peerId, final DOMDataWriteTransaction tx,
+ final Map<RouteUpdateKey, RouteEntry> routes) {
+ for (final DataTreeCandidateNode child : table.getChildNodes()) {
+ LOG.debug("Modification type {}", child.getModificationType());
+ if ((Attributes.QNAME).equals(child.getIdentifier().getNodeType())) {
+ if (child.getDataAfter().isPresent()) {
+ // putting uptodate attribute in
+ LOG.trace("Uptodate found for {}", child.getDataAfter());
+ tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
+ }
+ continue;
+ }
+ updateRoutesEntries(child, peerId, routes);
+ }
+ }