diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-11-03 18:04:26 +0100 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-11-07 11:44:20 +0100 |
commit | 5fd09f98a9fde773b275c2266f39552cda861713 (patch) | |
tree | 305ca556bb3c8d9363b0866a3aa8ae62f1b262f1 /infra | |
parent | d1d66b15ba9cb373dc79c72981bb738f6360b4f5 (diff) |
Make persistence optional
Change-Id: I9db2d9705abeb27be0fb0c71229386b1943dcaf9
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra')
3 files changed, 30 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(); + } + } } diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json index 0c35c5262..1199f85bc 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json +++ b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json @@ -1,6 +1,8 @@ { + "persist-context": "true", "persisted-context-path": "/var/lib/honeycomb/persist/context/data.json", "persisted-context-restoration-type": "Merge", + "persist-config": "true", "persisted-config-path": "/var/lib/honeycomb/persist/config/data.json", "persisted-config-restoration-type": "Merge", |