Search in sources :

Example 1 with InstanceIdentifierBuilder

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder 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 InstanceIdentifierBuilder

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder in project bgpcep by opendaylight.

the class BmpRibInWriter method createTableInstance.

/**
 * Create new table instance.
 */
private static ImmutableMap.Builder<TablesKey, TableContext> createTableInstance(final Set<TablesKey> tableTypes, final YangInstanceIdentifier yangTableRootIId, final DOMDataWriteTransaction tx, final RIBExtensionConsumerContext ribExtensions, final BindingCodecTree tree) {
    final ImmutableMap.Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey k : tableTypes) {
        final RIBSupport rs = ribExtensions.getRIBSupport(k);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", k);
            continue;
        }
        final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(yangTableRootIId);
        final NodeIdentifierWithPredicates key = TablesUtil.toYangTablesKey(k);
        idb.nodeWithKey(key.getNodeType(), key.getKeyValues());
        final TableContext ctx = new TableContext(rs, idb.build(), tree);
        ctx.createTable(tx);
        tx.put(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(BMP_ATTRIBUTES_QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
        LOG.debug("Created table instance {}", ctx.getTableId());
        tb.put(k, ctx);
    }
    return tb;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with InstanceIdentifierBuilder

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder in project bgpcep by opendaylight.

the class AdjRibInWriter method installAdjRibInTables.

private static void installAdjRibInTables(final YangInstanceIdentifier newPeerPath, final TablesKey tableKey, final RIBSupportContext rs, final NodeIdentifierWithPredicates instanceIdentifierKey, final DOMDataWriteTransaction tx, final Builder<TablesKey, TableContext> tb) {
    // We will use table keys very often, make sure they are optimized
    final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(newPeerPath.node(EMPTY_ADJRIBIN.getIdentifier()).node(TABLES));
    idb.nodeWithKey(instanceIdentifierKey.getNodeType(), instanceIdentifierKey.getKeyValues());
    final TableContext ctx = new TableContext(rs, idb.build());
    ctx.createEmptyTableStructure(tx);
    tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
    LOG.debug("Created table instance {}", ctx.getTableId());
    tb.put(tableKey, ctx);
}
Also used : InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder)

Aggregations

InstanceIdentifierBuilder (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder)3 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)1 RIBSupportContext (org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext)1 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)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 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)1 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)1