Brian O'Connor

Fixing bug where WITHDRAWN intents get added to ObjectiveTracker

Change-Id: I4c16fe749ab30fdc4fbb96854cade0c292a3f8da
...@@ -76,6 +76,7 @@ import static org.onlab.util.Tools.groupedThreads; ...@@ -76,6 +76,7 @@ import static org.onlab.util.Tools.groupedThreads;
76 import static org.onlab.util.Tools.isNullOrEmpty; 76 import static org.onlab.util.Tools.isNullOrEmpty;
77 import static org.onosproject.net.LinkKey.linkKey; 77 import static org.onosproject.net.LinkKey.linkKey;
78 import static org.onosproject.net.intent.IntentState.INSTALLED; 78 import static org.onosproject.net.intent.IntentState.INSTALLED;
79 +import static org.onosproject.net.intent.IntentState.INSTALLING;
79 import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; 80 import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED;
80 import static org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED; 81 import static org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED;
81 import static org.slf4j.LoggerFactory.getLogger; 82 import static org.slf4j.LoggerFactory.getLogger;
...@@ -212,13 +213,15 @@ public class ObjectiveTracker implements ObjectiveTrackerService { ...@@ -212,13 +213,15 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
212 Key key = intentData.key(); 213 Key key = intentData.key();
213 Intent intent = intentData.intent(); 214 Intent intent = intentData.intent();
214 boolean isLocal = intentService.isLocal(key); 215 boolean isLocal = intentService.isLocal(key);
216 + boolean isInstalled = intentData.state() == INSTALLING ||
217 + intentData.state() == INSTALLED;
215 List<Intent> installables = intentData.installables(); 218 List<Intent> installables = intentData.installables();
216 219
217 if (log.isTraceEnabled()) { 220 if (log.isTraceEnabled()) {
218 log.trace("intent {}, old: {}, new: {}, installableCount: {}, resourceCount: {}", 221 log.trace("intent {}, old: {}, new: {}, installableCount: {}, resourceCount: {}",
219 key, 222 key,
220 intentsByDevice.values().contains(key), 223 intentsByDevice.values().contains(key),
221 - isLocal, 224 + isLocal && isInstalled,
222 installables.size(), 225 installables.size(),
223 intent.resources().size() + 226 intent.resources().size() +
224 installables.stream() 227 installables.stream()
...@@ -229,7 +232,9 @@ public class ObjectiveTracker implements ObjectiveTrackerService { ...@@ -229,7 +232,9 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
229 log.warn("Intent {} is INSTALLED with no installables", key); 232 log.warn("Intent {} is INSTALLED with no installables", key);
230 } 233 }
231 234
232 - if (isLocal) { 235 + // FIXME Intents will be added 3 times (once directly using addTracked,
236 + // then when installing and when installed)
237 + if (isLocal && isInstalled) {
233 addTrackedResources(key, intent.resources()); 238 addTrackedResources(key, intent.resources());
234 for (Intent installable : installables) { 239 for (Intent installable : installables) {
235 addTrackedResources(key, installable.resources()); 240 addTrackedResources(key, installable.resources());
......