lock = lockFactory.create(fileLockName, false); if (!lock.tryLock()) throw new RuntimeException("To avoid reading partial data we need to obtain the read lock but it failed. In " + ghLocation, lock.getObtainFailedReason());
if (ghStorage.getDirectory().getDefaultType().isStoring()) { lockFactory.setLockDir(new File(graphHopperLocation)); lock = lockFactory.create(fileLockName, true); if (!lock.tryLock()) throw new RuntimeException("To avoid multiple writers we need to obtain a write lock but it failed. In " + graphHopperLocation, lock.getObtainFailedReason());
LockFactory instance = createLockFactory(); instance.setLockDir(lockDir); GHLock writeLock1 = instance.create("test", true); assertTrue(writeLock1.tryLock()); GHLock lock2 = instance.create("test", false); assertFalse(lock2.tryLock()); GHLock writeLock4 = instance.create("test", true); assertFalse(writeLock4.tryLock()); assertEquals(OverlappingFileLockException.class, writeLock4.getObtainFailedReason().getClass());
@Test public void testObtain() { LockFactory instance = createLockFactory(); instance.setLockDir(lockDir); GHLock lock = instance.create("test", true); assertTrue(lock.tryLock()); assertTrue(lock.isLocked()); assertFalse(lock.tryLock()); assertTrue(lock.isLocked()); GHLock lock2 = instance.create("test", true); assertFalse(lock2.tryLock()); assertTrue(lock2.isLocked()); // fails for SimpleFSLockFactory: // although it is locked do not allow release: // lock2.release(); // assertTrue(lock.isLocked()); lock.release(); assertFalse(lock.isLocked()); }
@Test public void testForceDelete() { LockFactory instance = createLockFactory(); instance.setLockDir(lockDir); GHLock lock = instance.create("testlock", true); assertTrue(lock.tryLock()); assertTrue(lock.isLocked()); // on windows we cannot forcefully remove an unreleased lock if (Constants.WINDOWS) lock.release(); instance.forceRemove(lock.getName(), true); assertFalse(lock.isLocked()); } }
lock = lockFactory.create(fileLockName, false); if (!lock.tryLock()) throw new RuntimeException("To avoid reading partial data we need to obtain the read lock but it failed. In " + ghLocation, lock.getObtainFailedReason());
if (ghStorage.getDirectory().getDefaultType().isStoring()) { lockFactory.setLockDir(new File(graphHopperLocation)); lock = lockFactory.create(fileLockName, true); if (!lock.tryLock()) throw new RuntimeException("To avoid multiple writers we need to obtain a write lock but it failed. In " + graphHopperLocation, lock.getObtainFailedReason());
lock = lockFactory.create(fileLockName, false); if (!lock.tryLock()) throw new RuntimeException("To avoid reading partial data we need to obtain the read lock but it failed. In " + ghLocation, lock.getObtainFailedReason());
lock = lockFactory.create(fileLockName, false); if (!lock.tryLock()) throw new RuntimeException("To avoid reading partial data we need to obtain the read lock but it failed. In " + ghLocation, lock.getObtainFailedReason());
if (ghStorage.getDirectory().getDefaultType().isStoring()) { lockFactory.setLockDir(new File(graphHopperLocation)); lock = lockFactory.create(fileLockName, true); if (!lock.tryLock()) throw new RuntimeException("To avoid multiple writers we need to obtain a write lock but it failed. In " + graphHopperLocation, lock.getObtainFailedReason());
lock = lockFactory.create(fileLockName, true); if (!lock.tryLock()) throw new RuntimeException("To avoid multiple writers we need to obtain a write lock but it failed. In " + graphHopperLocation, lock.getObtainFailedReason());