use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports 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 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports 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.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports in project bgpcep by opendaylight.
the class StatefulPCReportMessageParser method getValidReports.
protected Reports getValidReports(final Queue<Object> objects, final List<Message> errors) {
final ReportsBuilder builder = new ReportsBuilder();
boolean lspViaSR = false;
Object object = objects.remove();
if (object instanceof Srp) {
final Srp srp = (Srp) object;
final Tlvs tlvs = srp.getTlvs();
if (tlvs != null) {
lspViaSR = PSTUtil.isDefaultPST(tlvs.getPathSetupType());
}
builder.setSrp(srp);
object = objects.poll();
}
if (validateLsp(object, lspViaSR, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method reportMissedLsp.
/**
* Reports Missed Lsp when DbVersion doesnt match.
*/
private void reportMissedLsp(final PCCSession session) {
for (long missedLsp = this.syncOptimization.getRemoteLspDbVersionValue().longValue() + 1; missedLsp <= this.syncOptimization.getLocalLspDbVersionValue().longValue(); missedLsp++) {
final Uint32 missed = Uint32.valueOf(missedLsp);
final PlspId plspId = new PlspId(missed);
final PCCTunnel tunnel = this.tunnels.get(plspId);
createLspAndSendReport(missed, tunnel, session, Optional.empty(), NO_SRP);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method makeBeforeBreak.
private static Map<PathKey, Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
// just one path should be reported
final Path path = Iterables.getOnlyElement(rlb.getPath().values());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = path.getLspId();
final List<Path> updatedPaths;
// remove existing tunnel's paths now, as explicit path remove will not come
if (!remove && reportedLspId.getValue().toJava() == 0) {
updatedPaths = new ArrayList<>();
LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
} else {
// check previous report for existing paths
final Collection<Path> prev = previous.nonnullPath().values();
updatedPaths = new ArrayList<>(prev);
LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
for (final Path prevPath : prev) {
// we found reported path in previous reports
if (prevPath.getLspId().getValue().toJava() == 0 || prevPath.getLspId().equals(reportedLspId)) {
LOG.debug("Match on lsp-id {}", prevPath.getLspId().getValue());
// path that was reported previously and does have the same lsp-id, path will be updated
final boolean r = updatedPaths.remove(prevPath);
LOG.trace("Request removed? {}", r);
}
}
}
// if the path does not exist in previous report, add it to path list, it's a new ERO
// only one path will be added
// lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
LOG.trace("Adding new path {} to {}", path, updatedPaths);
updatedPaths.add(path);
if (remove) {
if (reportedLspId.getValue().toJava() == 0) {
// if lsp-id also 0, remove all paths
LOG.debug("Removing all paths.");
updatedPaths.clear();
} else {
// path is marked to be removed
LOG.debug("Removing path {} from {}", path, updatedPaths);
final boolean r = updatedPaths.remove(path);
LOG.trace("Request removed? {}", r);
}
}
LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
return Maps.uniqueIndex(updatedPaths, Path::key);
}
Aggregations