@Override public ValidTxnWriteIdList getValidWriteIds(List<String> tableList, String validTxnList) throws LockException { assert isTxnOpen(); assert validTxnList != null && !validTxnList.isEmpty(); try { return TxnCommonUtils.createValidTxnWriteIdList( txnId, getMS().getValidWriteIds(tableList, validTxnList)); } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }
private TxnCtx generateTxnCtxForAlter( Table table, IMetaStoreClient msc, Boolean wasTxn) throws HiveException { if ((wasTxn != null && !wasTxn) || !TxnUtils.isTransactionalTable(table.getParameters())) { return null; } try { UserGroupInformation ugi = UserGroupInformation.getCurrentUser(); long txnId = msc.openTxn(ugi == null ? "anonymous" : ugi.getShortUserName()); TxnCtx result = null; try { ValidTxnList txns = msc.getValidTxns(txnId); String fqn = table.getDbName() + "." + table.getTableName(); List<TableValidWriteIds> writeIdsObj = msc.getValidWriteIds( Lists.newArrayList(fqn), txns.toString()); String validWriteIds = TxnCommonUtils.createValidTxnWriteIdList(txnId, writeIdsObj) .getTableValidWriteIdList(fqn).writeToString(); long writeId = msc.allocateTableWriteId(txnId, table.getDbName(), table.getTableName()); result = new TxnCtx(writeId, validWriteIds, txnId); } finally { if (result == null) { msc.abortTxns(Lists.newArrayList(txnId)); } } return result; } catch (IOException | TException ex) { throw new HiveException(ex); } }