use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests in project bgpcep by opendaylight.
the class PCEPMonitoringRequestMessageParser method validate.
@Override
protected Message validate(final Queue<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.empty()));
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder().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.Requests in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method validate.
@Override
protected Message validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcrep message cannot be empty.");
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder().setMonitoringRequest(getMonitoring(objects));
final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
final List<Requests> requests = getRequests(objects, errors);
if (requests != null) {
mBuilder.setRequests(requests);
} else {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method serializeRequest.
protected void serializeRequest(final PcreqMessage msg, final ByteBuf buffer) {
for (final Requests req : msg.nonnullRequests()) {
serializeObject(req.getRp(), buffer);
serializeVendorInformationObjects(req.getVendorInformationObject(), buffer);
if (req.getPathKeyExpansion() != null) {
serializeObject(req.getPathKeyExpansion().getPathKey(), buffer);
}
if (req.getSegmentComputation() != null) {
final SegmentComputation sc = req.getSegmentComputation();
if (sc.getP2p() != null) {
serializeP2P(buffer, sc.getP2p());
}
if (sc.getP2mp() != null) {
serializeP2MP(buffer, sc.getP2mp());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests in project bgpcep by opendaylight.
the class InitiatedPCInitiateMessageParser method getValidRequest.
protected Requests getValidRequest(final Queue<Object> objects) throws PCEPDeserializerException {
final RequestsBuilder builder = new RequestsBuilder().setSrp(consumeObject(objects, Srp.class)).setLsp(consumeObject(objects, Lsp.class));
final List<Metrics> metrics = new ArrayList<>();
State state = State.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertObject(state, obj, builder, metrics);
if (state == State.END) {
break;
}
objects.remove();
}
builder.setMetrics(metrics);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests in project bgpcep by opendaylight.
the class InitiatedPCInitiateMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
checkArgument(message instanceof Pcinitiate, "Wrong instance of Message. Passed instance of %s. Need PcinitiateMessage.", message.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessage init = ((Pcinitiate) message).getPcinitiateMessage();
final ByteBuf buffer = Unpooled.buffer();
for (final Requests req : init.getRequests()) {
serializeRequest(req, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
Aggregations