diff options
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", |