activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r783384 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/kahadb/MessageDatabase.java test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
Date Wed, 10 Jun 2009 14:59:03 GMT
Author: gtully
Date: Wed Jun 10 14:59:02 2009
New Revision: 783384

URL: http://svn.apache.org/viewvc?rev=783384&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2285 - pull file locking outside setting
opened state so that an open does not ocurr unless the lock is available, sorts out Npe on
shutdown

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java?rev=783384&r1=783383&r2=783384&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
Wed Jun 10 14:59:02 2009
@@ -218,26 +218,25 @@
 	 * @throws IOException
 	 */
 	public void open() throws IOException {
+		File lockFileName = new File(directory, "lock");
+		lockFile = new LockFile(lockFileName, true);
+		if (failIfDatabaseIsLocked) {
+		    lockFile.lock();
+		} else {
+		    while (true) {
+		        try {
+		            lockFile.lock();
+		            break;
+		        } catch (IOException e) {
+		            LOG.info("Database "+lockFileName+" is locked... waiting " + (DATABASE_LOCKED_WAIT_DELAY
/ 1000) + " seconds for the database to be unlocked. Reason: " + e);
+		            try {
+		                Thread.sleep(DATABASE_LOCKED_WAIT_DELAY);
+		            } catch (InterruptedException e1) {
+		            }
+		        }
+		    }
+		}
 		if( opened.compareAndSet(false, true) ) {
-            File lockFileName = new File(directory, "lock");
-            lockFile = new LockFile(lockFileName, true);
-	        if (failIfDatabaseIsLocked) {
-	            lockFile.lock();
-	        } else {
-	            while (true) {
-	                try {
-	                    lockFile.lock();
-	                    break;
-	                } catch (IOException e) {
-	                    LOG.info("Database "+lockFileName+" is locked... waiting " + (DATABASE_LOCKED_WAIT_DELAY
/ 1000) + " seconds for the database to be unlocked. Reason: " + e);
-	                    try {
-	                        Thread.sleep(DATABASE_LOCKED_WAIT_DELAY);
-	                    } catch (InterruptedException e1) {
-	                    }
-	                }
-	            }
-	        }
-	        
             getJournal().start();
             
 	        loadPageFile();
@@ -312,7 +311,7 @@
 	
     public void unload() throws IOException, InterruptedException {
         synchronized (indexMutex) {
-            if( pageFile.isLoaded() ) {
+            if( pageFile != null && pageFile.isLoaded() ) {
                 metadata.state = CLOSED_STATE;
                 metadata.firstInProgressTransactionLocation = getFirstInProgressTxLocation();
     

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java?rev=783384&r1=783383&r2=783384&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
Wed Jun 10 14:59:02 2009
@@ -17,11 +17,9 @@
 package org.apache.activemq.store.kahadb;
 
 import java.io.File;
-import java.net.URI;
 
 import junit.framework.Test;
 
-import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.BrokerTest;
 



Mime
View raw message