Search in sources :

Example 1 with Backtrace

use of org.onlab.util.Backtrace in project onos by opennetworkinglab.

the class GossipIntentStore method write.

@Override
public void write(IntentData newData) {
    checkNotNull(newData);
    IntentData currentData = currentMap.get(newData.key());
    if (IntentData.isUpdateAcceptable(currentData, newData)) {
        // this always succeeds
        if (newData.state() == PURGE_REQ) {
            if (currentData != null) {
                if (log.isTraceEnabled()) {
                    log.trace("Purging {} in currentMap. {}@{}", newData.key(), newData.state(), newData.version(), new Backtrace());
                }
                currentMap.remove(newData.key(), currentData);
            } else {
                log.info("Gratuitous purge request for intent: {}", newData.key());
            }
        } else {
            if (log.isTraceEnabled()) {
                log.trace("Putting {} in currentMap. {}@{}", newData.key(), newData.state(), newData.version(), new Backtrace());
            }
            currentMap.put(newData.key(), IntentData.copy(newData));
        }
    } else {
        log.debug("Update for {} not acceptable from:\n{}\nto:\n{}", newData.key(), currentData, newData);
    }
    // Remove the intent data from the pending map if the newData is more
    // recent or equal to the existing entry. No matter if it is an acceptable
    // update or not
    Key key = newData.key();
    IntentData existingValue = pendingMap.get(key);
    if (existingValue == null) {
        return;
    }
    if (!existingValue.version().isNewerThan(newData.version())) {
        pendingMap.remove(key, existingValue);
    } else {
        log.debug("{} in pending map was newer, leaving it there", key);
    }
}
Also used : Backtrace(org.onlab.util.Backtrace) IntentData(org.onosproject.net.intent.IntentData) Key(org.onosproject.net.intent.Key)

Aggregations

Backtrace (org.onlab.util.Backtrace)1 IntentData (org.onosproject.net.intent.IntentData)1 Key (org.onosproject.net.intent.Key)1