activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r646877 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
Date Thu, 10 Apr 2008 17:14:07 GMT
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



Mime
View raw message