jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1583994 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStore.java test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStoreTest.java
Date Wed, 02 Apr 2014 12:25:44 GMT
Author: chetanm
Date: Wed Apr  2 12:25:44 2014
New Revision: 1583994

URL: http://svn.apache.org/r1583994
Log:
OAK-1666 - FileDataStore inUse map causes contention in concurrent env

Temporary workaround which uses a NoOpMap for inUseMap untill fix for JCR-3764 is ready

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStore.java?rev=1583994&r1=1583993&r2=1583994&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStore.java
Wed Apr  2 12:25:44 2014
@@ -20,7 +20,11 @@
 package org.apache.jackrabbit.oak.plugins.blob.datastore;
 
 import java.io.File;
+import java.lang.ref.WeakReference;
+import java.util.AbstractMap;
+import java.util.Collections;
 import java.util.Iterator;
+import java.util.Set;
 
 import com.google.common.base.Charsets;
 import com.google.common.base.Function;
@@ -38,6 +42,13 @@ import org.apache.jackrabbit.core.data.F
 public class OakFileDataStore extends FileDataStore {
     private byte[] referenceKey;
 
+    public OakFileDataStore() {
+        //TODO FIXME Temporary workaround for OAK-1666. Override the default
+        //synchronized map with a Noop. This should be removed when fix
+        //for JCR-3764 is part of release.
+        inUse = new NoOpMap<DataIdentifier, WeakReference<DataIdentifier>>();
+    }
+
     @Override
     public Iterator<DataIdentifier> getAllIdentifiers() {
         return Files.fileTreeTraverser().postOrderTraversal(new File(getPath()))
@@ -89,4 +100,21 @@ public class OakFileDataStore extends Fi
     public void setReferenceKey(byte[] referenceKey) {
         this.referenceKey = referenceKey;
     }
+
+    /**
+     * Noop map which eats up all the put call
+     */
+    static class NoOpMap<K,V> extends AbstractMap<K,V> {
+
+        @Override
+        public V put(K key, V value) {
+            //Eat the put call
+            return null;
+        }
+
+        @Override
+        public Set<Entry<K, V>> entrySet() {
+            return Collections.emptySet();
+        }
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStoreTest.java?rev=1583994&r1=1583993&r2=1583994&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/OakFileDataStoreTest.java
Wed Apr  2 12:25:44 2014
@@ -21,6 +21,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.io.File;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.Nullable;
@@ -34,6 +35,7 @@ import org.apache.jackrabbit.core.data.F
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class OakFileDataStoreTest {
 
@@ -60,4 +62,12 @@ public class OakFileDataStoreTest {
         assertEquals(expectedNames, fileNames);
         FileUtils.cleanDirectory(testDir);
     }
+
+    @Test
+    public void testNoOpMap() throws Exception{
+        Map<String, String> noop = new OakFileDataStore.NoOpMap<String, String>();
+        noop.put("a","b");
+        noop.remove("foo");
+        assertTrue(noop.isEmpty());
+    }
 }



Mime
View raw message