use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class RibImpl method createRib.
private RIBImpl createRib(final Global global, final String bgpInstanceName, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
this.afiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true);
final Config globalConfig = global.getConfig();
this.asNumber = globalConfig.getAs();
this.routerId = globalConfig.getRouterId();
this.clusterId = getGlobalClusterIdentifier(globalConfig);
final BGPPeerTrackerImpl peerTracker = new BGPPeerTrackerImpl();
final Map<TablesKey, PathSelectionMode> pathSelectionModes = OpenConfigMappingUtil.toPathSelectionMode(this.afiSafi, tableTypeRegistry, peerTracker).entrySet().stream().collect(Collectors.toMap(entry -> new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
final BGPRibRoutingPolicy ribPolicy = this.policyProvider.buildBGPRibPolicy(this.asNumber.getValue(), this.routerId, this.clusterId, RoutingPolicyUtil.getApplyPolicy(global.getApplyPolicy()));
final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(codecTreeFactory, this.extensions.getClassLoadingStrategy());
return new RIBImpl(new RibId(bgpInstanceName), this.asNumber, new BgpId(this.routerId), this.extensions, this.dispatcher, codecsRegistry, this.domBroker, this.dataBroker, ribPolicy, peerTracker, toTableTypes(this.afiSafi, tableTypeRegistry), pathSelectionModes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method setPeerTables.
private static Set<TablesKey> setPeerTables(final ReceivedOpen open) {
final Set<TablesKey> tables = Sets.newHashSet(DEFAULT_TABLE);
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
final CParameters cParam = optCapa.getCParameters();
if (cParam.getAugmentation(CParameters1.class) == null || cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() == null) {
continue;
}
final MultiprotocolCapability multi = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
final TablesKey tt = new TablesKey(multi.getAfi(), multi.getSafi());
tables.add(tt);
}
}
return tables;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AdjRibInWriter method transform.
AdjRibInWriter transform(final PeerId newPeerId, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
final YangInstanceIdentifier newPeerPath;
newPeerPath = createEmptyPeerStructure(newPeerId, tx);
final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(newPeerPath, registry, tableTypes, addPathTablesType, tx);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
if (registerAppPeerListener != null) {
LOG.trace("Application Peer Listener registered");
registerAppPeerListener.register();
}
}
@Override
public void onFailure(final Throwable throwable) {
if (registerAppPeerListener != null) {
LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
} else {
LOG.error("Failed to create Empty Structure", throwable);
}
}
}, MoreExecutors.directExecutor());
return new AdjRibInWriter(this.ribPath, this.chain, this.role, newPeerPath, tb);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AdjRibInWriter method updateRoutes.
void updateRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes attributes) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.writeRoutes(tx, nlri, attributes);
LOG.trace("Write routes {}", nlri);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Write routes {}, succeed", nlri);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Write routes failed", throwable);
}
}, MoreExecutors.directExecutor());
}
Aggregations