Skip to content

Commit

Permalink
Merge pull request apache#405 from mreutegg/OAK-9609
Browse files Browse the repository at this point in the history
OAK-9609: Override persistentCacheIncludes with framework property
  • Loading branch information
mreutegg authored Nov 2, 2021
2 parents aa52568 + f6ba312 commit 2c3ce07
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions oak-doc/src/site/markdown/osgi_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ journalGCMaxAge | 86400000 (24 hrs, was 6 hrs until 1.7.4) | Journal entries old
journalGCInterval | 300000 (5 min) | The interval in milliseconds with which the journal garbage collector removes old journal entries. | 1.0.19, 1.2.3, 1.4
blobCacheSize | 16 (MB) | DocumentNodeStore when running with Mongo will use `MongoBlobStore` by default unless a custom `BlobStore` is configured. In such scenario the size of in memory cache for the frequently used blobs can be configured via `blobCacheSize`. | 1.0
persistentCache | "cache,binary=0" (prior to 1.6, the persistent cache was disabled by default) | The [persistent cache][persistent-cache], which is stored in the local file system. | 1.0.8
persistentCacheIncludes | \["/"\] | List of paths defining the subtrees that are cached. | 1.8.0
<a name="cache-allocation"></a> nodeCachePercentage | 35 (was 25 until 1.5.14) | Percentage of `cache` allocated for `nodeCache`. See [Caching][doc-cache] | 1.0.12
prevDocCachePercentage | 4 | Percentage of `cache` allocated for `prevDocCache`. See [Caching][doc-cache] | 1.3.15
childrenCachePercentage | 15 (was 10 until 1.5.14) | Percentage of `cache` allocated for `childrenCache`. See [Caching][doc-cache] | 1.0.12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@

@AttributeDefinition(
name = "Persistent Cache Includes",
description = "Paths which should be cached in persistent cache")
description = "Paths which should be cached in persistent cache. " +
"This value can be overridden with a system property " +
"'oak.documentstore.persistentCacheIncludes' where paths " +
"are separated with '::'. Example: -Doak.documentstore.persistentCacheIncludes=/content::/var")
String[] persistentCacheIncludes() default {"/"};

@AttributeDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private Object tryCoerce(String value, Class<?> type, Object defaultValue) {
}
} else if (type == String.class) {
obj = value;
} else if (type == String[].class) {
obj = String.valueOf(value).split("::");
} else {
obj = defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.ComponentContext;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -138,6 +142,19 @@ public void presetResetToDefault() throws Exception {
assertEquals(DocumentNodeStoreService.DEFAULT_DB, config.db());
}

@Test
public void overridePersistentCacheIncludes() throws Exception {
BundleContext bundleContext = Mockito.mock(BundleContext.class);
Mockito.when(bundleContext.getProperty("oak.documentstore.persistentCacheIncludes")).thenReturn("/foo::/bar");
ComponentContext componentContext = Mockito.mock(ComponentContext.class);
Mockito.when(componentContext.getBundleContext()).thenReturn(bundleContext);
Configuration config = DocumentNodeStoreServiceConfiguration.create(
componentContext, configAdmin,
preset.asConfiguration(),
configuration.asConfiguration());
assertArrayEquals(new String[]{"/foo", "/bar"}, config.persistentCacheIncludes());
}

private Configuration createConfiguration() throws IOException {
return DocumentNodeStoreServiceConfiguration.create(
context.componentContext(), configAdmin,
Expand Down

0 comments on commit 2c3ce07

Please sign in to comment.