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 fr...@apache.org on 2017/07/27 11:04:10 UTC

svn commit: r1803164 - in /jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment: compaction/SegmentRevisionGC.java compaction/SegmentRevisionGCMBean.java file/FileStore.java file/GCType.java

Author: frm
Date: Thu Jul 27 11:04:09 2017
New Revision: 1803164

URL: http://svn.apache.org/viewvc?rev=1803164&view=rev
Log:
OAK-6485 - Set the default compaction type via SegmentRevisionGCMBean

Added:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java   (with props)
Modified:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java?rev=1803164&r1=1803163&r2=1803164&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGC.java Thu Jul 27 11:04:09 2017
@@ -22,6 +22,7 @@ package org.apache.jackrabbit.oak.segmen
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.segment.file.GCType;
 import org.apache.jackrabbit.oak.spi.gc.GCMonitor;
 
 /**
@@ -103,6 +104,10 @@ public interface SegmentRevisionGC {
      */
     void setEstimationDisabled(boolean disabled);
 
+    String getGCType();
+
+    void setGCType(String gcType);
+
     /**
      * Initiate a revision garbage collection operation
      */

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java?rev=1803164&r1=1803163&r2=1803164&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/compaction/SegmentRevisionGCMBean.java Thu Jul 27 11:04:09 2017
@@ -27,8 +27,8 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor;
+import org.apache.jackrabbit.oak.segment.file.GCType;
 
-// FIXME OAK-3349 add means to trigger full / tail compaction
 public class SegmentRevisionGCMBean
         extends AnnotatedStandardMBean
         implements SegmentRevisionGC {
@@ -115,6 +115,16 @@ public class SegmentRevisionGCMBean
     }
 
     @Override
+    public String getGCType() {
+        return fileStore.getGcType().toString();
+    }
+
+    @Override
+    public void setGCType(String gcType) {
+        fileStore.setGcType(GCType.valueOf(gcType));
+    }
+
+    @Override
     public void startRevisionGC() {
         fileStore.getGCRunner().run();
     }

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java?rev=1803164&r1=1803163&r2=1803164&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java Thu Jul 27 11:04:09 2017
@@ -18,6 +18,7 @@
  */
 package org.apache.jackrabbit.oak.segment.file;
 
+import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newLinkedHashMap;
 import static com.google.common.collect.Sets.newHashSet;
@@ -168,6 +169,8 @@ public class FileStore extends AbstractF
     @Nonnull
     private final SegmentNotFoundExceptionListener snfeListener;
 
+    private volatile GCType gcType = GCType.FULL;
+
     FileStore(final FileStoreBuilder builder) throws InvalidFileStoreVersionException, IOException {
         super(builder);
 
@@ -277,6 +280,14 @@ public class FileStore extends AbstractF
         return revisions.getHead().getSegmentId().getGcGeneration();
     }
 
+    public void setGcType(GCType gcType) {
+        this.gcType = checkNotNull(gcType);
+    }
+
+    public GCType getGcType() {
+        return gcType;
+    }
+
     /**
      * @return  a runnable for running garbage collection
      */
@@ -285,7 +296,16 @@ public class FileStore extends AbstractF
             @Override
             public void run() {
                 try {
-                    fullGC();
+                    switch (gcType) {
+                        case FULL:
+                            fullGC();
+                            break;
+                        case TAIL:
+                            tailGC();
+                            break;
+                        default:
+                            throw new IllegalStateException("Invalid GC type");
+                    }
                 } catch (IOException e) {
                     log.error("Error running revision garbage collection", e);
                 }
@@ -683,16 +703,18 @@ public class FileStore extends AbstractF
         }
 
         synchronized CompactionResult compactFull() {
+            gcListener.info("TarMK GC #{}: running full compaction", GC_COUNT);
             return compact(null, getGcGeneration().nextFull());
         }
 
         synchronized CompactionResult compactTail() {
+            gcListener.info("TarMK GC #{}: running tail compaction", GC_COUNT);
             SegmentNodeState base = getBase();
             if (base != null) {
                 return compact(base, getGcGeneration().nextTail());
             }
-            log.warn("Tail compaction requested but no base state available, falling back to full compaction");
-            return compactFull();
+            gcListener.info("TarMK GC #{}: no base state available, running full compaction instead", GC_COUNT);
+            return compact(null, getGcGeneration().nextFull());
         }
 
         private CompactionResult compact(SegmentNodeState base, GCGeneration newGeneration) {

Added: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java?rev=1803164&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java (added)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java Thu Jul 27 11:04:09 2017
@@ -0,0 +1,25 @@
+/*
+ * 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.segment.file;
+
+public enum GCType {
+
+    FULL,
+    TAIL
+
+}

Propchange: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/GCType.java
------------------------------------------------------------------------------
    svn:eol-style = native