use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class MldpMp2mpLspParser method parse.
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
if (opaque == null) {
return null;
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class MldpP2mpLspParser method serialize.
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp();
final ByteBuf opaqueValues = Unpooled.buffer();
final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily());
if (!serializeOpaqueList(mldpP2mpLsp.getOpaqueValue(), opaqueValues) || addressFamily == 0) {
return NO_TUNNEL_INFORMATION_PRESENT;
}
final IpAddress rootNode = mldpP2mpLsp.getRootNodeAddress();
ByteBufWriteUtil.writeUnsignedByte(P2MP_TYPE, buffer);
ByteBufWriteUtil.writeUnsignedShort(addressFamily, buffer);
ByteBufWriteUtil.writeUnsignedByte(getAdressFamilyLength(rootNode), buffer);
serializeIpAddress(rootNode, buffer);
ByteBufWriteUtil.writeUnsignedShort(opaqueValues.readableBytes(), buffer);
buffer.writeBytes(opaqueValues);
return TunnelType.MLDP_P2MP_LSP.getIntValue();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project genius by opendaylight.
the class HwVtepTunnelsStateHandler method update.
@Override
public void update(@Nonnull Tunnels oldTunnelInfo, @Nonnull Tunnels updatedTunnelInfo) {
List<BfdStatus> oldBfdStatus = oldTunnelInfo.getBfdStatus();
List<BfdStatus> newBfdStatus = updatedTunnelInfo.getBfdStatus();
LivenessState oldTunnelOpState = getTunnelOpState(oldBfdStatus);
final LivenessState newTunnelOpState = getTunnelOpState(newBfdStatus);
if (oldTunnelOpState == newTunnelOpState) {
LOG.debug("Tunnel state of old tunnel {} and update tunnel {} are same", oldTunnelInfo, updatedTunnelInfo);
return;
}
updatedTunnelInfo.getTunnelUuid();
String interfaceName = "<TODO>";
// TODO: find out the corresponding interface using tunnelIdentifier or
// any attributes of tunnelInfo object
final String monitorKey = getBfdMonitorKey(interfaceName);
LOG.debug("Processing monitorKey: {} for received Tunnels update DCN", monitorKey);
final Semaphore lock = alivenessMonitor.getLock(monitorKey);
LOG.debug("Acquiring lock for monitor key : {} to process monitor DCN", monitorKey);
alivenessMonitor.acquireLock(lock);
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<MonitoringState>> stateResult = tx.read(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey));
Futures.addCallback(stateResult, new FutureCallback<Optional<MonitoringState>>() {
@Override
public void onSuccess(@Nonnull Optional<MonitoringState> optState) {
if (optState.isPresent()) {
final MonitoringState currentState = optState.get();
if (currentState.getState() == newTunnelOpState) {
return;
}
final boolean stateChanged = true;
final MonitoringState state = new MonitoringStateBuilder().setMonitorKey(monitorKey).setState(newTunnelOpState).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey), state);
ListenableFuture<Void> writeResult = tx.submit();
// WRITE Callback
Futures.addCallback(writeResult, new FutureCallback<Void>() {
@Override
public void onSuccess(Void arg0) {
alivenessMonitor.releaseLock(lock);
if (stateChanged) {
// send notifications
LOG.info("Sending notification for monitor Id : {} with Current State: {}", currentState.getMonitorId(), newTunnelOpState);
alivenessMonitor.publishNotification(currentState.getMonitorId(), newTunnelOpState);
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Successful in writing monitoring state {} to ODS", state);
}
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
alivenessMonitor.releaseLock(lock);
LOG.warn("Error in writing monitoring state : {} to Datastore", monitorKey, error);
if (LOG.isTraceEnabled()) {
LOG.trace("Error in writing monitoring state: {} to Datastore", state);
}
}
}, MoreExecutors.directExecutor());
} else {
LOG.warn("Monitoring State not available for key: {} to process the Packet received", monitorKey);
// Complete the transaction
tx.submit();
alivenessMonitor.releaseLock(lock);
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("Error when reading Monitoring State for key: {} to process the Packet received", monitorKey, error);
// FIXME: Not sure if the transaction status is valid to cancel
tx.cancel();
alivenessMonitor.releaseLock(lock);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandler method serializeAttribute.
@Override
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
final PmsiTunnelAugmentation pmsiTunnelAugmentation = attribute.augmentation(PmsiTunnelAugmentation.class);
if (pmsiTunnelAugmentation == null) {
return;
}
final PmsiTunnel pmsiTunnelAttribute = pmsiTunnelAugmentation.getPmsiTunnel();
final TunnelIdentifier tunnel = pmsiTunnelAttribute.getTunnelIdentifier();
final ByteBuf tunnelBuffer = Unpooled.buffer();
final int tunnelType = this.tunnelIdentifierHandler.serialize(tunnel, tunnelBuffer);
final ByteBuf body = Unpooled.buffer();
serializeFlag(pmsiTunnelAttribute, body);
body.writeByte(tunnelType);
serializeMpls(pmsiTunnelAttribute.getMplsLabel(), body);
body.writeBytes(tunnelBuffer);
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, getType(), body, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandler method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint) {
// FIXME: BGPCEP-359: what is the error handling here?
if (!buffer.isReadable()) {
return;
}
final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
pmsiTunnelBuilder.setLeafInformationRequired(buffer.readBoolean());
final int tunnelType = buffer.readUnsignedByte();
parseMpls(pmsiTunnelBuilder, buffer);
final TunnelIdentifier tunnelIdentifier = this.tunnelIdentifierHandler.parse(tunnelType, buffer);
if (tunnelIdentifier != null) {
pmsiTunnelBuilder.setTunnelIdentifier(tunnelIdentifier);
}
builder.addAugmentation(new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build());
}
Aggregations