geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [16/37] incubator-geode git commit: GEODE-229: Fixed javadoc for DiskStoreFactory.setCompactionThreshold
Date Tue, 01 Sep 2015 16:48:54 GMT
GEODE-229: Fixed javadoc for DiskStoreFactory.setCompactionThreshold

The javadocs and the behavior of the code were backwards. The code
compacts when the live data gets below the threshold. I changed the
javadocs to avoid screwing up someone who was relied on the old
behavior.

Adding a unit test of this property.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/936065f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/936065f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/936065f4

Branch: refs/heads/feature/GEODE-77
Commit: 936065f4194f5df97d83b26ca029e66bb69a8d15
Parents: bbc2a5f
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Tue Aug 18 17:54:56 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Aug 19 16:35:27 2015 -0700

----------------------------------------------------------------------
 .../gemfire/cache/DiskStoreFactory.java         | 15 ++++++----
 .../internal/cache/DiskRegionJUnitTest.java     | 30 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/936065f4/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java
index ab67c75..296fb8a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java
@@ -111,13 +111,16 @@ public interface DiskStoreFactory
   public DiskStoreFactory setAutoCompact(boolean isAutoCompact);
 
   /**
-   * Sets the threshold at which an oplog will become compactable. Until it reaches
-   * this threshold the oplog will not be compacted.
-   * The threshold is a percentage in the range 0..100.
-   * When the amount of garbage in an oplog exceeds this percentage then when a compaction
-   * is done this garbage will be cleaned up freeing up disk space. Garbage is created by
+   * Sets the threshold at which an oplog will become compactable. Until it
+   * reaches this threshold the oplog will not be compacted. The threshold is a
+   * percentage in the range 0..100. When the amount of live data in an oplog
+   * becomes less than this percentage then when a compaction is done this
+   * garbage will be cleaned up freeing up disk space. Garbage is created by
    * entry destroys, entry updates, and region destroys.
-   * @param compactionThreshold the threshold percentage at which an oplog is compactable
+   * 
+   * @param compactionThreshold
+   *          percentage of remaining live data in the oplog at which an oplog
+   *          is compactable
    * @return a reference to <code>this</code>
    */
   public DiskStoreFactory setCompactionThreshold(int compactionThreshold);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/936065f4/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java
index bfc832a..9f85b6f 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskRegionJUnitTest.java
@@ -2993,6 +2993,36 @@ public class DiskRegionJUnitTest extends DiskRegionTestingBase
     boolean compacted = ((LocalRegion)region).getDiskStore().forceCompaction();
     assertEquals(true, compacted);
   }
+  
+  /**
+   * Confirm that forceCompaction waits for the compaction to finish
+   */
+  @Test
+  public void testNonDefaultCompaction() {
+    DiskRegionProperties props = new DiskRegionProperties();
+    props.setRegionName("testForceCompactionDoesRoll");
+    props.setRolling(false);
+    props.setDiskDirs(dirs);
+    props.setAllowForceCompaction(true);
+    props.setPersistBackup(true);
+    props.setCompactionThreshold(90);
+    region = DiskRegionHelperFactory.getSyncPersistOnlyRegion(cache, props, Scope.LOCAL);
+    DiskRegion dr = ((LocalRegion)region).getDiskRegion();
+    logWriter.info("putting key1");
+    region.put("key1", "value1");
+    logWriter.info("putting key2");
+    region.put("key2", "value2");
+    //Only remove 1 of the entries. This wouldn't trigger compaction with
+    //the default threshold, since there are two entries.
+    logWriter.info("removing key1");
+    region.remove("key1");
+    // now that it is compactable the following forceCompaction should
+    // go ahead and do a roll and compact it.
+    Oplog oplog = dr.testHook_getChild();
+    boolean compacted = ((LocalRegion)region).getDiskStore().forceCompaction();
+    assertEquals(true, oplog.testConfirmCompacted());
+    assertEquals(true, compacted);
+  }
 
   /**
    * Confirm that forceCompaction waits for the compaction to finish


Mime
View raw message