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 ch...@apache.org on 2016/10/19 15:11:04 UTC
svn commit: r1765642 - in /jackrabbit/oak/trunk:
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/
oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/
Author: chetanm
Date: Wed Oct 19 15:11:03 2016
New Revision: 1765642
URL: http://svn.apache.org/viewvc?rev=1765642&view=rev
Log:
OAK-1312 - [bundling] Bundle nodes into a document
Provide OSGi config for disabling bundling
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/DocumentNodeStore.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandler.java
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
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=1765642&r1=1765641&r2=1765642&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 19 15:11:03 2016
@@ -583,6 +583,7 @@ public class DocumentMK {
private DocumentNodeStoreStatsCollector nodeStoreStatsCollector;
private Map<CacheType, PersistentCacheStats> persistentCacheStats =
new EnumMap<CacheType, PersistentCacheStats>(CacheType.class);
+ private boolean bundlingEnabled = true;
public Builder() {
}
@@ -1028,6 +1029,15 @@ public class DocumentMK {
return disableBranches;
}
+ public Builder setBundlingEnabled(boolean enabled) {
+ bundlingEnabled = enabled;
+ return this;
+ }
+
+ public boolean isBundlingEnabled() {
+ return bundlingEnabled;
+ }
+
public Builder setPrefetchExternalChanges(boolean b) {
prefetchExternalChanges = b;
return this;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1765642&r1=1765641&r2=1765642&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Wed Oct 19 15:11:03 2016
@@ -420,6 +420,8 @@ public final class DocumentNodeStore
private final BundlingConfigHandler bundlingConfigHandler = new BundlingConfigHandler();
+ private final boolean bundlingEnabled;
+
public DocumentNodeStore(DocumentMK.Builder builder) {
this.blobStore = builder.getBlobStore();
this.statisticsProvider = builder.getStatisticsProvider();
@@ -576,7 +578,10 @@ public final class DocumentNodeStore
LOG.info("Initialized DocumentNodeStore with clusterNodeId: {} ({})", clusterId,
getClusterNodeInfoDisplayString());
- bundlingConfigHandler.initialize(this, executor);
+ bundlingEnabled = builder.isBundlingEnabled();
+ if (bundlingEnabled) {
+ bundlingConfigHandler.initialize(this, executor);
+ }
}
@@ -1125,6 +1130,10 @@ public final class DocumentNodeStore
return bundlingConfigHandler.newBundlingHandler();
}
+ public BundlingConfigHandler getBundlingConfigHandler() {
+ return bundlingConfigHandler;
+ }
+
/**
* Apply the changes of a node to the cache.
*
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=1765642&r1=1765641&r2=1765642&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 19 15:11:03 2016
@@ -82,6 +82,7 @@ import org.apache.jackrabbit.oak.spi.blo
import org.apache.jackrabbit.oak.spi.blob.BlobStoreWrapper;
import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
import org.apache.jackrabbit.oak.spi.blob.stats.BlobStoreStatsMBean;
+import org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean;
import org.apache.jackrabbit.oak.spi.state.Clusterable;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.oak.spi.state.RevisionGC;
@@ -376,6 +377,14 @@ public class DocumentNodeStoreService {
description = "Type of DocumentStore to use for persistence. Defaults to MONGO"
)
public static final String PROP_DS_TYPE = "documentStoreType";
+
+ private static final boolean DEFAULT_BUNDLING_ENABLED = true;
+ @Property(boolValue = DEFAULT_BUNDLING_ENABLED,
+ label = "Bundling Enabled",
+ description = "Boolean value indicating that Node bundling is enabled"
+ )
+ public static final String PROP_BUNDLING_ENABLED = "bundlingEnabled";
+
private DocumentStoreType documentStoreType;
@Reference
@@ -431,6 +440,7 @@ public class DocumentNodeStoreService {
String journalCache = getPath(PROP_JOURNAL_CACHE, DEFAULT_JOURNAL_CACHE);
int cacheSegmentCount = toInteger(prop(PROP_CACHE_SEGMENT_COUNT), DEFAULT_CACHE_SEGMENT_COUNT);
int cacheStackMoveDistance = toInteger(prop(PROP_CACHE_STACK_MOVE_DISTANCE), DEFAULT_CACHE_STACK_MOVE_DISTANCE);
+ boolean bundlingEnabled = toBoolean(prop(PROP_BUNDLING_ENABLED), DEFAULT_BUNDLING_ENABLED);
boolean prefetchExternalChanges = toBoolean(prop(PROP_PREFETCH_EXTERNAL_CHANGES), false);
DocumentMK.Builder mkBuilder =
new DocumentMK.Builder().
@@ -443,6 +453,7 @@ public class DocumentNodeStoreService {
diffCachePercentage).
setCacheSegmentCount(cacheSegmentCount).
setCacheStackMoveDistance(cacheStackMoveDistance).
+ setBundlingEnabled(bundlingEnabled).
setLeaseCheck(true /* OAK-2739: enabled by default */).
setLeaseFailureHandler(new LeaseFailureHandler() {
@@ -830,6 +841,14 @@ public class DocumentNodeStoreService {
BlobStoreStatsMBean.TYPE,
ds.getClass().getSimpleName()));
}
+
+ if (mkBuilder.isBundlingEnabled()){
+ registrations.add(registerMBean(whiteboard,
+ BackgroundObserverMBean.class,
+ store.getBundlingConfigHandler().getMBean(),
+ BackgroundObserverMBean.TYPE,
+ "BundlingConfigObserver"));
+ }
}
private void registerLastRevRecoveryJob(final DocumentNodeStore nodeStore) {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandler.java?rev=1765642&r1=1765641&r2=1765642&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandler.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandler.java Wed Oct 19 15:11:03 2016
@@ -30,21 +30,20 @@ import com.google.common.collect.Iterabl
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.spi.commit.BackgroundObserver;
+import org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.DefaultEditor;
import org.apache.jackrabbit.oak.spi.commit.Editor;
import org.apache.jackrabbit.oak.spi.commit.EditorDiff;
-import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.commit.Observable;
import org.apache.jackrabbit.oak.spi.commit.Observer;
import org.apache.jackrabbit.oak.spi.commit.SubtreeEditor;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
public class BundlingConfigHandler implements Observer, Closeable {
@@ -53,6 +52,7 @@ public class BundlingConfigHandler imple
private NodeState root = EMPTY_NODE;
private BackgroundObserver backgroundObserver;
private Closeable observerRegistration;
+ private boolean enabled;
private volatile BundledTypesRegistry registry = BundledTypesRegistry.NOOP;
@@ -75,6 +75,11 @@ public class BundlingConfigHandler imple
public void initialize(NodeStore nodeStore, Executor executor) {
registerObserver(nodeStore, executor);
+ //If bundling is disabled then initialize would not be invoked
+ //NOOP registry would get used effectively disabling bundling for
+ //new nodes
+ enabled = true;
+ log.info("Bundling of nodes enabled");
}
@Override
@@ -85,6 +90,14 @@ public class BundlingConfigHandler imple
}
}
+ public BackgroundObserverMBean getMBean(){
+ return checkNotNull(backgroundObserver).getMBean();
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
BundledTypesRegistry getRegistry() {
return registry;
}
Modified: jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy?rev=1765642&r1=1765641&r2=1765642&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy Wed Oct 19 15:11:03 2016
@@ -265,6 +265,45 @@ class DocumentNodeStoreConfigTest extend
testDocumentStoreStats(ns)
}
+ @Test
+ public void testBundlingEnabledByDefault() throws Exception {
+ registry = repositoryFactory.initializeServiceRegistry(config)
+
+ //1. Register the DataSource as a service
+ DataSource ds = createDS("jdbc:h2:mem:testRDB;DB_CLOSE_DELAY=-1")
+ registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable)
+
+ //2. Create config for DocumentNodeStore with RDB enabled
+ createConfig([
+ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [
+ documentStoreType: 'RDB'
+ ]
+ ])
+
+ DocumentNodeStore ns = getServiceWithWait(NodeStore.class)
+ assert ns.bundlingConfigHandler.enabled
+ }
+
+ @Test
+ public void testBundlingDisabled() throws Exception {
+ registry = repositoryFactory.initializeServiceRegistry(config)
+
+ //1. Register the DataSource as a service
+ DataSource ds = createDS("jdbc:h2:mem:testRDB;DB_CLOSE_DELAY=-1")
+ registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable)
+
+ //2. Create config for DocumentNodeStore with RDB enabled
+ createConfig([
+ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [
+ documentStoreType: 'RDB',
+ bundlingEnabled : false
+ ]
+ ])
+
+ DocumentNodeStore ns = getServiceWithWait(NodeStore.class)
+ assert !ns.bundlingConfigHandler.enabled
+ }
+
private void testDocumentStoreStats(DocumentNodeStore store) {
DocumentStoreStatsMBean stats = getService(DocumentStoreStatsMBean.class)