diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-04-10 22:18:02 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-04-10 22:18:02 +0000 |
| commit | 8d1c8e86ca56069aa7fe26ac08c3a5187e1f7929 (patch) | |
| tree | 6d2d95ecc710a1470c9595331617f82c96c5a83b /qpid/java/broker/src | |
| parent | b24e3ba7ce3b25775280e9066496ed3b7b830843 (diff) | |
| download | qpid-python-8d1c8e86ca56069aa7fe26ac08c3a5187e1f7929.tar.gz | |
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.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@764083 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src')
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java index 21073c22ae..b53d5a99ee 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java @@ -138,16 +138,39 @@ public class FileQueueBackingStoreFactory implements QueueBackingStoreFactory 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 @@ public class FileQueueBackingStoreFactory implements QueueBackingStoreFactory 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(); |
