Search in sources :

Example 26 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method insertP2MPObject.

private static P2MPState insertP2MPObject(final P2MPState p2MPState, final Queue<Object> objects, final P2mpBuilder builder, final List<EndpointRroPair> epRros, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.Metric> metrics, final List<Message> errors, final Rp rp) {
    final Object obj = objects.element();
    switch(p2MPState) {
        case RP:
            if (obj instanceof EndpointsObj) {
                final EndpointRroPairBuilder rroPairBuilder = new EndpointRroPairBuilder();
                if (obj.getProcessingRule()) {
                    rroPairBuilder.setEndpointsObj((EndpointsObj) obj);
                } else {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
                }
                epRros.add(rroPairBuilder.setRros(new ArrayList<>()).build());
                return P2MPState.ENDPOINT;
            }
        // fallthrough
        case ENDPOINT:
            if (obj instanceof Rro || obj instanceof Srro) {
                if (obj.getProcessingRule()) {
                    final int lastIndex = epRros.size() - 1;
                    final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
                    List<Rros> rros = endpointRroPair.getRros();
                    if (rros == null) {
                        rros = new ArrayList<>();
                    }
                    if (obj instanceof Rro) {
                        rros.add(new RrosBuilder().setRouteObject(new ReportedRouteObjectCaseBuilder().setRro((Rro) obj).build()).build());
                    } else {
                        rros.add(new RrosBuilder().setRouteObject(new SecondaryReportedRouteObjectCaseBuilder().setSrro((Srro) obj).build()).build());
                    }
                    epRros.remove(lastIndex);
                    epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setRros(rros).build());
                }
                return P2MPState.ENDPOINT;
            }
        // fallthrough
        case RRO_SRRO:
            if (obj instanceof ReoptimizationBandwidth) {
                final int lastIndex = epRros.size() - 1;
                final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
                epRros.remove(lastIndex);
                epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setReoptimizationBandwidth((ReoptimizationBandwidth) obj).build());
                return P2MPState.BANDWIDTH;
            }
        // fallthrough
        case BANDWIDTH:
            if (obj instanceof EndpointsObj) {
                return P2MPState.RP;
            }
            if (obj instanceof Of) {
                builder.setOf((Of) obj);
                return P2MPState.OF_IN;
            }
        // fallthrough
        case OF_IN:
            if (obj instanceof Lspa) {
                builder.setLspa((Lspa) obj);
                return P2MPState.LSPA_IN;
            }
        // fallthrough
        case LSPA_IN:
            if (obj instanceof Bandwidth) {
                builder.setBandwidth((Bandwidth) obj);
                return P2MPState.BANDWIDTH_IN;
            }
        // fallthrough
        case BANDWIDTH_IN:
            if (obj instanceof Metric) {
                metrics.add(new MetricBuilder().setMetric((Metric) obj).build());
                return P2MPState.BANDWIDTH_IN;
            }
        // fallthrough
        case METRIC_IN:
            if (obj instanceof Iro) {
                builder.setIroBncChoice(new IroCaseBuilder().setIro((Iro) obj).build());
                return P2MPState.IRO_BNC_IN;
            }
            if (obj instanceof BranchNodeList) {
                builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new BranchNodeCaseBuilder().setBranchNodeList((BranchNodeList) obj).build()).build());
                return P2MPState.IRO_BNC_IN;
            }
            if (obj instanceof NonBranchNodeList) {
                builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new NonBranchNodeCaseBuilder().setNonBranchNodeList((NonBranchNodeList) obj).build()).build());
                return P2MPState.IRO_BNC_IN;
            }
        // fallthrough
        case IRO_BNC_IN:
            if (obj instanceof LoadBalancing) {
                builder.setLoadBalancing((LoadBalancing) obj);
                return P2MPState.LOAD_BIN;
            }
        // fallthrough
        case LOAD_BIN:
        case END:
        default:
            return P2MPState.END;
    }
}
Also used : Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro) EndpointRroPairBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.EndpointRroPairBuilder) NonBranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList) NonBranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.NonBranchNodeCaseBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) Srro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.MetricBuilder) Rros(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.Rros) SecondaryReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.SecondaryReportedRouteObjectCaseBuilder) SecondaryReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.SecondaryReportedRouteObjectCaseBuilder) ReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.ReportedRouteObjectCaseBuilder) EndpointRroPair(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.EndpointRroPair) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing) RrosBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.RrosBuilder) BranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeList) NonBranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of) IroCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.iro.bnc.choice.IroCaseBuilder) BncCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.iro.bnc.choice.BncCaseBuilder) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) BranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.BranchNodeCaseBuilder) NonBranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.NonBranchNodeCaseBuilder)

Example 27 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeP2P.

protected void serializeP2P(final ByteBuf buffer, final P2p p2p) {
    serializeObject(p2p.getEndpointsObj(), buffer);
    serializeVendorInformationObjects(p2p.getVendorInformationObject(), buffer);
    if (p2p.getReportedRoute() != null) {
        final ReportedRoute rr = p2p.getReportedRoute();
        if (rr != null) {
            serializeObject(rr.getRro(), buffer);
            serializeObject(rr.getReoptimizationBandwidth(), buffer);
        }
    }
    serializeObject(p2p.getLoadBalancing(), buffer);
    serializeObject(p2p.getLspa(), buffer);
    serializeObject(p2p.getBandwidth(), buffer);
    for (final Metrics m : p2p.nonnullMetrics()) {
        serializeObject(m.getMetric(), buffer);
    }
    serializeObject(p2p.getIro(), buffer);
    serializeObject(p2p.getRro(), buffer);
    serializeObject(p2p.getXro(), buffer);
    serializeObject(p2p.getOf(), buffer);
    serializeObject(p2p.getClassType(), buffer);
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) ReportedRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRoute)

Example 28 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics 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();
}
Also used : Preconditions(com.google.common.base.Preconditions) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec) ArrayList(java.util.ArrayList) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 29 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method parsePath.

protected void parsePath(final PathsBuilder builder, final Queue<Object> objects) {
    final List<Metrics> pathMetrics = new ArrayList<>();
    State state = State.INIT;
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        state = insertObject(state, obj, builder, pathMetrics);
        if (state == State.END) {
            break;
        }
        objects.remove();
    }
    if (!pathMetrics.isEmpty()) {
        builder.setMetrics(pathMetrics);
    }
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) ArrayList(java.util.ArrayList) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)

Example 30 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method serializeSuccess.

private void serializeSuccess(final SuccessCase success, final ByteBuf buffer) {
    if (success == null || success.getSuccess() == null) {
        return;
    }
    for (final Paths p : success.getSuccess().nonnullPaths()) {
        serializeObject(p.getEro(), buffer);
        serializeObject(p.getLspa(), buffer);
        serializeObject(p.getOf(), buffer);
        serializeObject(p.getBandwidth(), buffer);
        for (final Metrics m : p.nonnullMetrics()) {
            serializeObject(m.getMetric(), buffer);
        }
        serializeObject(p.getIro(), buffer);
    }
    serializeVendorInformationObjects(success.getSuccess().getVendorInformationObject(), buffer);
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) Paths(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.Paths)

Aggregations

Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)15 ArrayList (java.util.ArrayList)13 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics)9 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)9 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)7 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)6 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)4 Preconditions (com.google.common.base.Preconditions)3 List (java.util.List)3 Metric (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric)3 ByteBuf (io.netty.buffer.ByteBuf)2 Counter (org.opendaylight.infrautils.metrics.Counter)2 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth)2 Iro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro)2 LoadBalancing (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing)2 MetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder)2 Lspa (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa)2