- private static final NodeIdentifier TABLE_ROUTES = new NodeIdentifier(Routes.QNAME);
- private static final NodeIdentifier ADJRIBIN_NID = new NodeIdentifier(AdjRibIn.QNAME);
- private static final NodeIdentifier TABLES_NID = new NodeIdentifier(Tables.QNAME);
-
- /**
- * Maintains {@link TableRouteListener} instances.
- */
- private final class AdjInTracker implements AutoCloseable, DOMDataTreeChangeListener {
- private final RIBSupportContextRegistry registry;
- private final YangInstanceIdentifier ribId;
- private final ListenerRegistration<?> reg;
- private final DOMTransactionChain chain;
-
- AdjInTracker(final DOMDataTreeChangeService service, final RIBSupportContextRegistry registry, final DOMTransactionChain chain, final YangInstanceIdentifier ribId) {
- this.registry = Preconditions.checkNotNull(registry);
- this.chain = Preconditions.checkNotNull(chain);
- this.ribId = Preconditions.checkNotNull(ribId);
-
- final YangInstanceIdentifier tableId = ribId.node(Peer.QNAME).node(Peer.QNAME);
- final DOMDataTreeIdentifier treeId = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, tableId);
- LOG.debug("Registered Effective RIB on {}", tableId);
- this.reg = service.registerDataTreeChangeListener(treeId, this);
+ private static final TablesKey IVP4_VPN_TABLE_KEY = new TablesKey(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
+ private static final TablesKey IVP6_VPN_TABLE_KEY = new TablesKey(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
+ private static final ImmutableList<Communities> STALE_LLGR_COMMUNUTIES = ImmutableList.of(
+ StaleCommunities.STALE_LLGR);
+ private static final Attributes STALE_LLGR_ATTRIBUTES = new org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder()
+ .setCommunities(STALE_LLGR_COMMUNUTIES)
+ .build();
+ private static final ChoiceNode EMPTY_ROUTES = Builders.choiceBuilder().withNodeIdentifier(ROUTES_NID).build();
+
+ private final RIBSupportContextRegistry registry;
+ private final YangInstanceIdentifier peerIId;
+ private final YangInstanceIdentifier effRibTables;
+ private final DOMDataTreeChangeService service;
+ private final List<RouteTarget> rtMemberships;
+ private final RibOutRefresh vpnTableRefresher;
+ private final ClientRouteTargetContrainCache rtCache;
+ private ListenerRegistration<?> reg;
+ private DOMTransactionChain chain;
+ private final Map<TablesKey, LongAdder> prefixesReceived;
+ private final Map<TablesKey, LongAdder> prefixesInstalled;
+ private final BGPRibRoutingPolicy ribPolicies;
+ private final BGPRouteEntryImportParameters peerImportParameters;
+ private final BGPTableTypeRegistryConsumer tableTypeRegistry;
+ @GuardedBy("this")
+ private FluentFuture<? extends CommitInfo> submitted;
+ private boolean rtMembershipsUpdated;
+
+ EffectiveRibInWriter(
+ final BGPRouteEntryImportParameters peer,
+ final RIB rib,
+ final DOMTransactionChain chain,
+ final YangInstanceIdentifier peerIId,
+ final Set<TablesKey> tables,
+ final BGPTableTypeRegistryConsumer tableTypeRegistry,
+ final List<RouteTarget> rtMemberships,
+ final ClientRouteTargetContrainCache rtCache) {
+ this.registry = requireNonNull(rib.getRibSupportContext());
+ this.chain = requireNonNull(chain);
+ this.peerIId = requireNonNull(peerIId);
+ this.effRibTables = this.peerIId.node(EFFRIBIN_NID);
+ this.prefixesInstalled = buildPrefixesTables(tables);
+ this.prefixesReceived = buildPrefixesTables(tables);
+ this.ribPolicies = requireNonNull(rib.getRibPolicies());
+ this.service = requireNonNull(rib.getService());
+ this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
+ this.peerImportParameters = peer;
+ this.rtMemberships = rtMemberships;
+ this.rtCache = rtCache;
+ this.vpnTableRefresher = rib;
+ }
+
+ public void init() {
+ final DOMDataTreeIdentifier treeId = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ this.peerIId.node(ADJRIBIN_NID).node(TABLES_NID));
+ LOG.debug("Registered Effective RIB on {}", this.peerIId);
+ this.reg = requireNonNull(this.service).registerDataTreeChangeListener(treeId, this);
+ }
+
+ private static Map<TablesKey, LongAdder> buildPrefixesTables(final Set<TablesKey> tables) {
+ final ImmutableMap.Builder<TablesKey, LongAdder> b = ImmutableMap.builder();
+ tables.forEach(table -> b.put(table, new LongAdder()));
+ return b.build();
+ }
+
+ @Override
+ public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+ if (this.chain == null) {
+ LOG.trace("Chain closed. Ignoring Changes : {}", changes);
+ return;