use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.
the class TestTxnHandler method testWrongLockForOperation.
@Test
public void testWrongLockForOperation() throws Exception {
LockComponent comp = new LockComponent(LockType.SHARED_WRITE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
comp.setPartitionname("mypartition");
comp.setOperationType(DataOperationType.NO_TXN);
List<LockComponent> components = new ArrayList<LockComponent>(1);
components.add(comp);
LockRequest req = new LockRequest(components, "me", "localhost");
req.setTxnid(openTxn());
Exception expectedError = null;
try {
LockResponse res = txnHandler.lock(req);
} catch (Exception e) {
expectedError = e;
}
Assert.assertTrue(expectedError != null && expectedError.getMessage().contains("Unexpected DataOperationType"));
}
use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.
the class TestLockRequestBuilder method noUser.
// Test failure if user not set
@Test
public void noUser() {
LockRequestBuilder bldr = new LockRequestBuilder();
LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
bldr.addLockComponent(comp);
comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
bldr.addLockComponent(comp);
boolean caughtException = false;
try {
LockRequest req = bldr.build();
} catch (RuntimeException e) {
Assert.assertEquals("Cannot build a lock without giving a user", e.getMessage());
caughtException = true;
}
Assert.assertTrue(caughtException);
}
use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.
the class TestLockRequestBuilder method testTwoSeparateTables.
// Test that 2 separate tables don't coalesce.
@Test
public void testTwoSeparateTables() {
LockRequestBuilder bldr = new LockRequestBuilder();
LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
bldr.addLockComponent(comp);
comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("yourtable");
bldr.addLockComponent(comp).setUser("fred");
LockRequest req = bldr.build();
List<LockComponent> locks = req.getComponent();
Assert.assertEquals(2, locks.size());
}
use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.
the class TestLockRequestBuilder method testTwoSeparateDbs.
// Test that 2 separate databases don't coalesce.
@Test
public void testTwoSeparateDbs() {
LockRequestBuilder bldr = new LockRequestBuilder();
LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
bldr.addLockComponent(comp).setUser("fred");
comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "yourdb");
bldr.addLockComponent(comp);
LockRequest req = bldr.build();
List<LockComponent> locks = req.getComponent();
Assert.assertEquals(2, locks.size());
}
use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.
the class TestLockRequestBuilder method testDbTable.
// Test that database and table don't coalesce.
@Test
public void testDbTable() throws Exception {
LockRequestBuilder bldr = new LockRequestBuilder();
LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
bldr.addLockComponent(comp).setUser("fred");
comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
comp.setTablename("mytable");
bldr.addLockComponent(comp);
LockRequest req = bldr.build();
List<LockComponent> locks = req.getComponent();
Assert.assertEquals(2, locks.size());
Assert.assertEquals("fred", req.getUser());
Assert.assertEquals(InetAddress.getLocalHost().getHostName(), req.getHostname());
}
Aggregations