use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.", object.getClass());
final Svec svecObj = (Svec) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_F_OFFSET);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(L_FLAG_OFFSET, svecObj.getLinkDiverse());
flags.set(N_FLAG_OFFSET, svecObj.getNodeDiverse());
flags.set(S_FLAG_OFFSET, svecObj.getSrlgDiverse());
flags.set(D_FLAG_OFFSET, svecObj.getLinkDirectionDiverse());
flags.set(P_FLAG_OFFSET, svecObj.getPartialPathDiverse());
flags.toByteBuf(body);
final List<RequestId> requestIDs = svecObj.getRequestsIds();
// FIXME: remove this assert
assert !requestIDs.isEmpty() : "Empty Svec Object - no request ids.";
for (final RequestId requestId : requestIDs) {
ByteBufUtils.write(body, requestId.getValue());
}
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPMonitoringRequestMessageParser method validate.
@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcmonreq message cannot be empty.");
}
final MonitoringRequest monReq = getMonitoring(objects);
if (monReq == null) {
errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
mBuilder.setMonitoringRequest(monReq);
final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
final List<Requests> requests = getRequests(objects, errors);
if (requests != null && !requests.isEmpty()) {
mBuilder.setRequests(requests);
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcmonreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method serializeSvec.
protected void serializeSvec(final PcreqMessage msg, final ByteBuf buffer) {
for (final Svec s : msg.nonnullSvec()) {
serializeObject(s.getSvec(), buffer);
serializeObject(s.getOf(), buffer);
serializeObject(s.getGc(), buffer);
serializeObject(s.getXro(), buffer);
if (s.getMetric() != null) {
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.svec.Metric m : s.nonnullMetric()) {
serializeObject(m.getMetric(), buffer);
}
}
serializeVendorInformationObjects(s.getVendorInformationObject(), buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getSvecs.
protected List<Svec> getSvecs(final Queue<Object> objects) {
final List<Svec> svecList = new ArrayList<>();
while (!objects.isEmpty()) {
final SvecBuilder sBuilder = new SvecBuilder();
final Svec svecComp = getValidSvec(sBuilder, objects);
if (svecComp == null) {
break;
}
svecList.add(svecComp);
}
return svecList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getValidSvec.
// Note: objects is expected to be non-empty
private static Svec getValidSvec(final SvecBuilder builder, final Queue<Object> objects) {
final Object svec = objects.element();
if (svec instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) {
builder.setSvec((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) svec);
objects.remove();
} else {
return null;
}
// FIXME: this list is not retained anywhere
final List<Metrics> metrics = new ArrayList<>();
final List<VendorInformationObject> viObjects = new ArrayList<>();
SvecState state = SvecState.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertP2PObject(state, obj, builder, metrics, viObjects);
if (state == SvecState.END) {
break;
}
objects.remove();
}
if (!viObjects.isEmpty()) {
builder.setVendorInformationObject(viObjects);
}
return builder.build();
}
Aggregations