Search in sources :

Example 26 with LockRequest

use of org.apache.hadoop.hive.metastore.api.LockRequest 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"));
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockResponse(org.apache.hadoop.hive.metastore.api.LockResponse) ArrayList(java.util.ArrayList) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) CheckLockRequest(org.apache.hadoop.hive.metastore.api.CheckLockRequest) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) NoSuchTxnException(org.apache.hadoop.hive.metastore.api.NoSuchTxnException) NoSuchLockException(org.apache.hadoop.hive.metastore.api.NoSuchLockException) TxnAbortedException(org.apache.hadoop.hive.metastore.api.TxnAbortedException) SQLException(java.sql.SQLException) TxnOpenException(org.apache.hadoop.hive.metastore.api.TxnOpenException) Test(org.junit.Test)

Example 27 with LockRequest

use of org.apache.hadoop.hive.metastore.api.LockRequest 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);
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 28 with LockRequest

use of org.apache.hadoop.hive.metastore.api.LockRequest 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());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 29 with LockRequest

use of org.apache.hadoop.hive.metastore.api.LockRequest 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());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Example 30 with LockRequest

use of org.apache.hadoop.hive.metastore.api.LockRequest 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());
}
Also used : LockComponent(org.apache.hadoop.hive.metastore.api.LockComponent) LockRequest(org.apache.hadoop.hive.metastore.api.LockRequest) Test(org.junit.Test)

Aggregations

LockRequest (org.apache.hadoop.hive.metastore.api.LockRequest)96 LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)94 Test (org.junit.Test)94 LockResponse (org.apache.hadoop.hive.metastore.api.LockResponse)59 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