use of org.apache.hadoop.hive.metastore.api.CommitTxnRequest in project hive by apache.
the class TestOpenTxn method testMultiGapWithOldCommit.
@Test
public void testMultiGapWithOldCommit() throws Exception {
OpenTxnRequest openTxnRequest = new OpenTxnRequest(1, "me", "localhost");
long first = txnHandler.openTxns(openTxnRequest).getTxn_ids().get(0);
txnHandler.commitTxn(new CommitTxnRequest(first));
long second = txnHandler.openTxns(new OpenTxnRequest(10, "me", "localhost")).getTxn_ids().get(0);
deleteTransaction(second, second + 9);
txnHandler.openTxns(openTxnRequest);
GetOpenTxnsResponse openTxns = txnHandler.getOpenTxns();
Assert.assertEquals(11, openTxns.getOpen_txnsSize());
}
use of org.apache.hadoop.hive.metastore.api.CommitTxnRequest in project hive by apache.
the class TestOpenTxn method testGapWithOldCommit.
@Test
public void testGapWithOldCommit() throws Exception {
OpenTxnRequest openTxnRequest = new OpenTxnRequest(1, "me", "localhost");
long first = txnHandler.openTxns(openTxnRequest).getTxn_ids().get(0);
txnHandler.commitTxn(new CommitTxnRequest(first));
long second = txnHandler.openTxns(openTxnRequest).getTxn_ids().get(0);
deleteTransaction(second);
txnHandler.openTxns(openTxnRequest);
GetOpenTxnsResponse openTxns = txnHandler.getOpenTxns();
Assert.assertEquals(2, openTxns.getOpen_txnsSize());
}
use of org.apache.hadoop.hive.metastore.api.CommitTxnRequest in project hive by apache.
the class CompactorTest method burnThroughTransactions.
protected void burnThroughTransactions(String dbName, String tblName, int num, Set<Long> open, Set<Long> aborted) throws MetaException, NoSuchTxnException, TxnAbortedException {
OpenTxnsResponse rsp = txnHandler.openTxns(new OpenTxnRequest(num, "me", "localhost"));
AllocateTableWriteIdsRequest awiRqst = new AllocateTableWriteIdsRequest(rsp.getTxn_ids(), dbName, tblName);
AllocateTableWriteIdsResponse awiResp = txnHandler.allocateTableWriteIds(awiRqst);
int i = 0;
for (long tid : rsp.getTxn_ids()) {
assert (awiResp.getTxnToWriteIds().get(i++).getTxnId() == tid);
if (aborted != null && aborted.contains(tid)) {
txnHandler.abortTxn(new AbortTxnRequest(tid));
} else if (open == null || (open != null && !open.contains(tid))) {
txnHandler.commitTxn(new CommitTxnRequest(tid));
}
}
}
use of org.apache.hadoop.hive.metastore.api.CommitTxnRequest in project hive by apache.
the class CompactorTest method burnThroughTransactions.
protected void burnThroughTransactions(String dbName, String tblName, int num, Set<Long> open, Set<Long> aborted, LockRequest lockReq) throws MetaException, NoSuchTxnException, TxnAbortedException {
OpenTxnsResponse rsp = txnHandler.openTxns(new OpenTxnRequest(num, "me", "localhost"));
AllocateTableWriteIdsRequest awiRqst = new AllocateTableWriteIdsRequest(dbName, tblName);
awiRqst.setTxnIds(rsp.getTxn_ids());
AllocateTableWriteIdsResponse awiResp = txnHandler.allocateTableWriteIds(awiRqst);
int i = 0;
for (long tid : rsp.getTxn_ids()) {
assert (awiResp.getTxnToWriteIds().get(i).getTxnId() == tid);
++i;
if (lockReq != null) {
lockReq.setTxnid(tid);
txnHandler.lock(lockReq);
}
if (aborted != null && aborted.contains(tid)) {
txnHandler.abortTxn(new AbortTxnRequest(tid));
} else if (open == null || !open.contains(tid)) {
txnHandler.commitTxn(new CommitTxnRequest(tid));
}
}
}
use of org.apache.hadoop.hive.metastore.api.CommitTxnRequest in project hive by apache.
the class CompactorTest method compactInTxn.
protected long compactInTxn(CompactionRequest rqst) throws Exception {
txnHandler.compact(rqst);
FindNextCompactRequest findNextCompactRequest = new FindNextCompactRequest();
findNextCompactRequest.setWorkerId("fred");
findNextCompactRequest.setWorkerVersion(WORKER_VERSION);
CompactionInfo ci = txnHandler.findNextToCompact(findNextCompactRequest);
ci.runAs = System.getProperty("user.name");
long compactorTxnId = openTxn(TxnType.COMPACTION);
// Need to create a valid writeIdList to set the highestWriteId in ci
ValidTxnList validTxnList = TxnCommonUtils.createValidReadTxnList(txnHandler.getOpenTxns(), compactorTxnId);
GetValidWriteIdsRequest writeIdsRequest = new GetValidWriteIdsRequest();
writeIdsRequest.setValidTxnList(validTxnList.writeToString());
writeIdsRequest.setFullTableNames(Collections.singletonList(TxnUtils.getFullTableName(rqst.getDbname(), rqst.getTablename())));
// with this ValidWriteIdList is capped at whatever HWM validTxnList has
ValidCompactorWriteIdList tblValidWriteIds = TxnUtils.createValidCompactWriteIdList(txnHandler.getValidWriteIds(writeIdsRequest).getTblValidWriteIds().get(0));
ci.highestWriteId = tblValidWriteIds.getHighWatermark();
txnHandler.updateCompactorState(ci, compactorTxnId);
txnHandler.markCompacted(ci);
txnHandler.commitTxn(new CommitTxnRequest(compactorTxnId));
Thread.sleep(MetastoreConf.getTimeVar(conf, MetastoreConf.ConfVars.TXN_OPENTXN_TIMEOUT, TimeUnit.MILLISECONDS));
return compactorTxnId;
}
Aggregations