Search in sources :

Example 1 with HBaseTransaction

use of com.thinkaurelius.titan.diskstorage.hbase.HBaseTransaction in project incubator-atlas by apache.

the class LocalLockMediatorTest method testLock.

@Test
public void testLock() throws InterruptedException {
    TimestampProvider times = Timestamps.MICRO;
    LocalLockMediator<HBaseTransaction> llm = new LocalLockMediator<>(LOCK_NAMESPACE, times);
    //Expire immediately
    Assert.assertTrue(llm.lock(kc, mockTx1, times.getTime(0, TimeUnit.NANOSECONDS)));
    Assert.assertTrue(llm.lock(kc, mockTx2, times.getTime(Long.MAX_VALUE, TimeUnit.NANOSECONDS)));
    llm = new LocalLockMediator<>(LOCK_NAMESPACE, times);
    //Expire later
    Assert.assertTrue(llm.lock(kc, mockTx1, times.getTime(Long.MAX_VALUE, TimeUnit.NANOSECONDS)));
    //So second lock should fail on same keyCol
    Assert.assertFalse(llm.lock(kc, mockTx2, times.getTime(Long.MAX_VALUE, TimeUnit.NANOSECONDS)));
    //Unlock
    Assert.assertTrue(llm.unlock(kc, mockTx1));
    //Now locking should succeed
    Assert.assertTrue(llm.lock(kc, mockTx2, times.getTime(Long.MAX_VALUE, TimeUnit.NANOSECONDS)));
}
Also used : TimestampProvider(com.thinkaurelius.titan.diskstorage.util.time.TimestampProvider) HBaseTransaction(com.thinkaurelius.titan.diskstorage.hbase.HBaseTransaction) Test(org.testng.annotations.Test)

Aggregations

HBaseTransaction (com.thinkaurelius.titan.diskstorage.hbase.HBaseTransaction)1 TimestampProvider (com.thinkaurelius.titan.diskstorage.util.time.TimestampProvider)1 Test (org.testng.annotations.Test)1