use of org.apache.carbondata.core.locks.ZookeeperInit in project carbondata by apache.
the class ZooKeeperLockingTest method testZooKeeperLockingByTryingToAcquire2Locks.
@Test
public void testZooKeeperLockingByTryingToAcquire2Locks() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
final CarbonProperties cp = CarbonProperties.getInstance();
new NonStrictExpectations(cp) {
{
cp.getProperty("/CarbonLocks");
result = "/carbontests";
cp.getProperty("spark.deploy.zookeeper.url");
result = "127.0.0.1:" + freePort;
}
};
ZookeeperInit zki = ZookeeperInit.getInstance("127.0.0.1:" + freePort);
CarbonTableIdentifier tableIdentifier = new CarbonTableIdentifier("dbName", "tableName", "tableId");
ZooKeeperLocking zkl = new ZooKeeperLocking(tableIdentifier, LockUsage.METADATA_LOCK);
Assert.assertTrue(zkl.lock());
ZooKeeperLocking zk2 = new ZooKeeperLocking(tableIdentifier, LockUsage.METADATA_LOCK);
Assert.assertTrue(!zk2.lock());
Assert.assertTrue(zkl.unlock());
Assert.assertTrue(zk2.lock());
Assert.assertTrue(zk2.unlock());
}
Aggregations