Search in sources :

Example 1 with Pcmonrep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonrep in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser 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("Pcmonrep message cannot be empty.");
    }
    if (!(objects.get(0) instanceof Monitoring)) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
        return null;
    }
    final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
    builder.setMonitoring((Monitoring) objects.get(0));
    objects.remove(0);
    if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) objects.get(0));
        objects.remove(0);
    }
    validateSpecificMetrics(objects, builder);
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build();
}
Also used : PcmonrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessageBuilder) PcmonrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonrepBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)

Example 2 with Pcmonrep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonrep in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
    Preconditions.checkArgument(message instanceof Pcmonrep, "Wrong instance of Message. Passed instance of %s. Need Pcmonrep.", message.getClass());
    final PcmonrepMessage monRepMsg = ((Pcmonrep) message).getPcmonrepMessage();
    Preconditions.checkArgument(monRepMsg.getMonitoring() != null, "MONITORING object is mandatory.");
    final ByteBuf body = Unpooled.buffer();
    serializeObject(monRepMsg.getMonitoring(), body);
    serializeObject(monRepMsg.getPccIdReq(), body);
    if (monRepMsg.getMonitoringMetricsList() instanceof GeneralMetricsList) {
        final GeneralMetricsList gml = (GeneralMetricsList) monRepMsg.getMonitoringMetricsList();
        if (gml.getMetricPce() != null) {
            for (final MetricPce metricPce : gml.getMetricPce()) {
                serializeMetricPce(metricPce, body);
            }
        }
    } else if (monRepMsg.getMonitoringMetricsList() instanceof SpecificMetricsList) {
        final SpecificMetricsList sml = (SpecificMetricsList) monRepMsg.getMonitoringMetricsList();
        if (sml.getSpecificMetrics() != null) {
            for (final SpecificMetrics specificMetrics : sml.getSpecificMetrics()) {
                serializeObject(specificMetrics.getRp(), body);
                if (specificMetrics.getMetricPce() != null) {
                    for (final MetricPce metricPce : specificMetrics.getMetricPce()) {
                        serializeMetricPce(metricPce, body);
                    }
                }
            }
        }
    }
    MessageUtil.formatMessage(TYPE, body, buffer);
}
Also used : SpecificMetricsList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.SpecificMetricsList) Pcmonrep(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonrep) PcmonrepMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessage) SpecificMetrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics) ByteBuf(io.netty.buffer.ByteBuf) GeneralMetricsList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.GeneralMetricsList) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 Pcmonrep (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonrep)1 PcmonrepBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonrepBuilder)1 MetricPce (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)1 GeneralMetricsList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.GeneralMetricsList)1 SpecificMetricsList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.SpecificMetricsList)1 SpecificMetrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq)1 PcmonrepMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessage)1 PcmonrepMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessageBuilder)1