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 am...@apache.org on 2016/07/20 03:56:33 UTC

svn commit: r1753430 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java

Author: amitj
Date: Wed Jul 20 03:56:32 2016
New Revision: 1753430

URL: http://svn.apache.org/viewvc?rev=1753430&view=rev
Log:
OAK-4200:  [BlobGC] Improve collection times of blobs available

* Renamed BlobIdTracker.Store to BlobIdTracker.BlobIdStore

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java?rev=1753430&r1=1753429&r2=1753430&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java Wed Jul 20 03:56:32 2016
@@ -66,9 +66,9 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.commons.FileIOUtils.copy;
 import static org.apache.jackrabbit.oak.commons.FileIOUtils.sort;
 import static org.apache.jackrabbit.oak.commons.FileIOUtils.writeStrings;
-import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.Store.Type.GENERATION;
-import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.Store.Type.IN_PROCESS;
-import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.Store.Type.REFS;
+import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore.Type.GENERATION;
+import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore.Type.IN_PROCESS;
+import static org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore.Type.REFS;
 
 
 /**
@@ -90,7 +90,7 @@ public class BlobIdTracker implements Cl
 
     private final SharedDataStore datastore;
 
-    protected Store store;
+    protected BlobIdStore store;
 
     private final ScheduledExecutorService scheduler;
 
@@ -113,7 +113,7 @@ public class BlobIdTracker implements Cl
         try {
             forceMkdir(rootDir);
             prefix = fileNamePrefix + "-" + repositoryId;
-            this.store = new Store(rootDir, prefix);
+            this.store = new BlobIdStore(rootDir, prefix);
             scheduler.scheduleAtFixedRate(new SnapshotJob(),
                 SECONDS.toMillis(snapshotDelaySecs),
                 SECONDS.toMillis(snapshotIntervalSecs), MILLISECONDS);
@@ -258,7 +258,7 @@ public class BlobIdTracker implements Cl
     /**
      * Local store for managing the blob reference
      */
-    static class Store implements Closeable {
+    static class BlobIdStore implements Closeable {
         /* Suffix for a snapshot generation file */
         private static final String genFileNameSuffix = ".gen";
 
@@ -281,7 +281,7 @@ public class BlobIdTracker implements Cl
         /* Lock for operations on references file */
         private final ReentrantLock refLock;
 
-        Store(File rootDir, String prefix) throws IOException {
+        BlobIdStore(File rootDir, String prefix) throws IOException {
             this.rootDir = rootDir;
             this.prefix = prefix;
             this.refLock = new ReentrantLock();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java?rev=1753430&r1=1753429&r2=1753430&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTrackerStoreTest.java Wed Jul 20 03:56:32 2016
@@ -27,8 +27,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 
-import org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.Store;
 import org.apache.jackrabbit.oak.plugins.blob.SharedDataStore;
+import org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker.BlobIdStore;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -54,7 +54,7 @@ import static org.junit.Assume.assumeNoE
 import static org.junit.Assume.assumeThat;
 
 /**
- * Test for BlobIdTracker.Store to test addition, retrieval and removal of blob ids.
+ * Test for BlobIdTracker.BlobIdStore to test addition, retrieval and removal of blob ids.
  */
 public class BlobIdTrackerStoreTest {
     private static final Logger log = LoggerFactory.getLogger(BlobIdTrackerStoreTest.class);
@@ -99,7 +99,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshot() throws Exception {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.snapshot();
@@ -110,7 +110,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshotRetrieve() throws Exception {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.snapshot();
@@ -121,7 +121,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshotAdd() throws Exception {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.snapshot();
@@ -135,7 +135,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshotAddSnapshot() throws Exception {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.snapshot();
@@ -148,7 +148,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshotRemove() throws Exception {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.snapshot();
@@ -160,7 +160,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addRestart() throws IOException {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 100000));
         this.tracker = initTracker();
@@ -174,7 +174,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addCloseRestart() throws IOException {
-        BlobIdTracker.Store store = tracker.store;
+        BlobIdStore store = tracker.store;
 
         Set<String> initAdd = add(store, range(0, 10000));
         store.close();
@@ -187,7 +187,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addConcurrentSnapshot() throws IOException, InterruptedException {
-        final BlobIdTracker.Store store = tracker.store;
+        final BlobIdStore store = tracker.store;
         final CountDownLatch start = new CountDownLatch(1);
         final CountDownLatch done = new CountDownLatch(2);
 
@@ -208,7 +208,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addSnapshotConcurrentRetrieve() throws IOException, InterruptedException {
-        final BlobIdTracker.Store store = tracker.store;
+        final BlobIdStore store = tracker.store;
         final CountDownLatch start = new CountDownLatch(1);
         final CountDownLatch done = new CountDownLatch(2);
         Set<String> initAdd = add(store, range(0, 100000));
@@ -232,7 +232,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void snapshotConcurrentRemove() throws IOException, InterruptedException {
-        final BlobIdTracker.Store store = tracker.store;
+        final BlobIdStore store = tracker.store;
         final CountDownLatch start = new CountDownLatch(1);
         final CountDownLatch done = new CountDownLatch(2);
         final Set<String> initAdd = add(store, range(0, 100000));
@@ -255,7 +255,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void addBulkAdd() throws IOException {
-        final BlobIdTracker.Store store = tracker.store;
+        final BlobIdStore store = tracker.store;
         final Set<String> initAdd = add(store, range(0, 4));
 
         // Add new ids from a file
@@ -284,7 +284,7 @@ public class BlobIdTrackerStoreTest {
 
     @Test
     public void bulkAddConcurrentCompact() throws IOException, InterruptedException {
-        final BlobIdTracker.Store store = tracker.store;
+        final BlobIdStore store = tracker.store;
         final CountDownLatch start = new CountDownLatch(1);
         final CountDownLatch done = new CountDownLatch(2);
 
@@ -305,12 +305,12 @@ public class BlobIdTrackerStoreTest {
     }
 
     private static Thread addThread(
-        final Store store, final CountDownLatch start, final CountDownLatch done) {
+        final BlobIdStore store, final CountDownLatch start, final CountDownLatch done) {
         return addThread(store, false, start, done);
     }
 
     private static Thread addThread(
-        final Store store, final boolean bulk, final CountDownLatch start, final CountDownLatch done) {
+        final BlobIdStore store, final boolean bulk, final CountDownLatch start, final CountDownLatch done) {
         return new Thread("AddThread") {
             @Override
             public void run() {
@@ -333,7 +333,7 @@ public class BlobIdTrackerStoreTest {
     }
 
     private static Thread retrieveThread(
-        final Store store, final Set<String> retrieves, final CountDownLatch start,
+        final BlobIdStore store, final Set<String> retrieves, final CountDownLatch start,
         final CountDownLatch done) {
         return new Thread("RetrieveThread") {
             @Override
@@ -351,7 +351,7 @@ public class BlobIdTrackerStoreTest {
         };
     }
 
-    private static Thread removeThread(final Store store, final File temp,
+    private static Thread removeThread(final BlobIdStore store, final File temp,
         final Set<String> adds, final CountDownLatch start, final CountDownLatch done) {
         return new Thread("RemoveThread") {
             @Override
@@ -370,7 +370,7 @@ public class BlobIdTrackerStoreTest {
     }
 
     private static Thread snapshotThread(
-        final Store store, final CountDownLatch start, final CountDownLatch done) {
+        final BlobIdStore store, final CountDownLatch start, final CountDownLatch done) {
         return new Thread("SnapshotThread") {
             @Override
             public void run() {
@@ -387,7 +387,7 @@ public class BlobIdTrackerStoreTest {
         };
     }
 
-    private static Set<String> add(Store store, List<String> ints) throws IOException {
+    private static Set<String> add(BlobIdStore store, List<String> ints) throws IOException {
         Set<String> s = newHashSet();
         for (String rec : ints) {
             store.addRecord(rec);
@@ -396,7 +396,7 @@ public class BlobIdTrackerStoreTest {
         return s;
     }
 
-    private static Set<String> retrieve(Store store) throws IOException {
+    private static Set<String> retrieve(BlobIdStore store) throws IOException {
         Set<String> retrieved = newHashSet();
         Iterator<String> iter = store.getRecords();
         while(iter.hasNext()) {
@@ -405,14 +405,14 @@ public class BlobIdTrackerStoreTest {
         closeQuietly((Closeable)iter);
         return retrieved;
     }
-    private static Set<String> retrieveFile(Store store, TemporaryFolder folder) throws IOException {
+    private static Set<String> retrieveFile(BlobIdStore store, TemporaryFolder folder) throws IOException {
         File f = folder.newFile();
         Set<String> retrieved = readStringsAsSet(
             new FileInputStream(store.getRecords(f.getAbsolutePath())), false);
         return retrieved;
     }
 
-    private static void remove(Store store, File temp, Set<String> initAdd,
+    private static void remove(BlobIdStore store, File temp, Set<String> initAdd,
             List<String> ints) throws IOException {
         writeStrings(ints.iterator(), temp, false);
         initAdd.removeAll(ints);