Author: chetanm
Date: Tue Jun 21 06:22:10 2016
New Revision: 1749447
URL: http://svn.apache.org/viewvc?rev=1749447&view=rev
Log:
OAK-4180 - Use another NodeStore as a local cache for a remote Document store
Expose the default BlobStore to OSGi service registry such that secondary
NodeStore can make use of them. This is only required is customBlobStore is
false
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.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/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=1749447&r1=1749446&r2=1749447&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
Tue Jun 21 06:22:10 2016
@@ -351,6 +351,10 @@ public class DocumentNodeStoreService {
private DocumentNodeStore documentNodeStore;
+ private ServiceRegistration blobStoreReg;
+
+ private BlobStore defaultBlobStore;
+
@Activate
protected void activate(ComponentContext context, Map<String, ?> config)
throws Exception {
this.context = context;
@@ -474,6 +478,13 @@ public class DocumentNodeStoreService {
log.info("Connected to database '{}'", db);
}
+ if (!customBlobStore){
+ defaultBlobStore = mkBuilder.getBlobStore();
+ log.info("Registering the BlobStore with ServiceRegistry");
+ blobStoreReg =
context.getBundleContext().registerService(BlobStore.class.getName(),
+ defaultBlobStore , null);
+ }
+
//Set wrapping blob store after setting the DB
if (wrappingCustomBlobStore) {
((BlobStoreWrapper)
blobStore).setBlobStore(mkBuilder.getBlobStore());
@@ -558,6 +569,9 @@ public class DocumentNodeStoreService {
@SuppressWarnings("UnusedDeclaration")
protected void bindBlobStore(BlobStore blobStore) throws IOException {
+ if (defaultBlobStore == blobStore){
+ return;
+ }
log.info("Initializing DocumentNodeStore with BlobStore [{}]",
blobStore);
this.blobStore = blobStore;
registerNodeStoreIfPossible();
@@ -623,6 +637,15 @@ public class DocumentNodeStoreService {
nodeStoreReg = null;
}
+ //If we exposed our BlobStore then unregister it *after*
+ //NodeStore service. This ensures that if any other component
+ //like SecondaryStoreCache depends on this then it remains active
+ //untill DocumentNodeStore get deactivated
+ if (blobStoreReg != null){
+ blobStoreReg.unregister();
+ blobStoreReg = null;
+ }
+
if (mk != null) {
mk.dispose();
mk = null;
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=1749447&r1=1749446&r2=1749447&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
Tue Jun 21 06:22:10 2016
@@ -260,6 +260,7 @@ class DocumentNodeStoreConfigTest extend
assert getService(BlobStoreStatsMBean.class) : "BlobStoreStatsMBean
should " +
"be registered by DocumentNodeStoreService in default
blobStore used"
+ assert getService(BlobStore.class) : "BlobStore service should be
exposed for default setup"
testBlobStoreStats(ns)
testDocumentStoreStats(ns)
}