Search in sources :

Example 1 with RIBSupportContext

use of org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext in project bgpcep by opendaylight.

the class RIBImpl method startLocRib.

private synchronized 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()));
    }
    final RIBSupportContext supportContext = this.ribContextRegistry.getRIBSupportContext(key);
    if (supportContext != null) {
        final ChoiceNode routes = supportContext.getRibSupport().emptyRoutes();
        table.withChild(routes);
        tx.put(LogicalDatastoreType.OPERATIONAL, tableId.build(), table.build());
        try {
            tx.submit().checkedGet();
        } catch (final TransactionCommitFailedException e1) {
            LOG.error("Failed to initiate LocRIB for key {}", key, e1);
        }
    } else {
        LOG.warn("There's no registered RIB Context for {}", key.getAfi());
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) QName(org.opendaylight.yangtools.yang.common.QName) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 2 with RIBSupportContext

use of org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext in project bgpcep by opendaylight.

the class AdjRibInWriter method createNewTableInstances.

/**
 * Create new table instances, potentially creating their empty entries
 */
private ImmutableMap<TablesKey, TableContext> createNewTableInstances(final YangInstanceIdentifier newPeerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, final DOMDataWriteTransaction tx) {
    final Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey tableKey : tableTypes) {
        final RIBSupportContext rs = registry.getRIBSupportContext(tableKey);
        // TODO: Use returned value once Instance Identifier builder allows for it.
        final NodeIdentifierWithPredicates instanceIdentifierKey = RibSupportUtils.toYangTablesKey(tableKey);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", tableKey);
            continue;
        }
        installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey, addPathTablesType.get(tableKey), tx);
        installAdjRibInTables(newPeerPath, tableKey, rs, instanceIdentifierKey, tx, tb);
    }
    return tb.build();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Aggregations

RIBSupportContext (org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext)2 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)1 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)1 QName (org.opendaylight.yangtools.yang.common.QName)1 InstanceIdentifierBuilder (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder)1 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)1 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)1