Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 30561 invoked from network); 10 Apr 2008 17:14:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Apr 2008 17:14:31 -0000 Received: (qmail 97262 invoked by uid 500); 10 Apr 2008 17:14:32 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 97230 invoked by uid 500); 10 Apr 2008 17:14:32 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 97221 invoked by uid 99); 10 Apr 2008 17:14:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Apr 2008 10:14:32 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Apr 2008 17:13:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 394AC1A9832; Thu, 10 Apr 2008 10:14:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: rajdavies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080410171408.394AC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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