Author: thomasm
Date: Wed Mar 26 09:52:04 2014
New Revision: 1581771

URL: http://svn.apache.org/r1581771
Log:
OAK-1602 512 byte shard key limit in MongoMK

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java?rev=1581771&r1=1581770&r2=1581771&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
 Wed Mar 26 09:52:04 2014
@@ -55,14 +55,19 @@ public class Utils {
      * possibly be too large to be used for the primary key for the document
      * store.
      */
-    private static final int PATH_SHORT = Integer.getInteger("oak.pathShort", 
330);
+    private static final int PATH_SHORT = Integer.getInteger("oak.pathShort", 
165);
 
     /**
      * The maximum length of the parent path, in bytes. If the parent path is
      * longer, then the id of a document is no longer the path, but the hash of
      * the parent, and then the node name.
      */
-    private static final int PATH_LONG = Integer.getInteger("oak.pathLong", 
700);
+    private static final int PATH_LONG = Integer.getInteger("oak.pathLong", 
350);
+
+    /**
+     * The maximum size a node name, in bytes. This is only a problem for long 
path.
+     */
+    private static final int NODE_NAME_LIMIT = 
Integer.getInteger("oak.nodeNameLimit", 150);
 
     private static final Charset UTF_8 = Charset.forName("UTF-8");
 
@@ -258,6 +263,10 @@ public class Utils {
         if (parent.length < PATH_LONG) {
             return false;
         }
+        String name = PathUtils.getName(path);
+        if (name.getBytes(UTF_8).length > NODE_NAME_LIMIT) {
+            throw new IllegalArgumentException("Node name is too long: " + 
path);
+        }
         return true;
     }
     


Reply via email to