use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global in project bgpcep by opendaylight.
the class Type1LabelParser method serializeLabel.
@Override
public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject instanceof Type1LabelCase, "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
final ByteBuf body = Unpooled.buffer(LABEL_LENGTH);
final Type1Label type1Label = ((Type1LabelCase) subobject).getType1Label();
Preconditions.checkArgument(type1Label != null, "Type1Label is mandatory.");
writeUnsignedInt(type1Label.getType1Label(), body);
LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global in project genius by opendaylight.
the class SouthboundUtils method createGlobalNodeInstanceIdentifier.
@Nullable
public static InstanceIdentifier<Node> createGlobalNodeInstanceIdentifier(String psNodeIdString) {
String globalNodeIdStr;
try {
globalNodeIdStr = psNodeIdString.substring(0, psNodeIdString.indexOf(PS_NODE_ID_PREFIX));
} catch (StringIndexOutOfBoundsException ex) {
LOG.error("cannot determine global-node-id for the physical node {}", psNodeIdString);
return null;
}
NodeId globalNodeId = new NodeId(globalNodeIdStr);
InstanceIdentifier<Node> globalNodeInstanceId = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(HWVTEP_TOPOLOGY_ID)).child(Node.class, new NodeKey(globalNodeId));
return globalNodeInstanceId;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global in project genius by opendaylight.
the class IdManager method allocateIdBlockFromAvailableIdsHolder.
private long allocateIdBlockFromAvailableIdsHolder(IdLocalPool localIdPool, IdPool parentIdPool, WriteTransaction tx) {
long idCount = 0;
AvailableIdsHolderBuilder availableIdsBuilderParent = idUtils.getAvailableIdsHolderBuilder(parentIdPool);
long end = availableIdsBuilderParent.getEnd();
long cur = availableIdsBuilderParent.getCursor();
if (!idUtils.isIdAvailable(availableIdsBuilderParent)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Ids exhausted in parent pool {}", parentIdPool);
}
return idCount;
}
// Update availableIdsHolder of Local Pool
idCount = Math.min(end - cur, parentIdPool.getBlockSize());
AvailableIdHolder availableIds = new AvailableIdHolder(idUtils, cur + 1, cur + idCount);
localIdPool.setAvailableIds(availableIds);
// Update availableIdsHolder of Global Pool
InstanceIdentifier<AvailableIdsHolder> availableIdsHolderInstanceIdentifier = InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(parentIdPool.getPoolName())).child(AvailableIdsHolder.class).build();
availableIdsBuilderParent.setCursor(cur + idCount);
if (LOG.isDebugEnabled()) {
LOG.debug("Allocated {} ids from availableIds of global pool {}", idCount, parentIdPool);
}
tx.merge(CONFIGURATION, availableIdsHolderInstanceIdentifier, availableIdsBuilderParent.build(), true);
return idCount;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global in project genius by opendaylight.
the class IdManager method allocateIdBlockFromParentPool.
private long allocateIdBlockFromParentPool(IdLocalPool localPoolCache, IdPool parentIdPool, WriteTransaction tx) throws OperationFailedException, IdManagerException {
long idCount = -1;
ReleasedIdsHolderBuilder releasedIdsBuilderParent = idUtils.getReleaseIdsHolderBuilder(parentIdPool);
while (true) {
idCount = allocateIdBlockFromAvailableIdsHolder(localPoolCache, parentIdPool, tx);
if (idCount > 0) {
return idCount;
}
idCount = allocateIdBlockFromReleasedIdsHolder(localPoolCache, releasedIdsBuilderParent, parentIdPool, tx);
if (idCount > 0) {
return idCount;
}
idCount = getIdsFromOtherChildPools(releasedIdsBuilderParent, parentIdPool);
if (idCount <= 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("Unable to allocate Id block from global pool");
}
throw new IdManagerException(String.format("Ids exhausted for pool : %s", parentIdPool.getPoolName()));
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global in project bgpcep by opendaylight.
the class StateProviderImpl method storeOperationalState.
private synchronized void storeOperationalState(final BGPRibState bgpStateConsumer, final List<BGPPeerState> peerStats, final String ribId, final WriteTransaction wtx) {
final Global global = GlobalUtil.buildGlobal(bgpStateConsumer, this.bgpTableTypeRegistry);
final PeerGroups peerGroups = PeerGroupUtil.buildPeerGroups(peerStats);
final Neighbors neighbors = NeighborUtil.buildNeighbors(peerStats, this.bgpTableTypeRegistry);
InstanceIdentifier<Bgp> bgpIID = this.instanceIdentifiersCache.get(ribId);
if (bgpIID == null) {
final ProtocolKey protocolKey = new ProtocolKey(BGP.class, bgpStateConsumer.getInstanceIdentifier().getKey().getId().getValue());
final KeyedInstanceIdentifier<Protocol, ProtocolKey> protocolIId = this.networkInstanceIId.child(Protocols.class).child(Protocol.class, protocolKey);
bgpIID = protocolIId.augmentation(NetworkInstanceProtocol.class).child(Bgp.class);
this.instanceIdentifiersCache.put(ribId, bgpIID);
}
final Bgp bgp = new BgpBuilder().setGlobal(global).setNeighbors(neighbors).setPeerGroups(peerGroups).build();
wtx.put(LogicalDatastoreType.OPERATIONAL, bgpIID, bgp, WriteTransaction.CREATE_MISSING_PARENTS);
}
Aggregations