Search in sources :

Example 1 with MetricPce

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method validateSpecificMetrics.

private static void validateSpecificMetrics(final List<Object> objects, final PcmonrepMessageBuilder builder) throws PCEPDeserializerException {
    final List<SpecificMetrics> specificMetrics = new ArrayList<>();
    while (!objects.isEmpty()) {
        final SpecificMetricsBuilder smb = new SpecificMetricsBuilder();
        final List<MetricPce> metricPceList = new ArrayList<>();
        if (objects.get(0) instanceof Rp) {
            smb.setRp((Rp) objects.get(0));
            objects.remove(0);
        }
        while (!objects.isEmpty() && !(objects.get(0) instanceof Rp)) {
            metricPceList.add(Util.validateMonitoringMetrics(objects));
        }
        if (smb.getRp() != null) {
            smb.setMetricPce(metricPceList);
            specificMetrics.add(smb.build());
        } else if (!metricPceList.isEmpty()) {
            builder.setMonitoringMetricsList(new GeneralMetricsListBuilder().setMetricPce(metricPceList).build());
        }
    }
    if (!specificMetrics.isEmpty()) {
        builder.setMonitoringMetricsList(new SpecificMetricsListBuilder().setSpecificMetrics(specificMetrics).build());
    }
}
Also used : SpecificMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.SpecificMetricsListBuilder) GeneralMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.GeneralMetricsListBuilder) SpecificMetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder) SpecificMetrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics) ArrayList(java.util.ArrayList) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)

Example 2 with MetricPce

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce 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();
}
Also used : RepliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero) ArrayList(java.util.ArrayList) Result(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)

Example 3 with MetricPce

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method validateSpecificMetrics.

private static void validateSpecificMetrics(final Queue<Object> objects, final PcmonrepMessageBuilder builder) throws PCEPDeserializerException {
    final List<SpecificMetrics> specificMetrics = new ArrayList<>();
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        final SpecificMetricsBuilder smb = new SpecificMetricsBuilder();
        if (obj instanceof Rp) {
            smb.setRp((Rp) obj);
            objects.remove();
        }
        final List<MetricPce> metricPceList = new ArrayList<>();
        for (obj = objects.peek(); obj != null && !(obj instanceof Rp); obj = objects.peek()) {
            metricPceList.add(Util.validateMonitoringMetrics(objects));
        }
        if (smb.getRp() != null) {
            specificMetrics.add(smb.setMetricPce(metricPceList).build());
        } else if (!metricPceList.isEmpty()) {
            builder.setMonitoringMetricsList(new GeneralMetricsListBuilder().setMetricPce(metricPceList).build());
        }
    }
    if (!specificMetrics.isEmpty()) {
        builder.setMonitoringMetricsList(new SpecificMetricsListBuilder().setSpecificMetrics(specificMetrics).build());
    }
}
Also used : SpecificMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.SpecificMetricsListBuilder) GeneralMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.GeneralMetricsListBuilder) SpecificMetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder) SpecificMetrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics) ArrayList(java.util.ArrayList) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce)

Example 4 with MetricPce

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce in project bgpcep by opendaylight.

the class Util method validateMonitoringMetrics.

public static MetricPce validateMonitoringMetrics(final Queue<Object> objects) throws PCEPDeserializerException {
    final Object pceId = objects.poll();
    if (!(pceId instanceof PceId)) {
        throw new PCEPDeserializerException("metric-pce-list must start with PCE-ID object.");
    }
    final MetricPceBuilder metricPceBuilder = new MetricPceBuilder().setPceId((PceId) pceId);
    State state = State.START;
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        state = insertObject(metricPceBuilder, state, obj);
        if (state == State.END) {
            break;
        }
        objects.remove();
    }
    return metricPceBuilder.build();
}
Also used : PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) MetricPceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPceBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 5 with MetricPce

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce in project bgpcep by opendaylight.

the class Util method validateMonitoringMetrics.

public static MetricPce validateMonitoringMetrics(final List<Object> objects) throws PCEPDeserializerException {
    final MetricPceBuilder metricPceBuilder = new MetricPceBuilder();
    if (!(objects.get(0) instanceof PceId)) {
        throw new PCEPDeserializerException("metric-pce-list must start with PCE-ID object.");
    }
    metricPceBuilder.setPceId((PceId) (objects.get(0)));
    objects.remove(0);
    State state = State.START;
    while (!objects.isEmpty() && !state.equals(State.END)) {
        final Object obj = objects.get(0);
        state = insertObject(metricPceBuilder, state, obj);
        if (!state.equals(State.END)) {
            objects.remove(0);
        }
    }
    return metricPceBuilder.build();
}
Also used : PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) MetricPceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

ArrayList (java.util.ArrayList)5 MetricPce (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce)4 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)3 ByteBuf (io.netty.buffer.ByteBuf)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)2 MetricPce (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)2 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)2 Rp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)2 MetricPceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPceBuilder)2 GeneralMetricsListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.GeneralMetricsListBuilder)2 SpecificMetricsListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.SpecificMetricsListBuilder)2 SpecificMetrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics)2 SpecificMetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder)2 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId)2 Rp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp)2 Test (org.junit.Test)1 PCEPMonitoringReplyMessageParser (org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringReplyMessageParser)1 Pcmonrep (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcmonrep)1 PcmonrepBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonrepBuilder)1