use of org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse in project hive by apache.
the class TestTxnHandler method testValidTxnsNoneOpen.
@Test
public void testValidTxnsNoneOpen() throws Exception {
txnHandler.openTxns(new OpenTxnRequest(2, "me", "localhost"));
txnHandler.commitTxn(new CommitTxnRequest(1));
txnHandler.commitTxn(new CommitTxnRequest(2));
GetOpenTxnsInfoResponse txnsInfo = txnHandler.getOpenTxnsInfo();
assertEquals(2L, txnsInfo.getTxn_high_water_mark());
assertEquals(0, txnsInfo.getOpen_txns().size());
GetOpenTxnsResponse txns = txnHandler.getOpenTxns();
assertEquals(2L, txns.getTxn_high_water_mark());
assertEquals(0, txns.getOpen_txns().size());
}
use of org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse in project hive by apache.
the class TestTxnHandler method testAbortTxns.
@Test
public void testAbortTxns() throws Exception {
createDatabaseForReplTests("default", MetaStoreUtils.getDefaultCatalog(conf));
OpenTxnsResponse openedTxns = txnHandler.openTxns(new OpenTxnRequest(3, "me", "localhost"));
List<Long> txnList = openedTxns.getTxn_ids();
txnHandler.abortTxns(new AbortTxnsRequest(txnList));
OpenTxnRequest replRqst = new OpenTxnRequest(2, "me", "localhost");
replRqst.setReplPolicy("default.*");
replRqst.setTxn_type(TxnType.REPL_CREATED);
replRqst.setReplSrcTxnIds(Arrays.asList(1L, 2L));
List<Long> targetTxns = txnHandler.openTxns(replRqst).getTxn_ids();
assertTrue(targetTxnsPresentInReplTxnMap(1L, 2L, targetTxns));
txnHandler.abortTxns(new AbortTxnsRequest(targetTxns));
assertFalse(targetTxnsPresentInReplTxnMap(1L, 2L, targetTxns));
GetOpenTxnsInfoResponse txnsInfo = txnHandler.getOpenTxnsInfo();
assertEquals(5, txnsInfo.getOpen_txns().size());
txnsInfo.getOpen_txns().forEach(txn -> assertEquals(TxnState.ABORTED, txn.getState()));
}
use of org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse in project hive by apache.
the class TestTxnHandler method testOpenTxn.
@Test
public void testOpenTxn() throws Exception {
long first = openTxn();
assertEquals(1L, first);
long second = openTxn();
assertEquals(2L, second);
GetOpenTxnsInfoResponse txnsInfo = txnHandler.getOpenTxnsInfo();
assertEquals(2L, txnsInfo.getTxn_high_water_mark());
assertEquals(2, txnsInfo.getOpen_txns().size());
assertEquals(1L, txnsInfo.getOpen_txns().get(0).getId());
assertEquals(TxnState.OPEN, txnsInfo.getOpen_txns().get(0).getState());
assertEquals(2L, txnsInfo.getOpen_txns().get(1).getId());
assertEquals(TxnState.OPEN, txnsInfo.getOpen_txns().get(1).getState());
assertEquals("me", txnsInfo.getOpen_txns().get(1).getUser());
assertEquals("localhost", txnsInfo.getOpen_txns().get(1).getHostname());
GetOpenTxnsResponse txns = txnHandler.getOpenTxns();
assertEquals(2L, txns.getTxn_high_water_mark());
assertEquals(2, txns.getOpen_txns().size());
boolean[] saw = new boolean[3];
for (int i = 0; i < saw.length; i++) saw[i] = false;
for (Long tid : txns.getOpen_txns()) {
saw[tid.intValue()] = true;
}
for (int i = 1; i < saw.length; i++) assertTrue(saw[i]);
}
use of org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse in project hive by apache.
the class TestTxnHandler method testValidTxnsSomeOpen.
@Test
public void testValidTxnsSomeOpen() throws Exception {
txnHandler.openTxns(new OpenTxnRequest(3, "me", "localhost"));
txnHandler.abortTxn(new AbortTxnRequest(1));
txnHandler.commitTxn(new CommitTxnRequest(2));
GetOpenTxnsInfoResponse txnsInfo = txnHandler.getOpenTxnsInfo();
assertEquals(3L, txnsInfo.getTxn_high_water_mark());
assertEquals(2, txnsInfo.getOpen_txns().size());
assertEquals(1L, txnsInfo.getOpen_txns().get(0).getId());
assertEquals(TxnState.ABORTED, txnsInfo.getOpen_txns().get(0).getState());
assertEquals(3L, txnsInfo.getOpen_txns().get(1).getId());
assertEquals(TxnState.OPEN, txnsInfo.getOpen_txns().get(1).getState());
GetOpenTxnsResponse txns = txnHandler.getOpenTxns();
assertEquals(3L, txns.getTxn_high_water_mark());
assertEquals(2, txns.getOpen_txns().size());
boolean[] saw = new boolean[4];
for (int i = 0; i < saw.length; i++) saw[i] = false;
for (Long tid : txns.getOpen_txns()) {
saw[tid.intValue()] = true;
}
assertTrue(saw[1]);
assertFalse(saw[2]);
assertTrue(saw[3]);
}
use of org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse in project hive by apache.
the class TestTxnHandlerNoConnectionPool method testOpenTxn.
@Test
public void testOpenTxn() throws Exception {
long first = openTxn();
assertEquals(1L, first);
long second = openTxn();
assertEquals(2L, second);
GetOpenTxnsInfoResponse txnsInfo = txnHandler.getOpenTxnsInfo();
assertEquals(2L, txnsInfo.getTxn_high_water_mark());
assertEquals(2, txnsInfo.getOpen_txns().size());
assertEquals(1L, txnsInfo.getOpen_txns().get(0).getId());
assertEquals(TxnState.OPEN, txnsInfo.getOpen_txns().get(0).getState());
assertEquals(2L, txnsInfo.getOpen_txns().get(1).getId());
assertEquals(TxnState.OPEN, txnsInfo.getOpen_txns().get(1).getState());
assertEquals("me", txnsInfo.getOpen_txns().get(1).getUser());
assertEquals("localhost", txnsInfo.getOpen_txns().get(1).getHostname());
GetOpenTxnsResponse txns = txnHandler.getOpenTxns();
assertEquals(2L, txns.getTxn_high_water_mark());
assertEquals(2, txns.getOpen_txns().size());
boolean[] saw = new boolean[3];
for (int i = 0; i < saw.length; i++) saw[i] = false;
for (Long tid : txns.getOpen_txns()) {
saw[tid.intValue()] = true;
}
for (int i = 1; i < saw.length; i++) assertTrue(saw[i]);
}
Aggregations