Search in sources :

Example 1 with HeartbeatTxnRangeResponse

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

the class TestTxnHandler method heartbeatTxnRangeOneAborted.

@Test
public void heartbeatTxnRangeOneAborted() throws Exception {
    long txnid = openTxn();
    assertEquals(1, txnid);
    txnid = openTxn();
    txnid = openTxn();
    txnHandler.abortTxn(new AbortTxnRequest(3));
    HeartbeatTxnRangeResponse rsp = txnHandler.heartbeatTxnRange(new HeartbeatTxnRangeRequest(1, 3));
    assertEquals(1, rsp.getAbortedSize());
    Long txn = rsp.getAborted().iterator().next();
    assertEquals(3L, (long) txn);
    assertEquals(0, rsp.getNosuch().size());
}
Also used : HeartbeatTxnRangeResponse(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse) HeartbeatTxnRangeRequest(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeRequest) AbortTxnRequest(org.apache.hadoop.hive.metastore.api.AbortTxnRequest) Test(org.junit.Test)

Example 2 with HeartbeatTxnRangeResponse

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

the class TestTxnHandler method heartbeatTxnRange.

@Test
public void heartbeatTxnRange() throws Exception {
    long txnid = openTxn();
    assertEquals(1, txnid);
    txnid = openTxn();
    txnid = openTxn();
    HeartbeatTxnRangeResponse rsp = txnHandler.heartbeatTxnRange(new HeartbeatTxnRangeRequest(1, 3));
    assertEquals(0, rsp.getAborted().size());
    assertEquals(0, rsp.getNosuch().size());
}
Also used : HeartbeatTxnRangeResponse(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse) HeartbeatTxnRangeRequest(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeRequest) Test(org.junit.Test)

Example 3 with HeartbeatTxnRangeResponse

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

the class TestTxnHandler method heartbeatTxnRangeOneCommitted.

@Test
public void heartbeatTxnRangeOneCommitted() throws Exception {
    long txnid = openTxn();
    assertEquals(1, txnid);
    txnHandler.commitTxn(new CommitTxnRequest(1));
    txnid = openTxn();
    txnid = openTxn();
    HeartbeatTxnRangeResponse rsp = txnHandler.heartbeatTxnRange(new HeartbeatTxnRangeRequest(1, 3));
    assertEquals(1, rsp.getNosuchSize());
    Long txn = rsp.getNosuch().iterator().next();
    assertEquals(1L, (long) txn);
    assertEquals(0, rsp.getAborted().size());
}
Also used : CommitTxnRequest(org.apache.hadoop.hive.metastore.api.CommitTxnRequest) HeartbeatTxnRangeResponse(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse) HeartbeatTxnRangeRequest(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeRequest) Test(org.junit.Test)

Example 4 with HeartbeatTxnRangeResponse

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

the class TestHiveMetaStoreTxns method testTxnRange.

@Test
public void testTxnRange() throws Exception {
    ValidTxnList validTxns = client.getValidTxns();
    Assert.assertEquals(ValidTxnList.RangeResponse.NONE, validTxns.isTxnRangeValid(1L, 3L));
    List<Long> tids = client.openTxns("me", 5).getTxn_ids();
    HeartbeatTxnRangeResponse rsp = client.heartbeatTxnRange(1, 5);
    Assert.assertEquals(0, rsp.getNosuch().size());
    Assert.assertEquals(0, rsp.getAborted().size());
    client.rollbackTxn(1L);
    client.commitTxn(2L);
    client.commitTxn(3L);
    client.commitTxn(4L);
    validTxns = client.getValidTxns();
    System.out.println("validTxns = " + validTxns);
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(2L, 2L));
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(2L, 3L));
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(2L, 4L));
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(3L, 4L));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(1L, 4L));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(2L, 5L));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(1L, 2L));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(4L, 5L));
    Assert.assertEquals(ValidTxnList.RangeResponse.NONE, validTxns.isTxnRangeValid(1L, 1L));
    Assert.assertEquals(ValidTxnList.RangeResponse.NONE, validTxns.isTxnRangeValid(5L, 10L));
    validTxns = new ValidReadTxnList("10:5:4:5:6");
    Assert.assertEquals(ValidTxnList.RangeResponse.NONE, validTxns.isTxnRangeValid(4, 6));
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(7, 10));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(7, 11));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(3, 6));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(4, 7));
    Assert.assertEquals(ValidTxnList.RangeResponse.SOME, validTxns.isTxnRangeValid(1, 12));
    Assert.assertEquals(ValidTxnList.RangeResponse.ALL, validTxns.isTxnRangeValid(1, 3));
}
Also used : HeartbeatTxnRangeResponse(org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse) ValidTxnList(org.apache.hadoop.hive.common.ValidTxnList) ValidReadTxnList(org.apache.hadoop.hive.common.ValidReadTxnList) Test(org.junit.Test)

Aggregations

HeartbeatTxnRangeResponse (org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse)4 Test (org.junit.Test)4 HeartbeatTxnRangeRequest (org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeRequest)3 ValidReadTxnList (org.apache.hadoop.hive.common.ValidReadTxnList)1 ValidTxnList (org.apache.hadoop.hive.common.ValidTxnList)1 AbortTxnRequest (org.apache.hadoop.hive.metastore.api.AbortTxnRequest)1 CommitTxnRequest (org.apache.hadoop.hive.metastore.api.CommitTxnRequest)1