use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder in project bgpcep by opendaylight.
the class Stateful07OpenObjectParser method addTlv.
@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
super.addTlv(tbuilder, tlv);
final Tlvs1Builder statefulBuilder = new Tlvs1Builder();
if (tbuilder.getAugmentation(Tlvs1.class) != null) {
final Tlvs1 t = tbuilder.getAugmentation(Tlvs1.class);
if (t.getStateful() != null) {
statefulBuilder.setStateful(t.getStateful());
}
}
if (tlv instanceof Stateful) {
statefulBuilder.setStateful((Stateful) tlv);
}
tbuilder.addAugmentation(Tlvs1.class, statefulBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder in project bgpcep by opendaylight.
the class Stateful07SrpObjectParser method parseObject.
@Override
public Srp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (bytes.readableBytes() < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
}
final SrpBuilder builder = new SrpBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
parseFlags(builder, bytes);
builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt()));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
builder.setTlvs(tlvsBuilder.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder in project bgpcep by opendaylight.
the class Stateful07LspObjectParser method parseObject.
@Override
public Lsp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final LspBuilder builder = new LspBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final int[] plspIdRaw = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2) };
builder.setPlspId(new PlspId((long) ((plspIdRaw[0] << FLAGS_SIZE) | (plspIdRaw[1] << FOUR_BITS_SHIFT) | (plspIdRaw[2] >> FOUR_BITS_SHIFT))));
parseFlags(builder, bytes);
final TlvsBuilder b = new TlvsBuilder();
parseTlvs(b, bytes.slice());
builder.setTlvs(b.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder in project bgpcep by opendaylight.
the class Stateful07LspaObjectParser method addTlv.
@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
super.addTlv(tbuilder, tlv);
final Tlvs2Builder nameBuilder = new Tlvs2Builder();
if (tbuilder.getAugmentation(Tlvs2.class) != null) {
final Tlvs2 t = tbuilder.getAugmentation(Tlvs2.class);
if (t.getSymbolicPathName() != null) {
nameBuilder.setSymbolicPathName(t.getSymbolicPathName());
}
}
if (tlv instanceof SymbolicPathName) {
nameBuilder.setSymbolicPathName((SymbolicPathName) tlv);
}
tbuilder.addAugmentation(Tlvs2.class, nameBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPStatefulPeerProposal method setPeerProposal.
void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder, final byte[] speakerId) {
if (isSynOptimizationEnabled(openTlvsBuilder)) {
Optional<LspDbVersion> result = Optional.absent();
try (ReadOnlyTransaction rTx = this.dataBroker.newReadOnlyTransaction()) {
final ListenableFuture<Optional<LspDbVersion>> future = rTx.read(LogicalDatastoreType.OPERATIONAL, this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class).child(PathComputationClient.class).augmentation(PathComputationClient1.class).child(LspDbVersion.class));
try {
result = future.get();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(PCEPStatefulPeerProposal.this.topologyId), e);
}
}
if (speakerId == null && !result.isPresent()) {
return;
}
final Tlvs3Builder syncBuilder = new Tlvs3Builder();
if (result.isPresent()) {
syncBuilder.setLspDbVersion(result.get());
}
if (speakerId != null) {
syncBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(speakerId).build());
}
openTlvsBuilder.addAugmentation(Tlvs3.class, syncBuilder.build()).build();
}
}
Aggregations