You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2014/10/29 16:35:04 UTC
svn commit: r1635178 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document:
DocumentMK.java DocumentNodeStoreService.java
Author: thomasm
Date: Wed Oct 29 15:35:03 2014
New Revision: 1635178
URL: http://svn.apache.org/r1635178
Log:
OAK-2191 Persistent cache for the DocumentNodeStore (OSGi config option)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1635178&r1=1635177&r2=1635178&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java Wed Oct 29 15:35:03 2014
@@ -66,7 +66,7 @@ public class DocumentMK implements Micro
/**
* The path where the persistent cache is stored.
*/
- static final String PERSISTENT_CACHE =
+ static final String DEFAULT_PERSISTENT_CACHE_URI =
System.getProperty("oak.documentMK.persCache");
/**
@@ -508,6 +508,7 @@ public class DocumentMK implements Micro
private boolean disableBranches;
private Clock clock = Clock.SIMPLE;
private Executor executor;
+ private String persistentCacheURI = DEFAULT_PERSISTENT_CACHE_URI;
private PersistentCache persistentCache;
public Builder() {
@@ -567,6 +568,16 @@ public class DocumentMK implements Micro
}
return this;
}
+
+ /**
+ * Sets the persistent cache option.
+ *
+ * @return this
+ */
+ public Builder setPersistentCache(String persistentCache) {
+ this.persistentCacheURI = persistentCache;
+ return this;
+ }
/**
* Sets a {@link DataSource}s to use for the RDB document and blob
@@ -846,12 +857,12 @@ public class DocumentMK implements Micro
}
private PersistentCache getPersistentCache() {
- if (PERSISTENT_CACHE == null) {
+ if (persistentCacheURI == null) {
return null;
}
if (persistentCache == null) {
try {
- persistentCache = new PersistentCache(PERSISTENT_CACHE);
+ persistentCache = new PersistentCache(persistentCacheURI);
} catch (Throwable e) {
LOG.warn("Persistent cache not available; please disable the configuration", e);
throw new IllegalArgumentException(e);
@@ -862,7 +873,7 @@ public class DocumentMK implements Micro
private <K extends CacheValue, V extends CacheValue> Cache<K, V> buildCache(
long maxWeight) {
- if (LIRS_CACHE || PERSISTENT_CACHE != null) {
+ if (LIRS_CACHE || persistentCacheURI != null) {
return CacheLIRS.newBuilder().
weigher(weigher).
averageWeight(2000).
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1635178&r1=1635177&r2=1635178&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java Wed Oct 29 15:35:03 2014
@@ -83,6 +83,7 @@ public class DocumentNodeStoreService {
private static final int DEFAULT_CHANGES_SIZE = 256;
private static final int DEFAULT_BLOB_CACHE_SIZE = 16;
private static final String DEFAULT_DB = "oak";
+ private static final String DEFAULT_PERSISTENT_CACHE = "";
private static final String PREFIX = "oak.documentstore.";
/**
@@ -118,6 +119,9 @@ public class DocumentNodeStoreService {
@Property(intValue = DEFAULT_BLOB_CACHE_SIZE)
private static final String PROP_BLOB_CACHE_SIZE = "blobCacheSize";
+
+ @Property(value = DEFAULT_PERSISTENT_CACHE)
+ private static final String PROP_PERSISTENT_CACHE = "persistentCache";
/**
* Boolean value indicating a blobStore is to be used
@@ -238,12 +242,17 @@ public class DocumentNodeStoreService {
int cacheSize = toInteger(prop(PROP_CACHE), DEFAULT_CACHE);
int changesSize = toInteger(prop(PROP_CHANGES_SIZE), DEFAULT_CHANGES_SIZE);
int blobCacheSize = toInteger(prop(PROP_BLOB_CACHE_SIZE), DEFAULT_BLOB_CACHE_SIZE);
+ String persistentCache = PropertiesUtil.toString(prop(PROP_PERSISTENT_CACHE), DEFAULT_PERSISTENT_CACHE);
boolean useMK = toBoolean(context.getProperties().get(PROP_USE_MK), false);
DocumentMK.Builder mkBuilder =
new DocumentMK.Builder().
memoryCacheSize(cacheSize * MB).
offHeapCacheSize(offHeapCache * MB);
+
+ if (persistentCache != null && persistentCache.length() > 0) {
+ mkBuilder.setPersistentCache(persistentCache);
+ }
//Set blobstore before setting the DB
if (customBlobStore) {