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());
}
}
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;
}
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);
}
Aggregations