X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FConfigManagerActivator.java;h=d1c3d767bfebfdf7bc2e72b1a292af464ca0aadf;hp=1d8c3bbc30bff75a5f41d51dd5af2e06ca919dff;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=db89afdefb3cfa4454dfdc6008e1d54d3ede66fb 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 1d8c3bbc30..d1c3d767bf 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -51,6 +51,7 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl @Override public void start(final BundleContext context) { + LOG.info("Config manager starting..."); try { // the inner strategy is backed by thread context cl? final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create(); @@ -58,15 +59,17 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl final BindingContextProvider bindingContextProvider = new BindingContextProvider(); final RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry( - moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, bindingContextProvider, context); + moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, + bindingContextProvider, context); - final ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(context, moduleInfoRegistryWrapper); + final ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker( + moduleInfoRegistryWrapper); // start config registry - final BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver( - context); - this.configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, this.configMBeanServer, - bindingContextProvider); + final BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = + new BundleContextBackedModuleFactoriesResolver(context); + this.configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, + this.configMBeanServer, bindingContextProvider); // track bundles containing factories final BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker( @@ -74,33 +77,29 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker( blankTransactionServiceTracker); - final boolean scanResolvedBundlesForModuleInfo = true; - 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); - } - + BundleTracker>> moduleInfoResolvedBundleTracker = + new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE, + moduleInfoBundleTracker); + ExtensibleBundleTracker moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, + moduleFactoryTracker); moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker); // start extensible tracker moduleFactoryBundleTracker.open(); // Wrap config registry with JMX notification publishing adapter - final JMXNotifierConfigRegistry notifyingConfigRegistry = - new JMXNotifierConfigRegistry(this.configRegistry, this.configMBeanServer); + final JMXNotifierConfigRegistry notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, + this.configMBeanServer); // register config registry to OSGi - final AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class); - final AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class); + final AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, + ClassLoadingStrategy.class); + final AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, + ConfigRegistry.class); // register config registry to jmx - final ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(this.configMBeanServer); + final ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator( + this.configMBeanServer); try { configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry); } catch (final InstanceAlreadyExistsException e) { @@ -109,7 +108,8 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl } // register config registry to jmx - final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(this.configMBeanServer); + final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = + new ConfigRegistryJMXRegistrator(this.configMBeanServer); try { configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry); } catch (final InstanceAlreadyExistsException e) { @@ -119,51 +119,52 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl } // TODO wire directly via moduleInfoBundleTracker - final ServiceTracker serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, - blankTransactionServiceTracker); + final ServiceTracker serviceTracker = new ServiceTracker<>(context, + ModuleFactory.class, blankTransactionServiceTracker); serviceTracker.open(); - final AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class); + final AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, + ConfigSystemService.class); final List list = Arrays.asList(bindingContextProvider, clsReg, - OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker, - configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications, - OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg); + OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker, configRegReg, + configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications, + OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, + configMgrReg); this.autoCloseable = OsgiRegistrationUtil.aggregate(list); context.addBundleListener(this); - } catch(final Exception e) { - LOG.warn("Error starting config manager", e); - } catch(final Error e) { - // Log JVM Error and re-throw. The OSGi container may silently fail the bundle and not always log - // the exception. This has been seen on initial feature install. + } catch (final IllegalStateException e) { LOG.error("Error starting config manager", e); - throw e; } + + LOG.info("Config manager start complete"); } @Override public void stop(final BundleContext context) throws Exception { + LOG.info("Config manager stopping"); context.removeBundleListener(this); this.autoCloseable.close(); } @Override public void bundleChanged(final BundleEvent event) { - if(this.configRegistry == null) { + if (this.configRegistry == null) { return; } - // If the system bundle (id 0) is stopping close the ConfigRegistry so it destroys all modules. On + // If the system bundle (id 0) is stopping close the ConfigRegistry so it + // destroys all modules. On // shutdown the system bundle is stopped first. - if((event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID) && (event.getType() == BundleEvent.STOPPING)) { + if (event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID && event.getType() == BundleEvent.STOPPING) { this.configRegistry.close(); } } @Override public void closeAllConfigModules() { - if(this.configRegistry != null) { + if (this.configRegistry != null) { this.configRegistry.close(); } }