Partial revert of https://git.opendaylight.org/gerrit/#/c/27874/ 67/28067/2
authorTom Pantelis <tpanteli@brocade.com>
Wed, 7 Oct 2015 01:32:08 +0000 (21:32 -0400)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 8 Oct 2015 17:42:42 +0000 (17:42 +0000)
Patch https://git.opendaylight.org/gerrit/#/c/27874/ made improvements
that significantly sped up config system boot and helped the SFC project
but a couple other projects are seeing a timing issue where a
ModuleFactory isn't found and the config pusher fails. This is due to
the speed up and that YangModuleInfo's are now scraped from RESOLVED bundles
and thus are available quicker but ModuleFactory's are scaped from
ACTIVE bundles.

While the ModuleFactory issue is addressed, I'll partially revert the
prior changes to go back to scanning ACTIVE bundles for YangModuleInfo.

Change-Id: Icd3a51a049a940ad60a4bd0071e3c969167275d3
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java

index c15c6c82203458e0284ca30e088e1f029d76faa6..049f1a6814a288b056f40cf2e29ffe723f5c04a5 100644 (file)
@@ -11,6 +11,7 @@ import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrat
 import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.wrap;
 import java.lang.management.ManagementFactory;
 import java.util.Arrays;
 import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.wrap;
 import java.lang.management.ManagementFactory;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
 import java.util.List;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
@@ -23,10 +24,14 @@ import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBu
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
 import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
 import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil;
 import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.BundleTracker;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,13 +68,23 @@ public class ConfigManagerActivator implements BundleActivator {
             ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
                     blankTransactionServiceTracker);
 
             ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
                     blankTransactionServiceTracker);
 
+            boolean scanResolvedBundlesForModuleInfo = false;
+            BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = null;
+            ExtensibleBundleTracker<?> moduleFactoryBundleTracker;
+            if(scanResolvedBundlesForModuleInfo) {
+                moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING |
+                            Bundle.STOPPING | Bundle.ACTIVE, moduleInfoBundleTracker);
+                moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, moduleFactoryTracker);
+            } else {
+                moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
+                        moduleFactoryTracker, moduleInfoBundleTracker);
+            }
+
+            moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker);
+
             // start extensible tracker
             // start extensible tracker
-            ExtensibleBundleTracker<?> moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
-                    moduleFactoryTracker);
             moduleFactoryBundleTracker.open();
 
             moduleFactoryBundleTracker.open();
 
-            moduleInfoBundleTracker.open();
-
             // Wrap config registry with JMX notification publishing adapter
             final JMXNotifierConfigRegistry notifyingConfigRegistry =
                     new JMXNotifierConfigRegistry(configRegistry, configMBeanServer);
             // Wrap config registry with JMX notification publishing adapter
             final JMXNotifierConfigRegistry notifyingConfigRegistry =
                     new JMXNotifierConfigRegistry(configRegistry, configMBeanServer);
index 1006513fe9bcf7efeff49074f57ac8f4256b8407..e22fb4d919615becd5ed7d80c48396731be90622 100644 (file)
@@ -38,30 +38,35 @@ public final class ModuleInfoBundleTracker implements AutoCloseable,
 
 
     private final RefreshingSCPModuleInfoRegistry moduleInfoRegistry;
 
 
     private final RefreshingSCPModuleInfoRegistry moduleInfoRegistry;
-    private final BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker;
+    private BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker;
     private boolean starting;
 
     public ModuleInfoBundleTracker(BundleContext context, RefreshingSCPModuleInfoRegistry moduleInfoRegistry) {
         this.moduleInfoRegistry = moduleInfoRegistry;
     private boolean starting;
 
     public ModuleInfoBundleTracker(BundleContext context, RefreshingSCPModuleInfoRegistry moduleInfoRegistry) {
         this.moduleInfoRegistry = moduleInfoRegistry;
-        bundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING |
-                Bundle.STOPPING | Bundle.ACTIVE, this);
     }
 
     }
 
-    public void open() {
-        LOG.debug("ModuleInfoBundleTracker open starting");
+    public void open(BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker) {
+        LOG.debug("ModuleInfoBundleTracker open starting with bundleTracker {}", bundleTracker);
 
 
-        starting = true;
-        bundleTracker.open();
+        if(bundleTracker != null) {
+            this.bundleTracker = bundleTracker;
+            starting = true;
+            bundleTracker.open();
 
 
-        starting = false;
-        moduleInfoRegistry.updateService();
+            starting = false;
+            moduleInfoRegistry.updateService();
+        } else {
+            starting = false;
+        }
 
         LOG.debug("ModuleInfoBundleTracker open complete");
     }
 
     @Override
     public void close() {
 
         LOG.debug("ModuleInfoBundleTracker open complete");
     }
 
     @Override
     public void close() {
-        bundleTracker.close();
+        if(bundleTracker != null) {
+            bundleTracker.close();
+        }
     }
 
     @Override
     }
 
     @Override