activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r509565 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java
Date Tue, 20 Feb 2007 14:01:23 GMT
Author: rajdavies
Date: Tue Feb 20 06:01:18 2007
New Revision: 509565

URL: http://svn.apache.org/viewvc?view=rev&rev=509565
Log:
add waiting to aquire a lock held by the store

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java?view=diff&rev=509565&r1=509564&r2=509565
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistenceAdapter.java
Tue Feb 20 06:01:18 2007
@@ -34,6 +34,7 @@
 import org.apache.activemq.kaha.MessageMarshaller;
 import org.apache.activemq.kaha.Store;
 import org.apache.activemq.kaha.StoreFactory;
+import org.apache.activemq.kaha.impl.StoreLockedExcpetion;
 import org.apache.activemq.memory.UsageManager;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.store.MessageStore;
@@ -50,7 +51,7 @@
  * @version $Revision: 1.4 $
  */
 public class KahaPersistenceAdapter implements PersistenceAdapter{
-
+    private static final int STORE_LOCKED_WAIT_DELAY = 10*1000;
     private static final Log log=LogFactory.getLog(KahaPersistenceAdapter.class);
     static final String PREPARED_TRANSACTIONS_NAME="PreparedTransactions";
     KahaTransactionStore transactionStore;
@@ -126,13 +127,25 @@
     }
 
     public TransactionStore createTransactionStore() throws IOException{
+       
         if(transactionStore==null){
+            while (true) {
+                try {
             Store store=getStore();
             MapContainer container=store.getMapContainer(PREPARED_TRANSACTIONS_NAME,"transactions");
             container.setKeyMarshaller(new CommandMarshaller(wireFormat));
             container.setValueMarshaller(new TransactionMarshaller(wireFormat));
             container.load();
             transactionStore=new KahaTransactionStore(this,container);
+            break;
+                }catch(StoreLockedExcpetion e) {
+                    log.info("Store is locked... waiting "+(STORE_LOCKED_WAIT_DELAY/1000)+"
seconds for the Store to be unlocked.");
+                    try{
+                        Thread.sleep(STORE_LOCKED_WAIT_DELAY);
+                    }catch(InterruptedException e1){
+                    }
+                }
+        }
         }
         return transactionStore;
     }



Mime
View raw message