use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method validate.
@Override
protected Pcrep 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("Pcrep message cannot be empty.");
}
final List<Replies> replies = new ArrayList<>();
while (!objects.isEmpty()) {
final Replies r = this.getValidReply(objects, errors);
if (r != null) {
replies.add(r);
}
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().setReplies(replies).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method getValidReply.
protected Replies getValidReply(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Object object = objects.remove(0);
if (!(object instanceof Rp)) {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
final Rp rp = (Rp) object;
final RepliesBuilder repliesBuilder = new RepliesBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
repliesBuilder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
}
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
repliesBuilder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
Result res = null;
if (!objects.isEmpty()) {
if (objects.get(0) instanceof NoPath) {
res = handleNoPath((NoPath) objects.get(0), objects);
} else if (objects.get(0) instanceof Ero) {
res = handleEro((Ero) objects.get(0), objects);
}
}
final List<MetricPce> metricPceList = new ArrayList<>();
if (!objects.isEmpty() && objects.get(0) instanceof PceId) {
while (!objects.isEmpty()) {
metricPceList.add(Util.validateMonitoringMetrics(objects));
}
}
if (!vendorInfo.isEmpty()) {
repliesBuilder.setVendorInformationObject(vendorInfo);
}
if (!metricPceList.isEmpty()) {
repliesBuilder.setMetricPce(metricPceList);
}
return repliesBuilder.setRp(rp).setResult(res).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
checkArgument(message instanceof Pcrep, "Wrong instance of Message. Passed instance of %s. Need Pcrep.", message.getClass());
final PcrepMessage repMsg = ((Pcrep) message).getPcrepMessage();
final List<Replies> replies = repMsg.nonnullReplies();
checkArgument(!replies.isEmpty(), "Replies cannot be null or empty.");
final ByteBuf buffer = Unpooled.buffer();
for (final Replies reply : replies) {
checkArgument(reply.getRp() != null, "Reply must contain RP object.");
serializeReply(reply, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method validate.
@Override
protected Pcrep validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcrep message cannot be empty.");
}
final List<Replies> replies = new ArrayList<>();
while (!objects.isEmpty()) {
final Replies r = this.getValidReply(objects, errors);
if (r != null) {
replies.add(r);
}
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().setReplies(replies).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method serializeReply.
protected void serializeReply(final Replies reply, final ByteBuf buffer) {
serializeObject(reply.getRp(), buffer);
serializeMonitoring(reply, buffer);
serializeVendorInformationObjects(reply.getVendorInformationObject(), buffer);
if (reply.getResult() == null) {
return;
}
if (reply.getResult() instanceof FailureCase) {
final FailureCase f = (FailureCase) reply.getResult();
serializeFailure(f, buffer);
return;
}
final SuccessCase s = (SuccessCase) reply.getResult();
serializeSuccess(s, buffer);
serializeMonitoringMetrics(reply, buffer);
}
Aggregations