Search in sources :

Example 6 with FindNextCompactRequest

use of org.apache.hadoop.hive.metastore.api.FindNextCompactRequest 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;
}
Also used : ValidCompactorWriteIdList(org.apache.hadoop.hive.common.ValidCompactorWriteIdList) CommitTxnRequest(org.apache.hadoop.hive.metastore.api.CommitTxnRequest) ValidTxnList(org.apache.hadoop.hive.common.ValidTxnList) FindNextCompactRequest(org.apache.hadoop.hive.metastore.api.FindNextCompactRequest) GetValidWriteIdsRequest(org.apache.hadoop.hive.metastore.api.GetValidWriteIdsRequest) CompactionInfo(org.apache.hadoop.hive.metastore.txn.CompactionInfo)

Example 7 with FindNextCompactRequest

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

the class CompactionTxnHandler method findNextToCompact.

/**
 * This will grab the next compaction request off of
 * the queue, and assign it to the worker.
 * @param workerId id of the worker calling this, will be recorded in the db
 * @deprecated  Replaced by
 *     {@link CompactionTxnHandler#findNextToCompact(org.apache.hadoop.hive.metastore.api.FindNextCompactRequest)}
 * @return an info element for next compaction in the queue, or null if there is no work to do now.
 */
@Deprecated
@Override
@RetrySemantics.SafeToRetry
public CompactionInfo findNextToCompact(String workerId) throws MetaException {
    FindNextCompactRequest findNextCompactRequest = new FindNextCompactRequest();
    findNextCompactRequest.setWorkerId(workerId);
    return findNextToCompact(findNextCompactRequest);
}
Also used : FindNextCompactRequest(org.apache.hadoop.hive.metastore.api.FindNextCompactRequest)

Aggregations

FindNextCompactRequest (org.apache.hadoop.hive.metastore.api.FindNextCompactRequest)7 ValidCompactorWriteIdList (org.apache.hadoop.hive.common.ValidCompactorWriteIdList)3 ValidTxnList (org.apache.hadoop.hive.common.ValidTxnList)3 Table (org.apache.hadoop.hive.metastore.api.Table)3 CompactionInfo (org.apache.hadoop.hive.metastore.txn.CompactionInfo)3 CommitTxnRequest (org.apache.hadoop.hive.metastore.api.CommitTxnRequest)2 GetValidWriteIdsRequest (org.apache.hadoop.hive.metastore.api.GetValidWriteIdsRequest)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Path (org.apache.hadoop.fs.Path)1 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)1 CompactionInfoStruct (org.apache.hadoop.hive.metastore.api.CompactionInfoStruct)1 CompactionRequest (org.apache.hadoop.hive.metastore.api.CompactionRequest)1 CompactionType (org.apache.hadoop.hive.metastore.api.CompactionType)1 Database (org.apache.hadoop.hive.metastore.api.Database)1 GetLatestCommittedCompactionInfoRequest (org.apache.hadoop.hive.metastore.api.GetLatestCommittedCompactionInfoRequest)1