From 047e0a0a712e069ea59c503cbe757392d35974a5 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Mon, 22 Jan 2018 17:43:44 -0500 Subject: [PATCH] CONTROLLER-1809: De-deplicate extraneous ManagedService updates For some strange reason, the ComponentProcessor gets an extraneous duplicate update from the ConfigAdmin when running the netvirt integration/CSIT which causes it to restart the container b/c it thinks there was an update. There is no cfg file so both updates pass a null Properties. Oddly, I do not see this behavior when installing the toaster feature from the controller karaf. I added logic to store the last update and only restart if it changed. In my testing though, the ConfigAdmin does not notify unless a change actually occurred. Change-Id: I692dbd7fcaf921b90f828059d6104138c16a0508 Signed-off-by: Tom Pantelis --- .../controller/blueprint/ext/ComponentProcessor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java index 97f2fd2b0c..84847a14b1 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java @@ -12,6 +12,8 @@ import java.util.ArrayList; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.aries.blueprint.ComponentDefinitionRegistry; import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor; import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder; @@ -133,7 +135,8 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor // Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding // to the persistentId changes. final ManagedService managedService = new ManagedService() { - private volatile boolean initialUpdate = true; + private final AtomicBoolean initialUpdate = new AtomicBoolean(true); + private volatile Dictionary previousProperties; @Override public void updated(final Dictionary properties) { @@ -143,11 +146,11 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor // The first update occurs when the service is registered so ignore it as we want subsequent // updates when it changes. The ConfigAdmin will send an update even if the cfg file doesn't // yet exist. - if (initialUpdate) { - initialUpdate = false; - } else { + if (!initialUpdate.compareAndSet(true, false) && !Objects.equals(previousProperties, properties)) { blueprintContainerRestartService.restartContainerAndDependents(bundle); } + + previousProperties = properties; } }; -- 2.36.6