Search in sources :

Example 6 with MetricBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder in project bgpcep by opendaylight.

the class MessagesUtil method buildPath.

private static PathsBuilder buildPath(final ConstrainedPath cpath) {
    final PathsBuilder pathBuilder = new PathsBuilder();
    /* Get ERO from Path Description */
    pathBuilder.setEro(getEro(cpath.getPathDescription()));
    /* Fulfill Computed Metrics if available */
    final ArrayList<Metrics> metrics = new ArrayList<>();
    if (cpath.getMetric() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(IGP_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getMetric().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (cpath.getTeMetric() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(TE_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getTeMetric().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (cpath.getDelay() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(PATH_DELAY)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getDelay().getValue().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (!metrics.isEmpty()) {
        pathBuilder.setMetrics(metrics);
    }
    /* Fulfill Bandwidth and ClassType if set */
    if (cpath.getBandwidth() != null) {
        final BandwidthBuilder bwBuilder = new BandwidthBuilder();
        bwBuilder.setBandwidth(new Bandwidth(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getBandwidth().getValue().floatValue()).array())));
        pathBuilder.setBandwidth(bwBuilder.build());
    }
    if (cpath.getClassType() != null && !cpath.getClassType().equals(Uint8.ZERO)) {
        pathBuilder.setClassType(new ClassTypeBuilder().setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType(cpath.getClassType())).build());
    }
    return pathBuilder;
}
Also used : Collections(java.util.Collections) ArrayList(java.util.ArrayList) PathsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ClassTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassTypeBuilder) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder)

Aggregations

Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)5 MetricBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder)5 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 MetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder)3 Before (org.junit.Before)2 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)2 SimplePCEPExtensionProviderContext (org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext)2 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 Ipv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder)2 EroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder)2 IroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.IroBuilder)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject)2 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder)2 LspaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)1 PCEPMetricObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser)1