diff options
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.java | 26 |
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; + } } } |