Author: chetanm
Date: Wed Jun 29 06:26:39 2016
New Revision: 1750603
URL: http://svn.apache.org/viewvc?rev=1750603&view=rev
Log:
OAK-4490 - Expose SegmentNodeStore as a secondary NodeStore
Added an IT which validates the whole setup involving a MongoDocumentStore with
SegmentNodeStore as a secondary cache
Added:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy
Modified:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/LuceneSupportTest.groovy
Modified:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy?rev=1750603&r1=1750602&r2=1750603&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
(original)
+++
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
Wed Jun 29 06:26:39 2016
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit
import static
org.apache.jackrabbit.oak.run.osgi.OakOSGiRepositoryFactory.REPOSITORY_HOME
import static
org.apache.jackrabbit.oak.run.osgi.OakOSGiRepositoryFactory.REPOSITORY_TIMEOUT_IN_SECS
+import static org.junit.Assert.fail
abstract class AbstractRepositoryFactoryTest{
static final int SVC_WAIT_TIME = Integer.getInteger("pojosr.waitTime", 10)
@@ -130,4 +131,24 @@ abstract class AbstractRepositoryFactory
return new File(".").getAbsolutePath();
}
+ static retry(int timeoutSeconds, int intervalBetweenTriesMsec, Closure c) {
+ long timeout = System.currentTimeMillis() + timeoutSeconds * 1000L;
+ while (System.currentTimeMillis() < timeout) {
+ try {
+ if (c.call()) {
+ return;
+ }
+ } catch (AssertionError ignore) {
+ } catch (Exception ignore) {
+ }
+
+ try {
+ Thread.sleep(intervalBetweenTriesMsec);
+ } catch (InterruptedException ignore) {
+ }
+ }
+
+ fail("RetryLoop failed, condition is false after " + timeoutSeconds +
" seconds: ");
+ }
+
}
Modified:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/LuceneSupportTest.groovy
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/LuceneSupportTest.groovy?rev=1750603&r1=1750602&r2=1750603&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/LuceneSupportTest.groovy
(original)
+++
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/LuceneSupportTest.groovy
Wed Jun 29 06:26:39 2016
@@ -114,23 +114,4 @@ class LuceneSupportTest extends Abstract
}
}
- private static retry(int timeoutSeconds, int intervalBetweenTriesMsec,
Closure c) {
- long timeout = System.currentTimeMillis() + timeoutSeconds * 1000L;
- while (System.currentTimeMillis() < timeout) {
- try {
- if (c.call()) {
- return;
- }
- } catch (AssertionError ignore) {
- } catch (Exception ignore) {
- }
-
- try {
- Thread.sleep(intervalBetweenTriesMsec);
- } catch (InterruptedException ignore) {
- }
- }
-
- fail("RetryLoop failed, condition is false after " + timeoutSeconds +
" seconds: ");
- }
}
Added:
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy?rev=1750603&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy
(added)
+++
jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy
Wed Jun 29 06:26:39 2016
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.run.osgi
+
+import org.apache.jackrabbit.commons.JcrUtils
+import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore
+import org.apache.jackrabbit.oak.plugins.document.MongoUtils
+import org.apache.jackrabbit.oak.spi.state.NodeStateUtils
+import org.apache.jackrabbit.oak.spi.state.NodeStore
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider
+import org.junit.Test
+
+import javax.jcr.Session
+
+import static
org.apache.jackrabbit.oak.run.osgi.OakOSGiRepositoryFactory.REPOSITORY_CONFIG
+import static
org.apache.jackrabbit.oak.run.osgi.OakOSGiRepositoryFactory.REPOSITORY_CONFIG_FILE
+import static org.junit.Assume.assumeTrue
+
+
+class SecondaryStoreConfigIT extends AbstractRepositoryFactoryTest{
+
+ @Test
+ public void secondaryNodeStoreCache() throws Exception{
+ mongoCheck()
+
+ config[REPOSITORY_CONFIG_FILE] =
createConfigValue("oak-base-config.json")
+ config[REPOSITORY_CONFIG] = [
+
'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [
+ mongouri : MongoUtils.URL
+ ],
+
'org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService' : [
+ customBlobStore : true,
+ secondary : true
+ ],
+
'org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreCacheService'
: [
+ includedPaths : ['/']
+ ]
+ ]
+
+ repository = repositoryFactory.getRepository(config);
+
+ Session session = createAdminSession();
+ javax.jcr.Node rootNode = session.getRootNode();
+
+ javax.jcr.Node child = JcrUtils.getOrAddNode(rootNode, "testNode",
"oak:Unstructured");
+ child.setProperty("foo", "bar");
+ session.save()
+ session.logout();
+
+ NodeStoreProvider nsp = getServiceWithWait(NodeStoreProvider.class)
+ NodeStore secondary = nsp.nodeStore
+
+ //Assert that recently created node gets pushed to Secondary and
+ //is accessible in sometime
+ retry(30, 10) {
+ return NodeStateUtils.getNode(secondary.root, "/testNode").exists()
+ }
+
+ }
+
+ private mongoCheck() {
+ //Somehow in Groovy assumeNotNull cause issue as Groovy probably
+ //does away with null array causing a NPE
+ assumeTrue(MongoUtils.isAvailable())
+ }
+}