https://issues.apache.org/jira/browse/AMQ-4103 - fix default jdbc locker impl - same problem as lease after refactor from https://issues.apache.org/jira/browse/AMQ-4005

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1407621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-11-09 20:36:27 +00:00
parent 02ef3dc918
commit aac50fc57c
3 changed files with 19 additions and 12 deletions

View File

@ -31,9 +31,9 @@ public class DbRestartJDBCQueueMasterSlaveLeaseTest extends DbRestartJDBCQueueMa
@Override
protected void configureJdbcPersistenceAdapter(JDBCPersistenceAdapter persistenceAdapter) throws IOException {
super.configureJdbcPersistenceAdapter(persistenceAdapter);
persistenceAdapter.setLocker(new LeaseDatabaseLocker());
persistenceAdapter.getLocker().setLockAcquireSleepInterval(getLockAcquireSleepInterval());
persistenceAdapter.setLockKeepAlivePeriod(getLockKeepAlivePeriod());
persistenceAdapter.setLocker(new LeaseDatabaseLocker());
}
private long getLockKeepAlivePeriod() {

View File

@ -17,22 +17,15 @@
package org.apache.activemq.store.jdbc;
import org.apache.activemq.broker.AbstractLocker;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class LeaseDatabaseLockerConfigTest {
LeaseDatabaseLocker underTest;
@Before
public void setUpStore() throws Exception {
underTest = new LeaseDatabaseLocker();
}
public class DatabaseLockerConfigTest {
@Test
public void testSleepConfig() throws Exception {
LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
underTest.setLockAcquireSleepInterval(50);
underTest.configure(null);
assertEquals("configured sleep value retained", 50, underTest.getLockAcquireSleepInterval());
@ -40,6 +33,22 @@ public class LeaseDatabaseLockerConfigTest {
@Test
public void testDefaultSleepConfig() throws Exception {
LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
underTest.configure(null);
assertEquals("configured sleep value retained", AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, underTest.getLockAcquireSleepInterval());
}
@Test
public void testSleepConfigOrig() throws Exception {
DefaultDatabaseLocker underTest = new DefaultDatabaseLocker();
underTest.setLockAcquireSleepInterval(50);
underTest.configure(null);
assertEquals("configured sleep value retained", 50, underTest.getLockAcquireSleepInterval());
}
@Test
public void testDefaultSleepConfigOrig() throws Exception {
DefaultDatabaseLocker underTest = new DefaultDatabaseLocker();
underTest.configure(null);
assertEquals("configured sleep value retained", AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, underTest.getLockAcquireSleepInterval());
}

View File

@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
*
*/
public class DefaultDatabaseLocker extends AbstractLocker {
public static final long DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL = 1000;
private static final Logger LOG = LoggerFactory.getLogger(DefaultDatabaseLocker.class);
protected DataSource dataSource;
protected Statements statements;
@ -56,7 +55,6 @@ public class DefaultDatabaseLocker extends AbstractLocker {
this.dataSource = ((JDBCPersistenceAdapter) adapter).getLockDataSource();
this.statements = ((JDBCPersistenceAdapter) adapter).getStatements();
}
lockAcquireSleepInterval = DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL;
}
public void doStart() throws Exception {