use of org.apache.hudi.client.transaction.lock.InProcessLockProvider in project hudi by apache.
the class TestInProcessLockProvider method testRedundantUnlock.
@Test
public void testRedundantUnlock() {
InProcessLockProvider inProcessLockProvider = new InProcessLockProvider(lockConfiguration, hadoopConfiguration);
assertDoesNotThrow(() -> {
inProcessLockProvider.lock();
});
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
}
use of org.apache.hudi.client.transaction.lock.InProcessLockProvider in project hudi by apache.
the class TestInProcessLockProvider method testLockReAcquisitionByDifferentThread.
@Test
public void testLockReAcquisitionByDifferentThread() {
InProcessLockProvider inProcessLockProvider = new InProcessLockProvider(lockConfiguration, hadoopConfiguration);
final AtomicBoolean writer2Completed = new AtomicBoolean(false);
// Main test thread
assertDoesNotThrow(() -> {
inProcessLockProvider.lock();
});
// Another writer thread in parallel, should block
// and later acquire the lock once it is released
Thread writer2 = new Thread(new Runnable() {
@Override
public void run() {
assertDoesNotThrow(() -> {
inProcessLockProvider.lock();
});
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
writer2Completed.set(true);
}
});
writer2.start();
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
try {
writer2.join();
} catch (InterruptedException e) {
//
}
Assertions.assertTrue(writer2Completed.get());
}
use of org.apache.hudi.client.transaction.lock.InProcessLockProvider in project hudi by apache.
the class TestInProcessLockProvider method testLockReAcquisitionBySameThread.
@Test
public void testLockReAcquisitionBySameThread() {
InProcessLockProvider inProcessLockProvider = new InProcessLockProvider(lockConfiguration, hadoopConfiguration);
assertDoesNotThrow(() -> {
inProcessLockProvider.lock();
});
assertThrows(HoodieLockException.class, () -> {
inProcessLockProvider.lock();
});
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
}
use of org.apache.hudi.client.transaction.lock.InProcessLockProvider in project hudi by apache.
the class TestInProcessLockProvider method testTryLockReAcquisitionByDifferentThread.
@Test
public void testTryLockReAcquisitionByDifferentThread() {
InProcessLockProvider inProcessLockProvider = new InProcessLockProvider(lockConfiguration, hadoopConfiguration);
final AtomicBoolean writer2Completed = new AtomicBoolean(false);
// Main test thread
Assertions.assertTrue(inProcessLockProvider.tryLock());
// Another writer thread
Thread writer2 = new Thread(() -> {
Assertions.assertFalse(inProcessLockProvider.tryLock(100L, TimeUnit.MILLISECONDS));
writer2Completed.set(true);
});
writer2.start();
try {
writer2.join();
} catch (InterruptedException e) {
//
}
Assertions.assertTrue(writer2Completed.get());
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
}
use of org.apache.hudi.client.transaction.lock.InProcessLockProvider in project hudi by apache.
the class TestInProcessLockProvider method testTryLockAcquisition.
@Test
public void testTryLockAcquisition() {
InProcessLockProvider inProcessLockProvider = new InProcessLockProvider(lockConfiguration, hadoopConfiguration);
Assertions.assertTrue(inProcessLockProvider.tryLock());
assertDoesNotThrow(() -> {
inProcessLockProvider.unlock();
});
}
Aggregations