use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics 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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics 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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics in project bgpcep by opendaylight.
the class PCEPMonitoringReplyMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
checkArgument(message instanceof Pcmonrep, "Wrong instance of Message. Passed instance of %s. Need Pcmonrep.", message.getClass());
final PcmonrepMessage monRepMsg = ((Pcmonrep) message).getPcmonrepMessage();
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();
for (final MetricPce metricPce : gml.nonnullMetricPce()) {
serializeMetricPce(metricPce, body);
}
} else if (monRepMsg.getMonitoringMetricsList() instanceof SpecificMetricsList) {
final SpecificMetricsList sml = (SpecificMetricsList) monRepMsg.getMonitoringMetricsList();
for (final SpecificMetrics specificMetrics : sml.nonnullSpecificMetrics()) {
serializeObject(specificMetrics.getRp(), body);
for (final MetricPce metricPce : specificMetrics.nonnullMetricPce()) {
serializeMetricPce(metricPce, body);
}
}
}
MessageUtil.formatMessage(TYPE, body, buffer);
}
Aggregations