Search in sources :

Example 1 with ZooKeeperLocking

use of org.apache.carbondata.core.locks.ZooKeeperLocking 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());
}
Also used : ZooKeeperLocking(org.apache.carbondata.core.locks.ZooKeeperLocking) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) CarbonProperties(org.apache.carbondata.core.util.CarbonProperties) ZookeeperInit(org.apache.carbondata.core.locks.ZookeeperInit) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Aggregations

NonStrictExpectations (mockit.NonStrictExpectations)1 ZooKeeperLocking (org.apache.carbondata.core.locks.ZooKeeperLocking)1 ZookeeperInit (org.apache.carbondata.core.locks.ZookeeperInit)1 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)1 CarbonProperties (org.apache.carbondata.core.util.CarbonProperties)1 Test (org.junit.Test)1