You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/04/11 02:49:40 UTC

svn commit: r764124 - in /qpid/branches/0.5-release/qpid/java: broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java systests/src/main/java/org/apache/qpid/server/failure/Create32kQueueWithoutFailure.java

Author: ritchiem
Date: Sat Apr 11 00:49:40 2009
New Revision: 764124

URL: http://svn.apache.org/viewvc?rev=764124&view=rev
Log:
QPID-1805 : Updated BackingStore to error if we cannot create the backing store. Also updated so that we store the queues evenly over 256 bins, thus giving us the ability to have around 8.1 million actives queues. The Hash function was borrowed from Apache Harmony. Added manual testing to ensure we are not limited by Linux's max file/dir per Inode of 31998. Made the test manual as creating 32000 queues does take a little while.

merged from trunk r764083


Added:
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/Create32kQueueWithoutFailure.java
      - copied unchanged from r764083, qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/Create32kQueueWithoutFailure.java
Modified:
    qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java

Modified: qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java?rev=764124&r1=764123&r2=764124&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java (original)
+++ qpid/branches/0.5-release/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java Sat Apr 11 00:49:40 2009
@@ -138,16 +138,39 @@
         return createStore(name, 0);
     }
 
+    /**
+     * Returns a hash code for non-null Object x.
+     * Uses the same hash code spreader as most other java.util hash tables.
+     *
+     * Borrowed from the Apache Harmony project
+     * @param x the object serving as a key
+     * @return the hash code
+     */
+    public static int hash(Object x) {
+        int h = x.hashCode();
+        h += ~(h << 9);
+        h ^=  (h >>> 14);
+        h +=  (h << 4);
+        h ^=  (h >>> 10);
+        return h;
+    }
+
     private String createStore(String name, int index)
     {
 
-        String store = _flowToDiskLocation + File.separator + name;
+        int hash = hash(name);
+
+        long bin = hash & 0xFFL;
+
+        String store = _flowToDiskLocation + File.separator + bin + File.separator + name;
+
         if (index > 0)
         {
             store += "-" + index;
         }
 
-        //TODO ensure store is safe for the OS
+        //TODO ensure name is safe for the OS i.e. on OSX you can't have any ':'
+        // Does java take care of this?
 
         File storeFile = new File(store);
 
@@ -156,7 +179,12 @@
             return createStore(name, index + 1);
         }
 
-        storeFile.mkdirs();
+        // Ensure we report an error if we cannot create the backing store.
+        if (!storeFile.mkdirs())
+        {
+            _log.error("Unable to create queue backing directory for queue:" + name);
+            throw new RuntimeException("Unable to create queue backing directory for queue:" + name);
+        }
 
         storeFile.deleteOnExit();
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org