use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder 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;
}
Aggregations