Search in sources :

Example 1 with ZookeeperBasedLockProvider

use of org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider in project hudi by apache.

the class TestZookeeperBasedLockProvider method testReentrantLock.

@Test
public void testReentrantLock() {
    ZookeeperBasedLockProvider zookeeperBasedLockProvider = new ZookeeperBasedLockProvider(lockConfiguration, client);
    Assertions.assertTrue(zookeeperBasedLockProvider.tryLock(lockConfiguration.getConfig().getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS));
    try {
        zookeeperBasedLockProvider.tryLock(lockConfiguration.getConfig().getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS);
        Assertions.fail();
    } catch (HoodieLockException e) {
    // expected
    }
    zookeeperBasedLockProvider.unlock();
}
Also used : HoodieLockException(org.apache.hudi.exception.HoodieLockException) ZookeeperBasedLockProvider(org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider) Test(org.junit.jupiter.api.Test)

Example 2 with ZookeeperBasedLockProvider

use of org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider in project hudi by apache.

the class TestZookeeperBasedLockProvider method testUnLock.

@Test
public void testUnLock() {
    ZookeeperBasedLockProvider zookeeperBasedLockProvider = new ZookeeperBasedLockProvider(lockConfiguration, client);
    Assertions.assertTrue(zookeeperBasedLockProvider.tryLock(lockConfiguration.getConfig().getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS));
    zookeeperBasedLockProvider.unlock();
    zookeeperBasedLockProvider.tryLock(lockConfiguration.getConfig().getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS);
}
Also used : ZookeeperBasedLockProvider(org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider) Test(org.junit.jupiter.api.Test)

Example 3 with ZookeeperBasedLockProvider

use of org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider in project hudi by apache.

the class TestZookeeperBasedLockProvider method testAcquireLock.

@Test
public void testAcquireLock() {
    ZookeeperBasedLockProvider zookeeperBasedLockProvider = new ZookeeperBasedLockProvider(lockConfiguration, client);
    Assertions.assertTrue(zookeeperBasedLockProvider.tryLock(lockConfiguration.getConfig().getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS));
    zookeeperBasedLockProvider.unlock();
}
Also used : ZookeeperBasedLockProvider(org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider) Test(org.junit.jupiter.api.Test)

Example 4 with ZookeeperBasedLockProvider

use of org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider in project hudi by apache.

the class TestZookeeperBasedLockProvider method testUnlockWithoutLock.

@Test
public void testUnlockWithoutLock() {
    ZookeeperBasedLockProvider zookeeperBasedLockProvider = new ZookeeperBasedLockProvider(lockConfiguration, client);
    zookeeperBasedLockProvider.unlock();
}
Also used : ZookeeperBasedLockProvider(org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider) Test(org.junit.jupiter.api.Test)

Aggregations

ZookeeperBasedLockProvider (org.apache.hudi.client.transaction.lock.ZookeeperBasedLockProvider)4 Test (org.junit.jupiter.api.Test)4 HoodieLockException (org.apache.hudi.exception.HoodieLockException)1