Configurable update-strategy for clusteredAppConfig
[controller.git] / opendaylight / blueprint / src / main / java / org / opendaylight / controller / blueprint / ext / DataStoreAppConfigMetadata.java
index c83e4e8..7361497 100644 (file)
@@ -93,6 +93,7 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor
     private final String defaultAppConfigFileName;
     private final String appConfigBindingClassName;
     private final String appConfigListKeyValue;
+    private final UpdateStrategy appConfigUpdateStrategy;
     private final AtomicBoolean readingInitialAppConfig = new AtomicBoolean(true);
 
     private volatile BindingContext bindingContext;
@@ -106,12 +107,13 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor
 
     public DataStoreAppConfigMetadata(@Nonnull String id, @Nonnull String appConfigBindingClassName,
             @Nullable String appConfigListKeyValue, @Nullable String defaultAppConfigFileName,
-            @Nullable Element defaultAppConfigElement) {
+            @Nonnull UpdateStrategy updateStrategyValue, @Nullable Element defaultAppConfigElement) {
         super(id);
         this.defaultAppConfigElement = defaultAppConfigElement;
         this.defaultAppConfigFileName = defaultAppConfigFileName;
         this.appConfigBindingClassName = appConfigBindingClassName;
         this.appConfigListKeyValue = appConfigListKeyValue;
+        this.appConfigUpdateStrategy = updateStrategyValue;
     }
 
     @Override
@@ -250,14 +252,18 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor
 
                 if(!setInitialAppConfig(Optional.of(newAppConfig)) &&
                         !Objects.equals(currentAppConfig, newAppConfig)) {
-                    LOG.debug("App config was updated - scheduling container for restart");
+                    LOG.debug("App config was updated");
 
-                    restartContainer();
+                    if(appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
+                        restartContainer();
+                    }
                 }
             } else if(type == ModificationType.DELETE) {
-                LOG.debug("App config was deleted - scheduling container for restart");
+                LOG.debug("App config was deleted");
 
-                restartContainer();
+                if(appConfigUpdateStrategy == UpdateStrategy.RELOAD) {
+                    restartContainer();
+                }
             }
         }
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.