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/06/29 06:26:19 UTC

svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Author: chetanm
Date: Wed Jun 29 06:26:19 2016
New Revision: 1750601

URL: http://svn.apache.org/viewvc?rev=1750601&view=rev
Log:
OAK-4490 - Expose SegmentNodeStore as a secondary NodeStore

Exposes a barebone SegmentNodeStore. This instance is not listening for observor etc and not directly exposed as a NodeStore but instance exposed via NodeStoreProvider

Modified:
    jackrabbit/oak/trunk/oak-segment-tar/pom.xml
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
    jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java

Modified: jackrabbit/oak/trunk/oak-segment-tar/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/pom.xml?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/pom.xml Wed Jun 29 06:26:19 2016
@@ -34,7 +34,7 @@
     <name>Oak Segment Tar</name>
 
     <properties>
-        <oak.version>1.5.3</oak.version>
+        <oak.version>1.6-SNAPSHOT</oak.version>
     </properties>
 
     <scm>

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java Wed Jun 29 06:26:19 2016
@@ -81,6 +81,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
 import org.apache.jackrabbit.oak.spi.state.RevisionGC;
 import org.apache.jackrabbit.oak.spi.state.RevisionGCMBean;
@@ -196,6 +197,13 @@ public class SegmentNodeStoreService ext
     )
     public static final String STANDBY = "standby";
 
+    @Property(
+            boolValue = false,
+            label = "Secondary Store Mode",
+            description = "Flag indicating that this component will not register as a NodeStore but just as a SecondaryNodeStoreProvider"
+    )
+    public static final String SECONDARY_STORE = "secondary";
+
     @Property(boolValue = false,
             label = "Custom BlobStore",
             description = "Boolean value indicating that a custom BlobStore is to be used. " +
@@ -308,6 +316,11 @@ public class SegmentNodeStoreService ext
                 return;
             }
 
+            if (toBoolean(property(SECONDARY_STORE), false)){
+                registerSecondaryStore();
+                return;
+            }
+
             if (registerSegmentNodeStore()) {
                 Dictionary<String, Object> props = new Hashtable<String, Object>();
                 props.put(Constants.SERVICE_PID, SegmentNodeStore.class.getName());
@@ -317,6 +330,20 @@ public class SegmentNodeStoreService ext
         }
     }
 
+    private void registerSecondaryStore() {
+        segmentNodeStore = SegmentNodeStoreBuilders.builder(store).build();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(NodeStoreProvider.ROLE, "secondary");
+        storeRegistration = context.getBundleContext().registerService(NodeStoreProvider.class.getName(), new NodeStoreProvider() {
+                    @Override
+                    public NodeStore getNodeStore() {
+                        return SegmentNodeStoreService.this;
+                    }
+                },
+                props);
+        log.info("Registered NodeStoreProvider backed by SegmentNodeStore");
+    }
+
     private boolean registerSegmentStore() throws IOException {
         if (context == null) {
             log.info("Component still not activated. Ignoring the initialization call");

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java Wed Jun 29 06:26:19 2016
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
@@ -140,6 +141,17 @@ public class SegmentNodeStoreServiceTest
         unregisterSegmentNodeStoreService();
     }
 
+    @Test
+    public void nodeStoreProvider() throws Exception{
+        Map<String, Object> properties = newHashMap();
+        properties.put(SegmentNodeStoreService.SECONDARY_STORE, true);
+        properties.put(SegmentNodeStoreService.DIRECTORY, folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreService = context.registerInjectActivateService(new SegmentNodeStoreService(), properties);
+        assertNull(context.getService(NodeStore.class));
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
     private SegmentNodeStoreService segmentNodeStoreService;
 
     private void registerSegmentNodeStoreService(boolean customBlobStore) {

Modified: jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Wed Jun 29 06:26:19 2016
@@ -86,6 +86,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
 import org.apache.jackrabbit.oak.spi.state.RevisionGC;
 import org.apache.jackrabbit.oak.spi.state.RevisionGCMBean;
@@ -237,6 +238,13 @@ public class SegmentNodeStoreService ext
     )
     public static final String STANDBY = "standby";
 
+    @Property(
+            boolValue = false,
+            label = "Secondary Store Mode",
+            description = "Flag indicating that this component will not register as a NodeStore but just as a SecondaryNodeStoreProvider"
+    )
+    public static final String SECONDARY_STORE = "secondary";
+
     @Property(boolValue = false,
             label = "Custom BlobStore",
             description = "Boolean value indicating that a custom BlobStore is to be used. " +
@@ -351,6 +359,11 @@ public class SegmentNodeStoreService ext
                 return;
             }
 
+            if (toBoolean(property(SECONDARY_STORE), false)){
+                registerSecondaryStore();
+                return;
+            }
+
             if (registerSegmentNodeStore()) {
                 Dictionary<String, Object> props = new Hashtable<String, Object>();
                 props.put(Constants.SERVICE_PID, SegmentNodeStore.class.getName());
@@ -360,6 +373,22 @@ public class SegmentNodeStoreService ext
         }
     }
 
+    private void registerSecondaryStore() {
+        SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder = SegmentNodeStore.builder(store);
+        nodeStoreBuilder.withCompactionStrategy(compactionStrategy);
+        segmentNodeStore = nodeStoreBuilder.build();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(NodeStoreProvider.ROLE, "secondary");
+        storeRegistration = context.getBundleContext().registerService(NodeStoreProvider.class.getName(), new NodeStoreProvider() {
+                    @Override
+                    public NodeStore getNodeStore() {
+                        return SegmentNodeStoreService.this;
+                    }
+                },
+                props);
+        log.info("Registered NodeStoreProvider backed by SegmentNodeStore");
+    }
+
     private boolean registerSegmentStore() throws IOException {
         if (context == null) {
             log.info("Component still not activated. Ignoring the initialization call");

Modified: jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java (original)
+++ jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java Wed Jun 29 06:26:19 2016
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
@@ -140,6 +141,17 @@ public class SegmentNodeStoreServiceTest
         unregisterSegmentNodeStoreService();
     }
 
+    @Test
+    public void nodeStoreProvider() throws Exception{
+        Map<String, Object> properties = newHashMap();
+        properties.put(SegmentNodeStoreService.SECONDARY_STORE, true);
+        properties.put(SegmentNodeStoreService.DIRECTORY, folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreService = context.registerInjectActivateService(new SegmentNodeStoreService(), properties);
+        assertNull(context.getService(NodeStore.class));
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
     private SegmentNodeStoreService segmentNodeStoreService;
 
     private void registerSegmentNodeStoreService(boolean customBlobStore) {



Re: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Posted by Francesco Mari <ma...@gmail.com>.
Thanks a lot for your understanding!

2016-06-29 10:43 GMT+02:00 Chetan Mehrotra <ch...@gmail.com>:

> On Wed, Jun 29, 2016 at 1:25 PM, Francesco Mari
> <ma...@gmail.com> wrote:
> > oak-segment-tar should be releasable at any time. If I had to launch a
> quick patch release this morning, I would have to either revert your commit
> or postpone my release until Oak is released.
>
> Given the current release frequency on trunk (2 week) I do not think
> it should be a big problem and holding of commits break the continuity
> and increases work. But then that might be just an issue for me!
>
> For now I have reverted the changes from oak-segment-tar
>
> Chetan Mehrotra
>

Re: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Wed, Jun 29, 2016 at 1:25 PM, Francesco Mari
<ma...@gmail.com> wrote:
> oak-segment-tar should be releasable at any time. If I had to launch a
quick patch release this morning, I would have to either revert your commit
or postpone my release until Oak is released.

Given the current release frequency on trunk (2 week) I do not think
it should be a big problem and holding of commits break the continuity
and increases work. But then that might be just an issue for me!

For now I have reverted the changes from oak-segment-tar

Chetan Mehrotra

Re: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Posted by Francesco Mari <ma...@gmail.com>.
The rationale behind this is that we put a lot of effort in making
oak-segment-tar independent from the release process of Oak and I want to
keep it this way.

oak-segment-tar should be releasable at any time. If I had to launch a
quick patch release this morning, I would have to either revert your commit
or postpone my release until Oak is released.

Please don't let Oak impact the way we decided to manage oak-segment-tar.
On Jun 29, 2016 9:25 AM, "Chetan Mehrotra" <ch...@gmail.com>
wrote:

> Hi Francesco,
>
> On Wed, Jun 29, 2016 at 12:49 PM, Francesco Mari
> <ma...@gmail.com> wrote:
> > Please do not change the "oak.version" property to a snapshot version. If
> > your change relies on code that is only available in the latest snapshot
> of
> > Oak, please revert this commit and hold it back until a proper release of
> > Oak is performed.
>
> I can do that but want to understand the impact here if we switched to
> SNAPSHOT version?
>
> For e.g. in the past we had done some changes in jackrabbit which is
> need in oak then we had switched to snapshot version of JR2 and later
> reverted to released version once JR2 release is done. That has worked
> fine so far and we did not had to hold the feature work for that. So
> want to understand why it should be different here
>
> Chetan Mehrotra
>

Re: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Posted by Chetan Mehrotra <ch...@gmail.com>.
Hi Francesco,

On Wed, Jun 29, 2016 at 12:49 PM, Francesco Mari
<ma...@gmail.com> wrote:
> Please do not change the "oak.version" property to a snapshot version. If
> your change relies on code that is only available in the latest snapshot of
> Oak, please revert this commit and hold it back until a proper release of
> Oak is performed.

I can do that but want to understand the impact here if we switched to
SNAPSHOT version?

For e.g. in the past we had done some changes in jackrabbit which is
need in oak then we had switched to snapshot version of JR2 and later
reverted to released version once JR2 release is done. That has worked
fine so far and we did not had to hold the feature work for that. So
want to understand why it should be different here

Chetan Mehrotra

Fwd: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...

Posted by Francesco Mari <ma...@gmail.com>.
Hi Chetan,

Please do not change the "oak.version" property to a snapshot version. If
your change relies on code that is only available in the latest snapshot of
Oak, please revert this commit and hold it back until a proper release of
Oak is performed.

Thanks,

Francesco

---------- Forwarded message ----------
From: <ch...@apache.org>
Date: 2016-06-29 8:26 GMT+02:00
Subject: svn commit: r1750601 - in /jackrabbit/oak/trunk: oak-segment-tar/
oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/
oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/
oak-segment/src/main/java/org/apache/jackrabbit/oak/plug...
To: oak-commits@jackrabbit.apache.org


Author: chetanm
Date: Wed Jun 29 06:26:19 2016
New Revision: 1750601

URL: http://svn.apache.org/viewvc?rev=1750601&view=rev
Log:
OAK-4490 - Expose SegmentNodeStore as a secondary NodeStore

Exposes a barebone SegmentNodeStore. This instance is not listening for
observor etc and not directly exposed as a NodeStore but instance exposed
via NodeStoreProvider

Modified:
    jackrabbit/oak/trunk/oak-segment-tar/pom.xml

jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java

jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java

jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java

Modified: jackrabbit/oak/trunk/oak-segment-tar/pom.xml
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/pom.xml?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/pom.xml Wed Jun 29 06:26:19 2016
@@ -34,7 +34,7 @@
     <name>Oak Segment Tar</name>

     <properties>
-        <oak.version>1.5.3</oak.version>
+        <oak.version>1.6-SNAPSHOT</oak.version>
     </properties>

     <scm>

Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java
Wed Jun 29 06:26:19 2016
@@ -81,6 +81,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
 import org.apache.jackrabbit.oak.spi.state.RevisionGC;
 import org.apache.jackrabbit.oak.spi.state.RevisionGCMBean;
@@ -196,6 +197,13 @@ public class SegmentNodeStoreService ext
     )
     public static final String STANDBY = "standby";

+    @Property(
+            boolValue = false,
+            label = "Secondary Store Mode",
+            description = "Flag indicating that this component will not
register as a NodeStore but just as a SecondaryNodeStoreProvider"
+    )
+    public static final String SECONDARY_STORE = "secondary";
+
     @Property(boolValue = false,
             label = "Custom BlobStore",
             description = "Boolean value indicating that a custom
BlobStore is to be used. " +
@@ -308,6 +316,11 @@ public class SegmentNodeStoreService ext
                 return;
             }

+            if (toBoolean(property(SECONDARY_STORE), false)){
+                registerSecondaryStore();
+                return;
+            }
+
             if (registerSegmentNodeStore()) {
                 Dictionary<String, Object> props = new Hashtable<String,
Object>();
                 props.put(Constants.SERVICE_PID,
SegmentNodeStore.class.getName());
@@ -317,6 +330,20 @@ public class SegmentNodeStoreService ext
         }
     }

+    private void registerSecondaryStore() {
+        segmentNodeStore = SegmentNodeStoreBuilders.builder(store).build();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(NodeStoreProvider.ROLE, "secondary");
+        storeRegistration =
context.getBundleContext().registerService(NodeStoreProvider.class.getName(),
new NodeStoreProvider() {
+                    @Override
+                    public NodeStore getNodeStore() {
+                        return SegmentNodeStoreService.this;
+                    }
+                },
+                props);
+        log.info("Registered NodeStoreProvider backed by
SegmentNodeStore");
+    }
+
     private boolean registerSegmentStore() throws IOException {
         if (context == null) {
             log.info("Component still not activated. Ignoring the
initialization call");

Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
Wed Jun 29 06:26:19 2016
@@ -30,6 +30,7 @@ import java.util.Map;

 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
@@ -140,6 +141,17 @@ public class SegmentNodeStoreServiceTest
         unregisterSegmentNodeStoreService();
     }

+    @Test
+    public void nodeStoreProvider() throws Exception{
+        Map<String, Object> properties = newHashMap();
+        properties.put(SegmentNodeStoreService.SECONDARY_STORE, true);
+        properties.put(SegmentNodeStoreService.DIRECTORY,
folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreService =
context.registerInjectActivateService(new SegmentNodeStoreService(),
properties);
+        assertNull(context.getService(NodeStore.class));
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
     private SegmentNodeStoreService segmentNodeStoreService;

     private void registerSegmentNodeStoreService(boolean customBlobStore) {

Modified:
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
(original)
+++
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Wed Jun 29 06:26:19 2016
@@ -86,6 +86,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
 import org.apache.jackrabbit.oak.spi.state.RevisionGC;
 import org.apache.jackrabbit.oak.spi.state.RevisionGCMBean;
@@ -237,6 +238,13 @@ public class SegmentNodeStoreService ext
     )
     public static final String STANDBY = "standby";

+    @Property(
+            boolValue = false,
+            label = "Secondary Store Mode",
+            description = "Flag indicating that this component will not
register as a NodeStore but just as a SecondaryNodeStoreProvider"
+    )
+    public static final String SECONDARY_STORE = "secondary";
+
     @Property(boolValue = false,
             label = "Custom BlobStore",
             description = "Boolean value indicating that a custom
BlobStore is to be used. " +
@@ -351,6 +359,11 @@ public class SegmentNodeStoreService ext
                 return;
             }

+            if (toBoolean(property(SECONDARY_STORE), false)){
+                registerSecondaryStore();
+                return;
+            }
+
             if (registerSegmentNodeStore()) {
                 Dictionary<String, Object> props = new Hashtable<String,
Object>();
                 props.put(Constants.SERVICE_PID,
SegmentNodeStore.class.getName());
@@ -360,6 +373,22 @@ public class SegmentNodeStoreService ext
         }
     }

+    private void registerSecondaryStore() {
+        SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder =
SegmentNodeStore.builder(store);
+        nodeStoreBuilder.withCompactionStrategy(compactionStrategy);
+        segmentNodeStore = nodeStoreBuilder.build();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(NodeStoreProvider.ROLE, "secondary");
+        storeRegistration =
context.getBundleContext().registerService(NodeStoreProvider.class.getName(),
new NodeStoreProvider() {
+                    @Override
+                    public NodeStore getNodeStore() {
+                        return SegmentNodeStoreService.this;
+                    }
+                },
+                props);
+        log.info("Registered NodeStoreProvider backed by
SegmentNodeStore");
+    }
+
     private boolean registerSegmentStore() throws IOException {
         if (context == null) {
             log.info("Component still not activated. Ignoring the
initialization call");

Modified:
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java?rev=1750601&r1=1750600&r2=1750601&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
(original)
+++
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
Wed Jun 29 06:26:19 2016
@@ -30,6 +30,7 @@ import java.util.Map;

 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
@@ -140,6 +141,17 @@ public class SegmentNodeStoreServiceTest
         unregisterSegmentNodeStoreService();
     }

+    @Test
+    public void nodeStoreProvider() throws Exception{
+        Map<String, Object> properties = newHashMap();
+        properties.put(SegmentNodeStoreService.SECONDARY_STORE, true);
+        properties.put(SegmentNodeStoreService.DIRECTORY,
folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreService =
context.registerInjectActivateService(new SegmentNodeStoreService(),
properties);
+        assertNull(context.getService(NodeStore.class));
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
     private SegmentNodeStoreService segmentNodeStoreService;

     private void registerSegmentNodeStoreService(boolean customBlobStore) {