use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class StatefulPCRequestMessageParser method insertP2PObject.
// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
@SuppressWarnings("fallthrough")
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 Lsp) {
builder.addAugmentation(new P2p1Builder().setLsp((Lsp) obj).build());
return P2PState.LSP_IN;
}
// fallthrough
case LSP_IN:
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;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class InitiatedPCInitiateMessageParser method getValidRequest.
protected Requests getValidRequest(final Queue<Object> objects) throws PCEPDeserializerException {
final RequestsBuilder builder = new RequestsBuilder().setSrp(consumeObject(objects, Srp.class)).setLsp(consumeObject(objects, Lsp.class));
final List<Metrics> metrics = new ArrayList<>();
State state = State.INIT;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
state = insertObject(state, obj, builder, metrics);
if (state == State.END) {
break;
}
objects.remove();
}
builder.setMetrics(metrics);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class StatefulPCReportMessageParser method serializeReport.
private void serializeReport(final Reports report, final ByteBuf buffer) {
if (report.getSrp() != null) {
serializeObject(report.getSrp(), buffer);
}
serializeObject(report.getLsp(), buffer);
final Path p = report.getPath();
if (p != null) {
serializeObject(p.getEro(), buffer);
serializeObject(p.getLspa(), buffer);
serializeObject(p.getBandwidth(), buffer);
serializeObject(p.getReoptimizationBandwidth(), buffer);
for (final Metrics m : p.nonnullMetrics()) {
serializeObject(m.getMetric(), buffer);
}
serializeObject(p.getIro(), buffer);
serializeObject(p.getRro(), buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class StatefulPCReportMessageParser method parsePath.
private static void parsePath(final Queue<Object> objects, final PathBuilder builder) {
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 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class PathComputationImpl method computeEro.
@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
VertexKey source = getSourceVertexKey(endpoints);
VertexKey destination = getDestinationVertexKey(endpoints);
if (source == null) {
return null;
}
if (destination == null) {
return null;
}
/* Create new Constraints Object from the request */
PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
/* Determine Path Computation Algorithm according to parameters */
AlgorithmType algoType;
if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
algoType = AlgorithmType.Spf;
} else if (cts.getDelay() == null) {
algoType = AlgorithmType.Cspf;
} else {
algoType = AlgorithmType.Samcra;
}
PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
if (algo == null) {
return null;
}
/*
* Request Path Computation for given source, destination and
* constraints
*/
final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
LOG.info("Computed ERO: {}", cpath.getPathDescription());
/* Check if we got a valid Path and return appropriate ERO */
if (cpath.getStatus() == ComputationStatus.Completed) {
return MessagesUtil.getEro(cpath.getPathDescription());
} else {
return null;
}
}
Aggregations