You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2008/04/10 19:14:07 UTC

svn commit: r646877 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java

Author: rajdavies
Date: Thu Apr 10 10:13:55 2008
New Revision: 646877

URL: http://svn.apache.org/viewvc?rev=646877&view=rev
Log:
move back to acquire lock before opening initializing index managers

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java?rev=646877&r1=646876&r2=646877&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java Thu Apr 10 10:13:55 2008
@@ -82,6 +82,7 @@
     private long maxDataFileLength = 1024 * 1024 * 32;
     private FileLock lock;
     private boolean persistentIndex = true;
+    private RandomAccessFile lockFile;
     private final AtomicLong storeSize;
     private String defaultContainerName = DEFAULT_CONTAINER_NAME;
 
@@ -110,6 +111,9 @@
             closed = true;
             if (initialized) {
                 unlock();
+                if (lockFile!=null) {
+                    lockFile.close();
+                }
                 for (ListContainerImpl container : lists.values()) {
                     container.close();
                 }
@@ -468,9 +472,10 @@
         }
         if (!initialized) {       
             LOG.info("Kaha Store using data directory " + directory);
+            lockFile = new RandomAccessFile(new File(directory, "lock"), "rw");
+            lock();
             DataManager defaultDM = getDataManager(defaultContainerName);
             rootIndexManager = getIndexManager(defaultDM, defaultContainerName);
-            lock();
             IndexItem mapRoot = new IndexItem();
             IndexItem listRoot = new IndexItem();
             if (rootIndexManager.isEmpty()) {
@@ -505,7 +510,7 @@
                 String property = System.getProperty(key);
                 if (null == property) {
                     if (!BROKEN_FILE_LOCK) {
-                        lock = rootIndexManager.getLock();
+                        lock = lockFile.getChannel().tryLock();
                         if (lock == null) {
                             throw new StoreLockedExcpetion("Kaha Store " + directory.getName() + "  is already opened by another application");
                         } else