use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method handleEros.
private Result handleEros(final Queue<Object> objects) {
final SuccessBuilder builder = new SuccessBuilder();
final List<Paths> paths = new ArrayList<>();
for (Object obj = objects.peek(); obj != null && !(obj instanceof PceId); obj = objects.peek()) {
final PathsBuilder pBuilder = new PathsBuilder();
if (obj instanceof Ero) {
pBuilder.setEro((Ero) obj);
objects.remove();
}
final List<VendorInformationObject> vendorInfoObjects = addVendorInformationObjects(objects);
if (!vendorInfoObjects.isEmpty()) {
builder.setVendorInformationObject(vendorInfoObjects);
}
this.parsePath(pBuilder, objects);
paths.add(pBuilder.build());
}
builder.setPaths(paths);
return new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method getValidReply.
protected Replies getValidReply(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Object obj = objects.remove();
if (!(obj instanceof Rp)) {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
return null;
}
final RepliesBuilder repliesBuilder = new RepliesBuilder().setRp((Rp) obj);
obj = objects.peek();
if (obj instanceof Monitoring) {
repliesBuilder.setMonitoring((Monitoring) obj);
objects.remove();
obj = objects.peek();
}
if (obj instanceof PccIdReq) {
repliesBuilder.setPccIdReq((PccIdReq) obj);
objects.remove();
// last option, no need to peek
}
// note: this may modify 'objects'
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
repliesBuilder.setVendorInformationObject(vendorInfo);
}
final Result res;
obj = objects.peek();
if (obj instanceof NoPath) {
objects.remove();
res = handleNoPath((NoPath) obj, objects);
} else if (obj instanceof Ero) {
res = handleEros(objects);
} else {
res = null;
}
if (objects.peek() instanceof PceId) {
final List<MetricPce> metricPceList = new ArrayList<>();
while (!objects.isEmpty()) {
metricPceList.add(Util.validateMonitoringMetrics(objects));
}
if (!metricPceList.isEmpty()) {
repliesBuilder.setMetricPce(metricPceList);
}
}
return repliesBuilder.setResult(res).build();
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method parsePath.
protected void parsePath(final PathsBuilder builder, final Queue<Object> objects) {
final List<Metrics> pathMetrics = new ArrayList<>();
State state = State.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertObject(state, obj, builder, pathMetrics);
if (state == State.END) {
break;
}
objects.remove();
}
if (!pathMetrics.isEmpty()) {
builder.setMetrics(pathMetrics);
}
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPSecondaryRecordRouteObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Srro, "Wrong instance of PCEPObject. Passed %s. Needed EroObject.", object.getClass());
final Srro sero = (Srro) 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.reported.route.object.rro.SubobjectBuilder().setSubobjectType(so.getSubobjectType()).setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).build()).collect(Collectors.toList());
serializeSubobject(subObjects, body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method insertP2PObject.
// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
private static P2PState insertP2PObject(final P2PState p2PState, final Queue<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.element();
switch(p2PState) {
case INIT:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
objects.remove();
// FIXME: should we guard against empty objects?
final Object nextObj = objects.element();
if (nextObj instanceof ReoptimizationBandwidth) {
builder.setReoptimizationBandwidth((ReoptimizationBandwidth) nextObj);
}
return P2PState.REPORTED_IN;
}
// fallthrough
case REPORTED_IN:
if (obj instanceof VendorInformationObject) {
viObjects.add((VendorInformationObject) obj);
return P2PState.REPORTED_IN;
}
// fallthrough
case VENDOR_INFO_LIST:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return P2PState.LOAD_BIN;
}
// fallthrough
case LOAD_BIN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return P2PState.LSPA_IN;
}
// fallthrough
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIro((Iro) obj);
return P2PState.IRO_IN;
}
// fallthrough
case IRO_IN:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
return P2PState.RRO_IN;
}
// fallthrough
case RRO_IN:
if (obj instanceof Xro) {
builder.setXro((Xro) obj);
return P2PState.XRO_IN;
}
// fallthrough
case XRO_IN:
if (obj instanceof Of) {
builder.setOf((Of) obj);
return P2PState.OF_IN;
}
// fallthrough
case OF_IN:
if (obj instanceof ClassType) {
final ClassType classType = (ClassType) obj;
if (!classType.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
} else {
builder.setClassType(classType);
}
return P2PState.CT_IN;
}
// fallthrough
case CT_IN:
case END:
return P2PState.END;
default:
return p2PState;
}
}
Aggregations