Author: frm
Date: Fri Oct 28 09:05:14 2016
New Revision: 1766984

URL: http://svn.apache.org/viewvc?rev=1766984&view=rev
Log:
OAK-5029 - Trigger cleanup on standby at head generation change

Contribution by Timothee Maret

Modified:
    
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSync.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSync.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSync.java?rev=1766984&r1=1766983&r2=1766984&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSync.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSync.java
 Fri Oct 28 09:05:14 2016
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.oak.segment.standby.client;
 
-import static org.apache.jackrabbit.oak.commons.IOUtils.humanReadableByteCount;
-
 import java.io.Closeable;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
@@ -139,12 +137,12 @@ public final class StandbyClientSync imp
             try (StandbyClient client = new StandbyClient(observer.getID(), 
secure, readTimeoutMs)) {
                 client.connect(host, port);
 
-                long sizeBefore = fileStore.getStats().getApproximateSize();
+                int genBefore = headGeneration(fileStore);
                 new StandbyClientSyncExecution(fileStore, client, 
newRunningSupplier()).execute();
-                long sizeAfter = fileStore.getStats().getApproximateSize();
+                int genAfter = headGeneration(fileStore);
 
-                if (autoClean && sizeAfter > 1.25 * sizeBefore) {
-                    log.info("Store size increased from {} to {}, will run 
cleanup.", humanReadableByteCount(sizeBefore), 
humanReadableByteCount(sizeAfter));
+                if (autoClean && (genAfter > genBefore)) {
+                    log.info("New head generation detected (prevHeadGen: {} 
newHeadGen: {}), running cleanup.", genBefore, genAfter);
                     cleanupAndRemove();
                 }
             }
@@ -162,6 +160,10 @@ public final class StandbyClientSync imp
         }
     }
 
+    private int headGeneration(FileStore fileStore) {
+        return 
fileStore.getHead().getRecordId().getSegment().getGcGeneration();
+    }
+
     private void cleanupAndRemove() throws IOException {
         fileStore.cleanup();
     }

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1766984&r1=1766983&r2=1766984&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/main/resources/OSGI-INF/metatype/metatype.properties
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/main/resources/OSGI-INF/metatype/metatype.properties
 Fri Oct 28 09:05:14 2016
@@ -47,4 +47,4 @@ standby.readtimeout.name = Standby Read
 standby.readtimeout.description = Timeout for requests issued from the standby 
instance in milliseconds
 
 standby.autoclean.name = Standby Automatic Cleanup
-standby.autoclean.description = Call the cleanup method if the size of the 
store increases over 25% on a sync cycle
+standby.autoclean.description = Call the cleanup method when the root segment 
Garbage Collector (GC) generation number increases
\ No newline at end of file


Reply via email to