summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution/src/main/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-11-03 18:04:26 +0100
committerMaros Marsalek <mmarsale@cisco.com>2016-11-07 11:44:20 +0100
commit5fd09f98a9fde773b275c2266f39552cda861713 (patch)
tree305ca556bb3c8d9363b0866a3aa8ae62f1b262f1 /infra/minimal-distribution/src/main/java
parentd1d66b15ba9cb373dc79c72981bb738f6360b4f5 (diff)
Make persistence optional
Change-Id: I9db2d9705abeb27be0fb0c71229386b1943dcaf9 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/minimal-distribution/src/main/java')
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java11
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java19
2 files changed, 28 insertions, 2 deletions
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java
index 8c09c7b71..cc46f7b8e 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java
@@ -55,10 +55,21 @@ public class HoneycombConfiguration {
return isNetconfTcpEnabled() || isNetconfSshEnabled();
}
+ public boolean isConfigPersistenceEnabled() {
+ return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get());
+ }
+ public boolean isContextPersistenceEnabled() {
+ return persistContext.isPresent() && Boolean.valueOf(persistContext.get());
+ }
+
+ @InjectConfig("persist-context")
+ public Optional<String> persistContext = Optional.of("true");
@InjectConfig("persisted-context-path")
public String peristContextPath;
@InjectConfig("persisted-context-restoration-type")
public String persistedContextRestorationType;
+ @InjectConfig("persist-config")
+ public Optional<String> persistConfig = Optional.of("true");
@InjectConfig("persisted-config-path")
public String peristConfigPath;
@InjectConfig("persisted-config-restoration-type")
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java
index fb4ebc69d..e7a654c7d 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.java
@@ -34,8 +34,10 @@ public abstract class PersistingDataTreeProvider extends ProviderTrait<DataTree>
@Inject
protected HoneycombConfiguration config;
- public PersistingDataTreeAdapter create() {
- return new PersistingDataTreeAdapter(getDelegate(), schemaService, Paths.get(getPath()));
+ public DataTree create() {
+ return isEnabled()
+ ? new PersistingDataTreeAdapter(getDelegate(), schemaService, Paths.get(getPath()))
+ : getDelegate();
}
public abstract String getPath();
@@ -44,6 +46,8 @@ public abstract class PersistingDataTreeProvider extends ProviderTrait<DataTree>
public abstract DataTree getDelegate();
+ protected abstract boolean isEnabled();
+
public static final class ConfigPersistingDataTreeProvider extends PersistingDataTreeProvider {
@Inject
@@ -61,6 +65,11 @@ public abstract class PersistingDataTreeProvider extends ProviderTrait<DataTree>
public DataTree getDelegate() {
return delegate;
}
+
+ @Override
+ protected boolean isEnabled() {
+ return config.isConfigPersistenceEnabled();
+ }
}
public static final class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider {
@@ -80,5 +89,11 @@ public abstract class PersistingDataTreeProvider extends ProviderTrait<DataTree>
public DataTree getDelegate() {
return delegate;
}
+
+ @Override
+ protected boolean isEnabled() {
+ return config.isContextPersistenceEnabled();
+ }
+
}
}