jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1491447 - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/ main/java/org/apache/jackrabbit/mongomk/osgi/ main/java/org/apache/jackrabbit/mongomk/util/ test/java/org/apache/jackrabbit/mongomk/
Date Mon, 10 Jun 2013 13:40:55 GMT
Author: thomasm
Date: Mon Jun 10 13:40:54 2013
New Revision: 1491447

URL: http://svn.apache.org/r1491447
Log:
OAK-854 Use weight based caching limit instead of size based limits (formatting)

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/EmpericalWeigher.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernelService.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/Utils.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/ConflictTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MeasureMemory.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MongoDocumentStoreTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/EmpericalWeigher.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/EmpericalWeigher.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/EmpericalWeigher.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/EmpericalWeigher.java
Mon Jun 10 13:40:54 2013
@@ -26,19 +26,19 @@ import org.apache.jackrabbit.mongomk.uti
  * Determines the weight of object based on the memory taken by them. The memory esimates
  * are based on emperical data and not exact
  */
-public class EmpericalWeigher implements Weigher<String,Object>{
+public class EmpericalWeigher implements Weigher<String, Object> {
 
     @Override
     public int weigh(String key, Object value) {
         int size = key.length() * 2;
 
-        if(value instanceof Node){
+        if (value instanceof Node) {
             size += ((Node) value).getMemory();
-        }else if (value instanceof Node.Children){
+        } else if (value instanceof Node.Children) {
             size += ((Node.Children) value).getMemory();
-        }else if(value instanceof MongoDocumentStore.CachedDocument){
+        } else if (value instanceof MongoDocumentStore.CachedDocument) {
             size += Utils.estimateMemoryUsage(((MongoDocumentStore.CachedDocument) value).value);
-        }else if(value != null){
+        } else if (value != null) {
             throw new IllegalArgumentException("Cannot determine weight for object of type
" + value.getClass());
         }
         return size;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
Mon Jun 10 13:40:54 2013
@@ -64,7 +64,7 @@ public class MongoDocumentStore implemen
     
     private final Cache<String, CachedDocument> nodesCache;
 
-    public MongoDocumentStore(DB db,MongoMK.Builder builder) {
+    public MongoDocumentStore(DB db, MongoMK.Builder builder) {
         nodes = db.getCollection(
                 Collection.NODES.toString());
         clusterNodes = db.getCollection(

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
Mon Jun 10 13:40:54 2013
@@ -1542,13 +1542,13 @@ public class MongoMK implements MicroKer
      * A builder for a MongoMK instance.
      */
     public static class Builder {
-        private static final long DEFAULT_MEMORY_CACHE_SIZE = 1 << 28; // 256MB
+        private static final long DEFAULT_MEMORY_CACHE_SIZE = 256 * 1024 * 1024;
         private DocumentStore documentStore;
         private BlobStore blobStore;
         private int clusterId  = Integer.getInteger("oak.mongoMK.clusterId", 0);
         private int asyncDelay = 1000;
         private boolean timing;
-        private Weigher<String,Object> weigher = new EmpericalWeigher();
+        private Weigher<String, Object> weigher = new EmpericalWeigher();
         private long nodeCacheSize;
         private long childrenCacheSize;
         private long documentCacheSize;
@@ -1565,7 +1565,7 @@ public class MongoMK implements MicroKer
          */
         public Builder setMongoDB(DB db) {
             if (db != null) {
-                this.documentStore = new MongoDocumentStore(db,this);
+                this.documentStore = new MongoDocumentStore(db, this);
                 this.blobStore = new MongoBlobStore(db);
             }
             return this;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
Mon Jun 10 13:40:54 2013
@@ -127,14 +127,13 @@ public class Node {
             this.rev = rev;
         }
 
-        public int getMemory(){
+        public int getMemory() {
             int size = 200 + path.length() * 2;
-            for(String c : children){
+            for (String c : children) {
                 size += c.length() * 2 + 40;
             }
             return size;
         }
-
         
         @Override
         public String toString() {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernelService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernelService.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernelService.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernelService.java
Mon Jun 10 13:40:54 2013
@@ -62,7 +62,7 @@ public class MongoMicroKernelService {
     @Property(value = DEFAULT_DB)
     private static final String PROP_DB = "db";
 
-    @Property(intValue=DEFAULT_CACHE)
+    @Property(intValue = DEFAULT_CACHE)
     private static final String PROP_CACHE = "cache";
     private static final long MB = 1024 * 1024;
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/Utils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/Utils.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/Utils.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/Utils.java
Mon Jun 10 13:40:54 2013
@@ -59,21 +59,21 @@ public class Utils {
         int size = 0;
 
         for (Entry<String, Object> e : map.entrySet()) {
-            size += e.getKey().length()*2;
+            size += e.getKey().length() * 2;
             Object o = e.getValue();
             if (o instanceof String) {
-                size += ((String)o).length()*2;
+                size += ((String) o).length() * 2;
             } else if (o instanceof Long) {
                 size += 8;
-            }  else if (o instanceof Integer) {
+            } else if (o instanceof Integer) {
                 size += 4;
             } else if (o instanceof Map) {
                 size += 8 + estimateMemoryUsage((Map<String, Object>) o);
             }
         }
 
-        if(map instanceof BasicDBObject){
-            //Based on emperical testing using JAMM
+        if (map instanceof BasicDBObject) {
+            // Based on emperical testing using JAMM
             size += 176;
             size += map.entrySet().size() * 136;
         }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/ConflictTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/ConflictTest.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/ConflictTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/ConflictTest.java
Mon Jun 10 13:40:54 2013
@@ -406,7 +406,7 @@ public class ConflictTest extends BaseMo
     }
 
     @Test
-    public void changeChangedPropertyTwoBranches(){
+    public void changeChangedPropertyTwoBranches() {
         String rev = mk.commit("/", "+\"foo\":{\"prop\":\"value\"}", null, null);
 
         String b1 = mk.branch(rev);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MeasureMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MeasureMemory.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MeasureMemory.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MeasureMemory.java
Mon Jun 10 13:40:54 2013
@@ -148,7 +148,8 @@ public class MeasureMemory {
     }
 
     static BasicDBObject generateBasicObject(int propertyCount) {
-        BasicDBObject n = new BasicDBObject(new String("_id"),new String("/hello/world"));
+        BasicDBObject n = new BasicDBObject(new String("_id"), new String(
+                "/hello/world"));
         for (int i = 0; i < propertyCount; i++) {
             n.append("property" + i, "values " + i);
         }
@@ -156,9 +157,9 @@ public class MeasureMemory {
     }
 
     static Children generateNodeChild(int childCount) {
-        Children n = new Children(new String("_id"),new Revision(1, 2, 3));
+        Children n = new Children(new String("_id"), new Revision(1, 2, 3));
         for (int i = 0; i < childCount; i++) {
-            n.children.add("child"+i);
+            n.children.add("child" + i);
         }
         return n;
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MongoDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MongoDocumentStoreTest.java?rev=1491447&r1=1491446&r2=1491447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MongoDocumentStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/MongoDocumentStoreTest.java
Mon Jun 10 13:40:54 2013
@@ -54,7 +54,7 @@ public class MongoDocumentStoreTest {
 
     DocumentStore openDocumentStore() {
         if (MONGO_DB) {
-            return new MongoDocumentStore(MongoUtils.getConnection().getDB(),new MongoMK.Builder());
+            return new MongoDocumentStore(MongoUtils.getConnection().getDB(), new MongoMK.Builder());
         }
         return new MemoryDocumentStore();
     }
@@ -161,7 +161,7 @@ public class MongoDocumentStoreTest {
         op.set("prop", "value");
         op.containsMapEntry("map", "key", true);
         // update if key exists -> must succeed
-        Map doc = docStore.findAndUpdate(Collection.NODES, op);
+        Map<String, Object> doc = docStore.findAndUpdate(Collection.NODES, op);
         assertNotNull(doc);
 
         doc = docStore.find(Collection.NODES, "/node");



Mime
View raw message