From 1973ca8f3edf83ca356496f5c4f197a1d7e1be05 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Thu, 29 May 2008 19:23:18 +0000 Subject: [PATCH] Fix the failing QueueMasterSlaveTestUsingSharedFileTest test.. due to chang in startup order of the persistence adapter. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@661439 13f79535-47bb-0310-9956-ffa450edef68 --- .../store/amq/AMQPersistenceAdapter.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java index 4132543abc..65dcf1b03e 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java @@ -128,6 +128,8 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, private FileLock lock; private boolean disableLocking = DISABLE_LOCKING; private boolean failIfJournalIsLocked; + private boolean lockLogged; + private boolean lockAquired; public String getBrokerName() { return this.brokerName; @@ -271,6 +273,14 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, } }; Scheduler.executePeriodically(periodicCleanupTask, cleanupInterval); + + if (lockAquired && lockLogged) { + LOG.info("Aquired lock for AMQ Store" + getDirectory()); + if (brokerService != null) { + brokerService.getBroker().nowMasterBroker(); + } + } + } public void stop() throws Exception { @@ -923,27 +933,20 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, protected void lock() throws Exception { - boolean logged = false; - boolean aquiredLock = false; + lockLogged = false; + lockAquired = false; do { if (doLock()) { - aquiredLock = true; + lockAquired = true; } else { - if (!logged) { + if (!lockLogged) { LOG.warn("Waiting to Lock the Store " + getDirectory()); - logged = true; + lockLogged = true; } Thread.sleep(1000); } - if (aquiredLock && logged) { - LOG.info("Aquired lock for AMQ Store" + getDirectory()); - if (brokerService != null) { - brokerService.getBroker().nowMasterBroker(); - } - } - - } while (!aquiredLock && !disableLocking); + } while (!lockAquired && !disableLocking); } private synchronized void unlock() throws IOException {