X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2Fosgi%2FConfigPersisterActivator.java;h=787f8b10b077612c544a6efcaad813c304ce0c9f;hb=3cd841f641ebd8e4c3002ad3a61d06d4c276a656;hp=0a48e6c67dc8cc290c2b81a1b0eb67c05ac7c618;hpb=a3ff4b68093e6d675a92159e0efa2525af32d644;p=controller.git diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java index 0a48e6c67d..787f8b10b0 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java @@ -8,13 +8,12 @@ package org.opendaylight.controller.netconf.persist.impl.osgi; +import com.google.common.annotations.VisibleForTesting; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; - import javax.management.MBeanServer; - import org.opendaylight.controller.config.persist.api.ConfigPusher; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; @@ -34,17 +33,15 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.annotations.VisibleForTesting; - public class ConfigPersisterActivator implements BundleActivator { - private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterActivator.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigPersisterActivator.class); private static final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); public static final String MAX_WAIT_FOR_CAPABILITIES_MILLIS_PROPERTY = "maxWaitForCapabilitiesMillis"; private static final long MAX_WAIT_FOR_CAPABILITIES_MILLIS_DEFAULT = TimeUnit.MINUTES.toMillis(2); public static final String CONFLICTING_VERSION_TIMEOUT_MILLIS_PROPERTY = "conflictingVersionTimeoutMillis"; - private static final long CONFLICTING_VERSION_TIMEOUT_MILLIS_DEFAULT = TimeUnit.SECONDS.toMillis(30); + private static final long CONFLICTING_VERSION_TIMEOUT_MILLIS_DEFAULT = TimeUnit.MINUTES.toMillis(1); public static final String NETCONF_CONFIG_PERSISTER = "netconf.config.persister"; @@ -57,7 +54,7 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public void start(final BundleContext context) throws Exception { - logger.debug("ConfigPersister starting"); + LOG.debug("ConfigPersister starting"); this.context = context; autoCloseables = new ArrayList<>(); @@ -68,7 +65,7 @@ public class ConfigPersisterActivator implements BundleActivator { long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider); List configs = persisterAggregator.loadLastConfigs(); long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider); - logger.debug("Following configs will be pushed: {}", configs); + LOG.debug("Following configs will be pushed: {}", configs); InnerCustomizer innerCustomizer = new InnerCustomizer(configs, maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis, persisterAggregator); @@ -117,7 +114,7 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public NetconfOperationProvider addingService(ServiceReference reference) { - logger.trace("Got OuterCustomizer.addingService {}", reference); + LOG.trace("Got OuterCustomizer.addingService {}", reference); // JMX was registered, track config-netconf-connector Filter filter; try { @@ -156,15 +153,15 @@ public class ConfigPersisterActivator implements BundleActivator { @Override public NetconfOperationServiceFactory addingService(ServiceReference reference) { - logger.trace("Got InnerCustomizer.addingService {}", reference); + LOG.trace("Got InnerCustomizer.addingService {}", reference); NetconfOperationServiceFactory service = reference.getBundle().getBundleContext().getService(reference); - logger.debug("Creating new job queue"); + LOG.debug("Creating new job queue"); final ConfigPusherImpl configPusher = new ConfigPusherImpl(service, maxWaitForCapabilitiesMillis, conflictingVersionTimeoutMillis); - logger.debug("Configuration Persister got {}", service); - logger.debug("Context was {}", context); - logger.debug("Registration was {}", registration); + LOG.debug("Configuration Persister got {}", service); + LOG.debug("Context was {}", context); + LOG.debug("Registration was {}", registration); final Thread pushingThread = new Thread(new Runnable() { @Override @@ -173,12 +170,16 @@ public class ConfigPersisterActivator implements BundleActivator { if(configs != null && !configs.isEmpty()) { configPusher.pushConfigs(configs); } - registration = context.registerService(ConfigPusher.class.getName(), configPusher, null); - configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator); + if(context != null) { + registration = context.registerService(ConfigPusher.class.getName(), configPusher, null); + configPusher.process(autoCloseables, platformMBeanServer, persisterAggregator); + } else { + LOG.warn("Unable to process configs as BundleContext is null"); + } } catch (InterruptedException e) { - logger.info("ConfigPusher thread stopped",e); + LOG.info("ConfigPusher thread stopped",e); } - logger.info("Configuration Persister initialization completed."); + LOG.info("Configuration Persister initialization completed."); } }, "config-pusher"); synchronized (autoCloseables) {