use of com.google.storage.v2.Object 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 com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method validate.
@Override
protected PcerrMessage validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final List<Rps> requestParameters = new ArrayList<>();
final List<Errors> errorObjects = new ArrayList<>();
final State initialState;
final Object first = objects.poll();
if (first instanceof ErrorObject) {
errorObjects.add(new ErrorsBuilder().setErrorObject((ErrorObject) first).build());
initialState = State.ERROR_IN;
} else if (first instanceof Rp) {
final Rp rp = (Rp) first;
if (rp.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(rp).build());
initialState = State.RP_IN;
} else if (first == null) {
throw new PCEPDeserializerException("Error message is empty.");
} else {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
final PcerrMessageBuilder msgBuilder = new PcerrMessageBuilder();
State state = initialState;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(msgBuilder.setErrors(((UnknownObject) obj).getErrors()).build()).build();
}
state = insertObject(state, errorObjects, obj, requestParameters, msgBuilder);
if (state == State.END) {
break;
}
objects.remove();
}
if (errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
if (!requestParameters.isEmpty()) {
msgBuilder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
}
return new PcerrBuilder().setPcerrMessage(msgBuilder.setErrors(errorObjects).build()).build();
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPOpenMessageParser method validate.
@Override
protected org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object open = objects.poll();
if (!(open instanceof Open)) {
throw new PCEPDeserializerException("Open message doesn't contain OPEN object.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen((Open) open).build()).build();
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PcRptMessageCodec method getValidReports.
@Override
protected Reports getValidReports(final Queue<Object> objects, final List<Message> errors) {
final Optional<Object> find = Iterables.tryFind(objects, Predicates.instanceOf(BandwidthUsage.class));
final Object object;
if (find.isPresent()) {
object = find.get();
objects.remove(object);
} else {
object = null;
}
final Reports validReports = super.getValidReports(objects, errors);
if (object != null && validReports != null) {
final Path path = validReports.getPath();
if (path != null) {
return new ReportsBuilder(validReports).setPath(new PathBuilder(path).setBandwidth(setBandwidthUsage(path.getBandwidth(), (BandwidthUsage) object)).build()).build();
}
}
return validReports;
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPSecondaryExplicitRouteObjecParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Sero, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
final Sero sero = (Sero) object;
final ByteBuf body = Unpooled.buffer();
final List<Subobject> subObjects = sero.nonnullSubobject().stream().map(so -> new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(so.getLoose()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList());
serializeSubobject(subObjects, body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Aggregations