Trigger a GC once initial configuration has been pushed
[controller.git] / opendaylight / netconf / config-persister-impl / src / main / java / org / opendaylight / controller / netconf / persist / impl / osgi / ConfigPersisterActivator.java
index 0cc55719e12875ece51220073657867fc3a9c21f..48ae0cb91a132d1cd7bff773df604e2d5ae1c47a 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.netconf.persist.impl.osgi;
 
 import com.google.common.annotations.VisibleForTesting;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
 import org.opendaylight.controller.netconf.persist.impl.ConfigPersisterNotificationHandler;
@@ -61,7 +62,7 @@ public class ConfigPersisterActivator implements BundleActivator {
         long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider);
         List<ConfigSnapshotHolder> configs = persisterAggregator.loadLastConfigs();
         long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider);
-        logger.trace("Following configs will be pushed: {}", configs);
+        logger.debug("Following configs will be pushed: {}", configs);
 
         InnerCustomizer innerCustomizer = new InnerCustomizer(configs, maxWaitForCapabilitiesMillis,
                 conflictingVersionTimeoutMillis, persisterAggregator);
@@ -151,8 +152,23 @@ public class ConfigPersisterActivator implements BundleActivator {
             final Thread pushingThread = new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    configPusher.pushConfigs(configs);
+                    try {
+                        configPusher.pushConfigs(configs);
+                    } catch (NetconfDocumentedException e) {
+                        logger.error("Error pushing configs {}",configs);
+                        throw new IllegalStateException(e);
+                    }
                     logger.info("Configuration Persister initialization completed.");
+
+                    /*
+                     * We have completed initial configuration. At this point
+                     * it is good idea to perform garbage collection to prune
+                     * any garbage we have accumulated during startup.
+                     */
+                    logger.debug("Running post-initialization garbage collection...");
+                    System.gc();
+                    logger.debug("Post-initialization garbage collection completed.");
+
                     ConfigPersisterNotificationHandler jmxNotificationHandler = new ConfigPersisterNotificationHandler(platformMBeanServer, persisterAggregator);
                     synchronized (ConfigPersisterActivator.this) {
                         autoCloseables.add(jmxNotificationHandler);
@@ -162,7 +178,7 @@ public class ConfigPersisterActivator implements BundleActivator {
             synchronized (ConfigPersisterActivator.this) {
                 autoCloseables.add(new AutoCloseable() {
                     @Override
-                    public void close() throws Exception {
+                    public void close() {
                         pushingThread.interrupt();
                     }
                 });