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 2015/04/06 13:26:23 UTC
svn commit: r1671512 - in /jackrabbit/oak/trunk/oak-lucene/src:
main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java
test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java
Author: chetanm
Date: Mon Apr 6 11:26:22 2015
New Revision: 1671512
URL: http://svn.apache.org/r1671512
Log:
OAK-2708 - Enable CopyOnRead feature for Lucene indexes by default
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java?rev=1671512&r1=1671511&r2=1671512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderService.java Mon Apr 6 11:26:22 2015
@@ -84,7 +84,7 @@ public class LuceneIndexProviderService
private static final String PROP_DEBUG = "debug";
@Property(
- boolValue = false,
+ boolValue = true,
label = "Enable CopyOnRead",
description = "Enable copying of Lucene index to local file system to improve query performance"
)
@@ -183,7 +183,7 @@ public class LuceneIndexProviderService
}
private IndexTracker createTracker(BundleContext bundleContext, Map<String, ?> config) {
- boolean enableCopyOnRead = PropertiesUtil.toBoolean(config.get(PROP_COPY_ON_READ), false);
+ boolean enableCopyOnRead = PropertiesUtil.toBoolean(config.get(PROP_COPY_ON_READ), true);
if (enableCopyOnRead){
String indexDirPath = PropertiesUtil.toString(config.get(PROP_LOCAL_INDEX_DIR), null);
if (Strings.isNullOrEmpty(indexDirPath)) {
Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java?rev=1671512&r1=1671511&r2=1671512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProviderServiceTest.java Mon Apr 6 11:26:22 2015
@@ -20,8 +20,8 @@
package org.apache.jackrabbit.oak.plugins.index.lucene;
import java.util.HashMap;
+import java.util.Map;
-import com.google.common.collect.ImmutableMap;
import org.apache.jackrabbit.oak.spi.commit.BackgroundObserver;
import org.apache.jackrabbit.oak.spi.commit.Observer;
import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
@@ -29,11 +29,16 @@ import org.apache.sling.testing.mock.osg
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class LuceneIndexProviderServiceTest {
+
+ @Rule
+ public final TemporaryFolder folder = new TemporaryFolder();
+
@Rule
public final OsgiContext context = new OsgiContext();
@@ -41,11 +46,13 @@ public class LuceneIndexProviderServiceT
@Test
public void defaultSetup() throws Exception{
- MockOsgi.activate(service, context.bundleContext(), new HashMap<String, Object>());
+ MockOsgi.activate(service, context.bundleContext(), getDefaultConfig());
assertNotNull(context.getService(QueryIndexProvider.class));
assertNotNull(context.getService(Observer.class));
+ assertNotNull("CopyOnRead should be enabled by default",context.getService(CopyOnReadStatsMBean.class));
+
assertTrue(context.getService(Observer.class) instanceof BackgroundObserver);
MockOsgi.deactivate(service);
@@ -53,10 +60,18 @@ public class LuceneIndexProviderServiceT
@Test
public void disableOpenIndexAsync() throws Exception{
- MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String,Object>of("enableOpenIndexAsync", false));
+ Map<String,Object> config = getDefaultConfig();
+ config.put("enableOpenIndexAsync", false);
+ MockOsgi.activate(service, context.bundleContext(), config);
assertTrue(context.getService(Observer.class) instanceof LuceneIndexProvider);
MockOsgi.deactivate(service);
}
+
+ private Map<String,Object> getDefaultConfig(){
+ Map<String,Object> config = new HashMap<String, Object>();
+ config.put("localIndexDir", folder.getRoot().getAbsolutePath());
+ return config;
+ }
}