From: Tom Pantelis Date: Wed, 7 Oct 2015 01:32:08 +0000 (-0400) Subject: Partial revert of https://git.opendaylight.org/gerrit/#/c/27874/ X-Git-Tag: release/beryllium~243 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=464ef2fcb77ab24657056bb1bbfa19c0524624c3 Partial revert of https://git.opendaylight.org/gerrit/#/c/27874/ 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 --- diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java index c15c6c8220..049f1a6814 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java @@ -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 java.util.Collection; 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.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.yang.binding.YangModuleInfo; +import org.osgi.framework.Bundle; 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; @@ -63,13 +68,23 @@ public class ConfigManagerActivator implements BundleActivator { ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker( blankTransactionServiceTracker); + boolean scanResolvedBundlesForModuleInfo = false; + BundleTracker>> 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 - ExtensibleBundleTracker moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, - moduleFactoryTracker); moduleFactoryBundleTracker.open(); - moduleInfoBundleTracker.open(); - // Wrap config registry with JMX notification publishing adapter final JMXNotifierConfigRegistry notifyingConfigRegistry = new JMXNotifierConfigRegistry(configRegistry, configMBeanServer); diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java index 1006513fe9..e22fb4d919 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java @@ -38,30 +38,35 @@ public final class ModuleInfoBundleTracker implements AutoCloseable, private final RefreshingSCPModuleInfoRegistry moduleInfoRegistry; - private final BundleTracker>> bundleTracker; + private BundleTracker>> bundleTracker; 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>> 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() { - bundleTracker.close(); + if(bundleTracker != null) { + bundleTracker.close(); + } } @Override