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 th...@apache.org on 2019/01/08 12:42:21 UTC
svn commit: r1850741 - in /jackrabbit/oak/trunk:
oak-doc/src/site/markdown/query/
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/
oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/
Author: thomasm
Date: Tue Jan 8 12:42:21 2019
New Revision: 1850741
URL: http://svn.apache.org/viewvc?rev=1850741&view=rev
Log:
OAK-7968 Active deletion of Lucene binaries: configuration option to disable
Added:
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobDisabledTest.java
Modified:
jackrabbit/oak/trunk/oak-doc/src/site/markdown/query/lucene.md
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBean.java
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBeanImpl.java
Modified: jackrabbit/oak/trunk/oak-doc/src/site/markdown/query/lucene.md
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/query/lucene.md?rev=1850741&r1=1850740&r2=1850741&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-doc/src/site/markdown/query/lucene.md (original)
+++ jackrabbit/oak/trunk/oak-doc/src/site/markdown/query/lucene.md Tue Jan 8 12:42:21 2019
@@ -1131,6 +1131,8 @@ The feature would only delete blobs whic
The task to actually purge blobs from datastore is performed by jmx operation. Jmx bean
for the operation is `org.apache.jackrabbit.oak:name=Active lucene files collection,type=ActiveDeletedBlobCollector`
and the operation is `startActiveCollection()`.
+To disable active deletion in a certain installation, set the system property `oak.active.deletion.disabled`.
+
### <a name="luke"></a>Analyzing created Lucene Index
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBean.java?rev=1850741&r1=1850740&r2=1850741&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBean.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBean.java Tue Jan 8 12:42:21 2019
@@ -20,7 +20,6 @@
package org.apache.jackrabbit.oak.plugins.index.lucene;
import javax.management.openmbean.CompositeData;
-import java.util.Map;
import org.jetbrains.annotations.NotNull;
@@ -79,4 +78,12 @@ public interface ActiveDeletedBlobCollec
* would get marked for active deletion when active deletion is active.
*/
void flagActiveDeletionSafe();
+
+ /**
+ * Whether active deletion is disabled.
+ *
+ * @return true if disabled
+ */
+ boolean isDisabled();
+
}
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBeanImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBeanImpl.java?rev=1850741&r1=1850740&r2=1850741&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBeanImpl.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ActiveDeletedBlobCollectorMBeanImpl.java Tue Jan 8 12:42:21 2019
@@ -74,6 +74,8 @@ public class ActiveDeletedBlobCollectorM
private final long MIN_BLOB_AGE_TO_ACTIVELY_DELETE = Long.getLong("oak.active.deletion.minAge",
TimeUnit.HOURS.toSeconds(24));
+ private final boolean ACTIVE_DELETION_DISABLED = Boolean.getBoolean("oak.active.deletion.disabled");
+
Clock clock = Clock.SIMPLE; // package private for tests
@NotNull
@@ -128,9 +130,17 @@ public class ActiveDeletedBlobCollectorM
LOG.info("Active blob collector initialized with minAge: {}", MIN_BLOB_AGE_TO_ACTIVELY_DELETE);
}
+ @Override
+ public boolean isDisabled() {
+ return ACTIVE_DELETION_DISABLED;
+ }
+
@NotNull
@Override
public CompositeData startActiveCollection() {
+ if (isDisabled()) {
+ return ManagementOperation.Status.none(gcOp, "Active deletion is disabled").toCompositeData();
+ }
if (gcOp.isDone()) {
long safeTimestampForDeletedBlobs = getSafeTimestampForDeletedBlobs();
if (safeTimestampForDeletedBlobs == -1) {
Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobDisabledTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobDisabledTest.java?rev=1850741&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobDisabledTest.java (added)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobDisabledTest.java Tue Jan 8 12:42:21 2019
@@ -0,0 +1,86 @@
+/*
+ * 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.plugins.index.lucene.directory;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.Executor;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService;
+import org.apache.jackrabbit.oak.plugins.index.IndexPathService;
+import org.apache.jackrabbit.oak.plugins.index.lucene.ActiveDeletedBlobCollectorMBeanImpl;
+import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard;
+import org.junit.Test;
+
+public class ActiveDeletedBlobDisabledTest {
+
+
+ private void test(final boolean disabled) {
+ String property = "oak.active.deletion.disabled";
+ try {
+ System.setProperty(property, "" + disabled);
+ NodeStore store = null;
+ IndexPathService indexPathService = null;
+ AsyncIndexInfoService asyncIndexInfoService = null;
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ ActiveDeletedBlobCollectorMBeanImpl b = new ActiveDeletedBlobCollectorMBeanImpl(
+ ActiveDeletedBlobCollectorFactory.NOOP,
+ new DefaultWhiteboard(),
+ store,
+ indexPathService,
+ asyncIndexInfoService,
+ new MemoryBlobStore(),
+ executor);
+ b.isActiveDeletionUnsafe();
+ b.isDisabled();
+ CompositeData d = b.startActiveCollection();
+ if (disabled) {
+ // none
+ assertEquals(1, d.get("code"));
+ assertEquals("Active deletion is disabled", d.get("message"));
+ } else {
+ // failed
+ assertEquals(5, d.get("code"));
+ assertEquals("Active lucene index blobs collection couldn't be run as a safe timestamp for purging lucene index blobs couldn't be evaluated",
+ d.get("message"));
+ }
+ } finally {
+ System.clearProperty(property);
+ }
+
+ }
+
+ @Test
+ public void testDisabled() {
+ test(true);
+ }
+
+ @Test
+ public void testEnabled() {
+ test(false);
+ }
+
+}