use of org.onosproject.gnmi.api.GnmiUpdate in project onos by opennetworkinglab.
the class GnmiDeviceStateSubscriber method handleGnmiUpdate.
private void handleGnmiUpdate(GnmiUpdate eventSubject) {
Notification notification = eventSubject.update();
if (notification == null) {
log.warn("Cannot handle gNMI event without update data, abort");
log.debug("gNMI update:\n{}", eventSubject);
return;
}
long lastChange = 0;
Update statusUpdate = null;
Path path;
PathElem lastElem;
// to put in place the aggregation logic in ONOS
for (Update update : notification.getUpdateList()) {
path = update.getPath();
lastElem = path.getElem(path.getElemCount() - 1);
// Use last element to identify which state updated
if ("oper-status".equals(lastElem.getName())) {
statusUpdate = update;
} else if ("last-change".equals(lastElem.getName())) {
lastChange = update.getVal().getUintVal();
} else if (log.isDebugEnabled()) {
log.debug("Unrecognized update {}", GnmiUtils.pathToString(path));
}
}
// Cannot proceed without the status update.
if (statusUpdate != null) {
handleOperStatusUpdate(eventSubject.deviceId(), statusUpdate, lastChange);
}
}
Aggregations