summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-10-09 18:32:44 -0700
committerAshlee Young <ashlee@onosfw.com>2015-10-09 18:32:44 -0700
commit6a07d2d622eaa06953f3353e39c080984076e8de (patch)
treebfb50a2090fce186c2cc545a400c969bf2ea702b /framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
parente6d71622143ff9b2421a1abbe8434b954b5b1099 (diff)
Updated master to commit id 6ee8aa3e67ce89908a8c93aa9445c6f71a18f986
Change-Id: I94b055ee2f298daf71e2ec794fd0f2495bd8081f
Diffstat (limited to 'framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java')
-rw-r--r--framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
index 5710aced..5ebc812e 100644
--- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
+++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
@@ -16,8 +16,8 @@
package org.onosproject.net.intent.impl;
import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.SetMultimap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -61,7 +61,6 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -91,8 +90,6 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
private final Logger log = getLogger(getClass());
- private final ConcurrentMap<Key, Intent> intents = Maps.newConcurrentMap();
-
private final SetMultimap<LinkKey, Key> intentsByLink =
//TODO this could be slow as a point of synchronization
synchronizedSetMultimap(HashMultimap.<LinkKey, Key>create());
@@ -378,7 +375,12 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
}
// TODO should we recompile on available==true?
- delegate.triggerCompile(intentsByDevice.get(id), available);
+
+ final ImmutableSet<Key> snapshot;
+ synchronized (intentsByDevice) {
+ snapshot = ImmutableSet.copyOf(intentsByDevice.get(id));
+ }
+ delegate.triggerCompile(snapshot, available);
}
}
@@ -415,9 +417,17 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
@Override
public void event(HostEvent event) {
HostId id = event.subject().id();
- HostEvent.Type type = event.type();
- boolean available = (type == HostEvent.Type.HOST_ADDED);
- executorService.execute(new DeviceAvailabilityHandler(id, available));
+ switch (event.type()) {
+ case HOST_ADDED:
+ case HOST_MOVED:
+ case HOST_REMOVED:
+ executorService.execute(new DeviceAvailabilityHandler(id, false));
+ break;
+ case HOST_UPDATED:
+ default:
+ // DO NOTHING
+ break;
+ }
}
}