use of org.apache.hadoop.hive.metastore.api.GetValidWriteIdsResponse in project hive by apache.
the class TxnHandler method getValidWriteIds.
@Override
@RetrySemantics.ReadOnly
public GetValidWriteIdsResponse getValidWriteIds(GetValidWriteIdsRequest rqst) throws NoSuchTxnException, MetaException {
try {
Connection dbConn = null;
Statement stmt = null;
ValidTxnList validTxnList;
// required to get the current state of txns to make validTxnList
if (rqst.isSetValidTxnList()) {
validTxnList = new ValidReadTxnList(rqst.getValidTxnList());
} else {
// Passing 0 for currentTxn means, this validTxnList is not wrt to any txn
validTxnList = TxnUtils.createValidReadTxnList(getOpenTxns(), 0);
}
try {
/**
* This runs at READ_COMMITTED for exactly the same reason as {@link #getOpenTxnsInfo()}
*/
dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
stmt = dbConn.createStatement();
// Get the valid write id list for all the tables read by the current txn
List<TableValidWriteIds> tblValidWriteIdsList = new ArrayList<>();
for (String fullTableName : rqst.getFullTableNames()) {
tblValidWriteIdsList.add(getValidWriteIdsForTable(stmt, fullTableName, validTxnList));
}
LOG.debug("Going to rollback");
dbConn.rollback();
GetValidWriteIdsResponse owr = new GetValidWriteIdsResponse(tblValidWriteIdsList);
return owr;
} catch (SQLException e) {
LOG.debug("Going to rollback");
rollbackDBConn(dbConn);
checkRetryable(dbConn, e, "getValidWriteIds");
throw new MetaException("Unable to select from transaction database, " + StringUtils.stringifyException(e));
} finally {
close(null, stmt, dbConn);
}
} catch (RetryException e) {
return getValidWriteIds(rqst);
}
}
Aggregations