Search in sources :

Example 1 with HeartbeatRequest

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

the class TestTxnHandler method testHeartbeatNoLock.

@Test
public void testHeartbeatNoLock() throws Exception {
    HeartbeatRequest h = new HeartbeatRequest();
    h.setLockid(29389839L);
    try {
        txnHandler.heartbeat(h);
        fail("Told there was a lock, when there wasn't.");
    } catch (NoSuchLockException e) {
    }
}
Also used : NoSuchLockException(org.apache.hadoop.hive.metastore.api.NoSuchLockException) HeartbeatRequest(org.apache.hadoop.hive.metastore.api.HeartbeatRequest) Test(org.junit.Test)

Example 2 with HeartbeatRequest

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

the class TestTxnHandler method testHeartbeatNoTxn.

@Test
public void testHeartbeatNoTxn() throws Exception {
    // Test that when a transaction is aborted, the heartbeat fails
    HeartbeatRequest h = new HeartbeatRequest();
    h.setTxnid(939393L);
    try {
        txnHandler.heartbeat(h);
        fail("Told there was a txn, when there wasn't.");
    } catch (NoSuchTxnException e) {
    }
}
Also used : NoSuchTxnException(org.apache.hadoop.hive.metastore.api.NoSuchTxnException) HeartbeatRequest(org.apache.hadoop.hive.metastore.api.HeartbeatRequest) Test(org.junit.Test)

Example 3 with HeartbeatRequest

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

the class TestTxnHandler method testHeartbeatLock.

@Test
public void testHeartbeatLock() throws Exception {
    conf.setTimeVar(HiveConf.ConfVars.HIVE_TXN_TIMEOUT, 1, TimeUnit.SECONDS);
    HeartbeatRequest h = new HeartbeatRequest();
    LockComponent comp = new LockComponent(LockType.EXCLUSIVE, LockLevel.DB, "mydb");
    comp.setTablename("mytable");
    comp.setPartitionname("mypartition=myvalue");
    comp.setOperationType(DataOperationType.NO_TXN);
    List<LockComponent> components = new ArrayList<LockComponent>(1);
    components.add(comp);
    LockRequest req = new LockRequest(components, "me", "localhost");
    LockResponse res = txnHandler.lock(req);
    assertTrue(res.getState() == LockState.ACQUIRED);
    h.setLockid(res.getLockid());
    for (int i = 0; i < 30; i++) {
        try {
            txnHandler.heartbeat(h);
        } catch (NoSuchLockException e) {
            fail("Told there was no lock, when the heartbeat should have kept it.");
        }
    }
}
Also used : NoSuchLockException(org.apache.hadoop.hive.metastore.api.NoSuchLockException) 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) HeartbeatRequest(org.apache.hadoop.hive.metastore.api.HeartbeatRequest) Test(org.junit.Test)

Example 4 with HeartbeatRequest

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

the class TestTxnHandler method testHeartbeatTxnAborted.

@Test
public void testHeartbeatTxnAborted() throws Exception {
    // Test that when a transaction is aborted, the heartbeat fails
    openTxn();
    txnHandler.abortTxn(new AbortTxnRequest(1));
    HeartbeatRequest h = new HeartbeatRequest();
    h.setTxnid(1);
    try {
        txnHandler.heartbeat(h);
        fail("Told there was a txn, when it should have been aborted.");
    } catch (TxnAbortedException e) {
    }
}
Also used : TxnAbortedException(org.apache.hadoop.hive.metastore.api.TxnAbortedException) AbortTxnRequest(org.apache.hadoop.hive.metastore.api.AbortTxnRequest) HeartbeatRequest(org.apache.hadoop.hive.metastore.api.HeartbeatRequest) Test(org.junit.Test)

Aggregations

HeartbeatRequest (org.apache.hadoop.hive.metastore.api.HeartbeatRequest)4 Test (org.junit.Test)4 NoSuchLockException (org.apache.hadoop.hive.metastore.api.NoSuchLockException)2 ArrayList (java.util.ArrayList)1 AbortTxnRequest (org.apache.hadoop.hive.metastore.api.AbortTxnRequest)1 CheckLockRequest (org.apache.hadoop.hive.metastore.api.CheckLockRequest)1 LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)1 LockRequest (org.apache.hadoop.hive.metastore.api.LockRequest)1 LockResponse (org.apache.hadoop.hive.metastore.api.LockResponse)1 NoSuchTxnException (org.apache.hadoop.hive.metastore.api.NoSuchTxnException)1 TxnAbortedException (org.apache.hadoop.hive.metastore.api.TxnAbortedException)1