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());
}
}
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();
}
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());
}
}
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();
}
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();
}
Aggregations