- @Override
- public synchronized void updateTables(final Peer peer, final Update message) {
- final AdjRIBsTransactionImpl trans = new AdjRIBsTransactionImpl(this.ribOuts, this.comparator, this.chain.newWriteOnlyTransaction());
-
- if (!EOR.equals(message)) {
- final WithdrawnRoutes wr = message.getWithdrawnRoutes();
- if (wr != null) {
- final AdjRIBsIn<?, ?> ari = this.tables.get(IPV4_UNICAST_TABLE);
- if (ari != null) {
- /*
- * create MPUnreach for the routes to be handled in the same way as linkstate routes
- */
- ari.removeRoutes(
- trans,
- peer,
- new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(
- new WithdrawnRoutesBuilder().setDestinationType(
- new DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(wr.getWithdrawnRoutes()).build()).build()).build()).build());
- } else {
- LOG.debug("Not removing objects from unhandled IPv4 Unicast");
- }
- }
-
- final PathAttributes attrs = message.getPathAttributes();
- if (attrs != null) {
- final PathAttributes2 mpu = attrs.getAugmentation(PathAttributes2.class);
- if (mpu != null) {
- final MpUnreachNlri nlri = mpu.getMpUnreachNlri();
- final AdjRIBsIn<?, ?> ari = this.tables.get(new TablesKey(nlri.getAfi(), nlri.getSafi()));
- // EOR messages do not contain withdrawn routes
- if (nlri.getWithdrawnRoutes() != null) {
- if (ari != null) {
- ari.removeRoutes(trans, peer, nlri);
- } else {
- LOG.debug("Not removing objects from unhandled NLRI {}", nlri);
- }
- } else {
- ari.markUptodate(trans, peer);
- }
- }
- }
-
- final Nlri ar = message.getNlri();
- if (ar != null) {
- final AdjRIBsIn<?, ?> ari = this.tables.get(IPV4_UNICAST_TABLE);
- if (ari != null) {
- /*
- * create MPReach for the routes to be handled in the same way as linkstate routes
- */
- final MpReachNlriBuilder b = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(
- UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(
- new AdvertizedRoutesBuilder().setDestinationType(
- new DestinationIpv4CaseBuilder().setDestinationIpv4(
- new DestinationIpv4Builder().setIpv4Prefixes(ar.getNlri()).build()).build()).build());
- if (attrs != null) {
- b.setCNextHop(attrs.getCNextHop());
- }
-
- ari.addRoutes(trans, peer, b.build(), attrs);
- } else {
- LOG.debug("Not adding objects from unhandled IPv4 Unicast");
- }
- }
-
- if (attrs != null) {
- final PathAttributes1 mpr = attrs.getAugmentation(PathAttributes1.class);
- if (mpr != null) {
- final MpReachNlri nlri = mpr.getMpReachNlri();
-
- final AdjRIBsIn<?, ?> ari = this.tables.get(new TablesKey(nlri.getAfi(), nlri.getSafi()));
- if (ari != null) {
- if (message.equals(ari.endOfRib())) {
- ari.markUptodate(trans, peer);
- } else {
- ari.addRoutes(trans, peer, nlri, attrs);
- }
- } else {
- LOG.debug("Not adding objects from unhandled NLRI {}", nlri);
- }
- }
- }
- } else {
- final AdjRIBsIn<?, ?> ari = this.tables.get(IPV4_UNICAST_TABLE);
- if (ari != null) {
- ari.markUptodate(trans, peer);
- } else {
- LOG.debug("End-of-RIB for IPv4 Unicast ignored");
- }
+ private void startLocRib(final TablesKey key) {
+ LOG.debug("Creating LocRib table for {}", key);
+ // create locRibWriter for each table
+ final DOMDataWriteTransaction tx = this.domChain.newWriteOnlyTransaction();
+
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> table = ImmutableNodes.mapEntryBuilder();
+ table.withNodeIdentifier(RibSupportUtils.toYangTablesKey(key));
+ table.withChild(EMPTY_TABLE_ATTRIBUTES);
+
+ final NodeIdentifierWithPredicates tableKey = RibSupportUtils.toYangTablesKey(key);
+ final InstanceIdentifierBuilder tableId = YangInstanceIdentifier.builder(this.yangRibId.node(LocRib.QNAME).node(Tables.QNAME));
+ tableId.nodeWithKey(tableKey.getNodeType(), tableKey.getKeyValues());
+ for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
+ table.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));