Search in sources :

Example 1 with GetOpenTxnsRequest

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

the class HMSClient method getOpenTxns.

List<Long> getOpenTxns() throws TException {
    GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest();
    getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY));
    GetOpenTxnsResponse txns = client.get_open_txns_req(getOpenTxnsRequest);
    List<Long> openTxns = new ArrayList<>();
    BitSet abortedBits = BitSet.valueOf(txns.getAbortedBits());
    int i = 0;
    for (long txnId : txns.getOpen_txns()) {
        if (!abortedBits.get(i)) {
            openTxns.add(txnId);
        }
        ++i;
    }
    return openTxns;
}
Also used : GetOpenTxnsRequest(org.apache.hadoop.hive.metastore.api.GetOpenTxnsRequest) ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) GetOpenTxnsResponse(org.apache.hadoop.hive.metastore.api.GetOpenTxnsResponse)

Aggregations

ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 GetOpenTxnsRequest (org.apache.hadoop.hive.metastore.api.GetOpenTxnsRequest)1 GetOpenTxnsResponse (org.apache.hadoop.hive.metastore.api.GetOpenTxnsResponse)1