fix intermittent failure of LeaseDatabaseLockerTest and fix log messge with lease expiry time

This commit is contained in:
gtully 2014-12-16 13:35:04 +00:00
parent fc3bb5c659
commit f57fd7daad
2 changed files with 3 additions and 2 deletions

View File

@ -105,7 +105,7 @@ public class LeaseDatabaseLocker extends AbstractJDBCLocker {
throw new RuntimeException(getLeaseHolderId() + " failing lease acquire due to stop");
}
LOG.info(getLeaseHolderId() + ", becoming master with lease expiry " + new Date(now) + " on dataSource: " + dataSource);
LOG.info(getLeaseHolderId() + ", becoming master with lease expiry " + new Date(now + lockAcquireSleepInterval) + " on dataSource: " + dataSource);
}
private void reportLeasOwnerShipAndDuration(Connection connection) throws SQLException {

View File

@ -108,7 +108,7 @@ public class LeaseDatabaseLockerTest {
}
});
TimeUnit.MILLISECONDS.sleep(lockerB.getLockAcquireSleepInterval());
TimeUnit.MILLISECONDS.sleep(lockerB.getLockAcquireSleepInterval() / 2);
assertTrue("B is blocked", blocked.get());
assertTrue("A is good", lockerA.keepAlive());
@ -129,6 +129,7 @@ public class LeaseDatabaseLockerTest {
// build a fake lock
final String fakeId = "Anon";
final Connection connection = dataSource.getConnection();
printLockTable(connection);
PreparedStatement statement = connection.prepareStatement(jdbc.getStatements().getLeaseObtainStatement());
final long now = System.currentTimeMillis();