Search in sources :

Example 36 with LockComponent

use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.

the class TestLockRequestBuilder method testExSRDb.

// Test that existing exclusive db with new shared_read coalesces to
// exclusive
@Test
public void testExSRDb() {
    LockRequestBuilder bldr = new LockRequestBuilder();
    LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    bldr.addLockComponent(comp).setUser("fred");
    comp = new LockComponent(LockType.SHARED_READ, LockLevel.DB, "mydb");
    bldr.addLockComponent(comp);
    LockRequest req = bldr.build();
    List<LockComponent> locks = req.getComponent();
    Assert.assertEquals(1, locks.size());
    Assert.assertEquals(LockType.EXCLUSIVE, locks.get(0).getType());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 37 with LockComponent

use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.

the class TestLockRequestBuilder method testSRSRTable.

// Test that existing shared_read table with new shared_read coalesces to
// shared_read
@Test
public void testSRSRTable() {
    LockRequestBuilder bldr = new LockRequestBuilder();
    LockComponent comp = new LockComponent(LockType.SHARED_READ, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    bldr.addLockComponent(comp);
    comp = new LockComponent(LockType.SHARED_READ, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    bldr.addLockComponent(comp).setUser("fred");
    LockRequest req = bldr.build();
    List<LockComponent> locks = req.getComponent();
    Assert.assertEquals(1, locks.size());
    Assert.assertEquals(LockType.SHARED_READ, locks.get(0).getType());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 38 with LockComponent

use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.

the class TestLockRequestBuilder method testSWExPart.

// Test that existing shared_write partition with new exclusive coalesces to
// exclusive
@Test
public void testSWExPart() {
    LockRequestBuilder bldr = new LockRequestBuilder();
    LockComponent comp = new LockComponent(LockType.SHARED_WRITE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    comp.setPartitionname("mypart");
    bldr.addLockComponent(comp);
    comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    comp.setPartitionname("mypart");
    bldr.addLockComponent(comp).setUser("fred");
    LockRequest req = bldr.build();
    List<LockComponent> locks = req.getComponent();
    Assert.assertEquals(1, locks.size());
    Assert.assertEquals(LockType.EXCLUSIVE, locks.get(0).getType());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 39 with LockComponent

use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.

the class TestLockRequestBuilder method testSWExTable.

// Test that existing shared_write table with new exclusive coalesces to
// exclusive
@Test
public void testSWExTable() {
    LockRequestBuilder bldr = new LockRequestBuilder();
    LockComponent comp = new LockComponent(LockType.SHARED_WRITE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    bldr.addLockComponent(comp);
    comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    bldr.addLockComponent(comp).setUser("fred");
    LockRequest req = bldr.build();
    List<LockComponent> locks = req.getComponent();
    Assert.assertEquals(1, locks.size());
    Assert.assertEquals(LockType.EXCLUSIVE, locks.get(0).getType());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 40 with LockComponent

use of org.apache.hadoop.hive.metastore.api.LockComponent in project hive by apache.

the class TestLockRequestBuilder method testTablePartition.

// Test that database and table don't coalesce.
@Test
public void testTablePartition() {
    LockRequestBuilder bldr = new LockRequestBuilder();
    LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    bldr.addLockComponent(comp).setUser(null);
    comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    comp.setPartitionname("mypartition");
    bldr.addLockComponent(comp);
    LockRequest req = bldr.build();
    List<LockComponent> locks = req.getComponent();
    Assert.assertEquals(2, locks.size());
    Assert.assertEquals("unknown", req.getUser());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Aggregations

LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)94 LockRequest (org.apache.hadoop.hive.metastore.api.LockRequest)94 Test (org.junit.Test)93 LockResponse (org.apache.hadoop.hive.metastore.api.LockResponse)58 ArrayList (java.util.ArrayList)57 CheckLockRequest (org.apache.hadoop.hive.metastore.api.CheckLockRequest)32 Table (org.apache.hadoop.hive.metastore.api.Table)24 ShowCompactRequest (org.apache.hadoop.hive.metastore.api.ShowCompactRequest)22 ShowCompactResponse (org.apache.hadoop.hive.metastore.api.ShowCompactResponse)22 ShowCompactResponseElement (org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement)17 CommitTxnRequest (org.apache.hadoop.hive.metastore.api.CommitTxnRequest)15 AbortTxnRequest (org.apache.hadoop.hive.metastore.api.AbortTxnRequest)11 Partition (org.apache.hadoop.hive.metastore.api.Partition)10 CompactionRequest (org.apache.hadoop.hive.metastore.api.CompactionRequest)6 UnlockRequest (org.apache.hadoop.hive.metastore.api.UnlockRequest)5 NoSuchLockException (org.apache.hadoop.hive.metastore.api.NoSuchLockException)4 CompactionInfo (org.apache.hadoop.hive.metastore.txn.CompactionInfo)4 GetOpenTxnsResponse (org.apache.hadoop.hive.metastore.api.GetOpenTxnsResponse)3 OpenTxnRequest (org.apache.hadoop.hive.metastore.api.OpenTxnRequest)3 HashMap (java.util.HashMap)2