use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PcRptMessageCodec method getValidReports.
@Override
protected Reports getValidReports(final List<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 StatefulPCUpdateRequestMessageParser method getValidUpdates.
protected Updates getValidUpdates(final Queue<Object> objects, final List<Message> errors) {
final UpdatesBuilder builder = new UpdatesBuilder();
Object object = objects.remove();
if (object instanceof Srp) {
builder.setSrp((Srp) object);
object = objects.poll();
} else {
errors.add(createErrorMsg(PCEPErrors.SRP_MISSING, Optional.empty()));
}
if (validateLsp(object, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class StatefulPCUpdateRequestMessageParser method validatePath.
private static boolean validatePath(final Queue<Object> objects, final List<Message> errors, final UpdatesBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove();
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.empty()));
return false;
}
parsePath(objects, pBuilder);
builder.setPath(pBuilder.build());
return true;
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class StatefulPCUpdateRequestMessageParser method parsePath.
private static void parsePath(final Queue<Object> objects, final PathBuilder pathBuilder) {
final List<Metrics> pathMetrics = new ArrayList<>();
State state = State.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertObject(state, obj, pathBuilder, pathMetrics);
if (state == State.END) {
break;
}
objects.remove();
}
if (!pathMetrics.isEmpty()) {
pathBuilder.setMetrics(pathMetrics);
}
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPMonitoringReplyMessageParser method validate.
@Override
protected Message validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object monitoring = objects.poll();
if (monitoring == null) {
throw new PCEPDeserializerException("Pcmonrep message cannot be empty.");
}
if (!(monitoring instanceof Monitoring)) {
errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.empty()));
return null;
}
final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder().setMonitoring((Monitoring) monitoring);
final Object obj = objects.peek();
if (obj instanceof PccIdReq) {
builder.setPccIdReq((PccIdReq) obj);
objects.remove();
}
validateSpecificMetrics(objects, builder);
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build();
}
Aggregations