private static Result getTransactionStatus(HTableInterface metaTable, long transactionId) throws IOException { byte[] row = DominoConst.long2TranscationRowKey(transactionId); return metaTable.coprocessorProxy(TMetaIface.class, row) .getTransactionStatus(transactionId); }
private static KeyValue commitRow(HTableWrapper tableWrapper, KeyValue statusKV, long startId, long commitId, Integer lockId) { byte[] row = statusKV.getRow(); boolean isDelete = DominoConst.isDelete(statusKV.getValue()); try { tableWrapper.commitRow(row, startId, commitId, isDelete, lockId); } catch (IOException ioe) { } byte[] value = DominoConst.versionValue(startId, isDelete); KeyValue commitKV = new KeyValue(row, DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId, value); return commitKV; }
private static boolean isDeletedRow(List<KeyValue> statusList, List<KeyValue> versionList, long startId) { if (statusList != null && statusList.size() > 0) { if (isSelfDelete(statusList.get(0), startId)) { return true; } } if (versionList != null && versionList.size() > 0) { KeyValue version = versionList.get(0); if (DominoConst.isDeleteVersion(version.getValue())) { return true; } } return false; }
@SuppressWarnings("deprecation") @Override public long commitTransaction(byte[] startId) throws IOException { Integer lockId = region.getLock(null, startId, true); try { long commitId = tidClient.getId(); long startIdLong = DominoConst.getTidFromTMetaKey(startId); Get get = new Get(startId); Result r = region.get(get, lockId); if (DominoConst.TRX_ACTIVE != DominoConst.transactionStatus(r)) { return DominoConst.ERR_TRX_ABORTED; } Put put = new Put(startId); put.add(DominoConst.TRANSACTION_META_FAMILY, DominoConst.TRANSACTION_STATUS, startIdLong, DominoConst.TRX_COMMITTED_B); put.add(DominoConst.TRANSACTION_META_FAMILY, DominoConst.TRANSACTION_COMMIT_ID, startIdLong, Bytes.toBytes(commitId)); region.put(put, lockId, true); return commitId; } finally { region.releaseRowLock(lockId); } }
Integer lockId) throws IOException { KeyValue commitKV = new KeyValue(row, DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId, DominoConst.versionValue(startId, isDelete)); NavigableSet<KeyValue> orderedVersions = new TreeSet<KeyValue>( byte[] prevValue = prev.getValue(); long removeCommitId = remove.getTimestamp(); long removeStartId = DominoConst.getVersion(removeValue); long prevStartId = DominoConst.getVersion(prevValue); boolean isFresh = (removeCommitId != commitId); Columns removeCols = new Columns(DominoConst.getColumnsAt(r, removeStartId)); if (!DominoConst.isDeleteVersion(removeValue) && !DominoConst.isDeleteVersion(prevValue)) { Columns prevCols = new Columns(DominoConst.getColumnsAt(r, prevStartId)); Get get = new Get(row); get.setTimeStamp(removeStartId);
@SuppressWarnings("deprecation") @Override public Result getTransactionStatus(long transactionId) throws IOException { byte[] row = DominoConst.long2TranscationRowKey(transactionId); Integer lockId = region.getLock(null, row, true); try { Get get = new Get(row); Result r = region.get(get, lockId); if (System.currentTimeMillis() - DominoConst.getLastTouched(r) > DominoConst.TRX_EXPIRED) { // If it's too long since the client last updated the transaction // timestamp, the client may be no longer alive. // So we have to mark the transaction as aborted and let the caller // clear the row status. abort(row, lockId); return region.get(get, lockId); } else { return r; } } finally { region.releaseRowLock(lockId); } }
KeyValue verKV = mergedList.get(i); byte[] verBytes = verKV.getValue(); if (DominoConst.isDeleteVersion(verBytes)) { gotoNextColumn = true; break; Long ver = DominoConst.getVersion(verBytes); if (values.containsKey(ver)) { retKV.add(new KeyValue(result.getRow(), family, column,
private static Put clonePut(Put put) { long startId = 0; long commitId = 1; Put ret = new Put(put.getRow()); Map<byte[], List<KeyValue>> families = put.getFamilyMap(); Columns cols = new Columns(null); for (byte[] family : families.keySet()) { List<KeyValue> columns = families.get(family); Iterator<KeyValue> it = columns.iterator(); while (it.hasNext()) { KeyValue kv = it.next(); // byte[] column = DominoConst.getColumnKey(kv.getQualifier(), startId); byte[] qualifier = kv.getQualifier(); ret.add(family, qualifier, startId, kv.getValue()); cols.add(family, qualifier); } } Map<String, byte[]> attributes = put.getAttributesMap(); for (String key : attributes.keySet()) { ret.setAttribute(key, attributes.get(key)); } ret.add(DominoConst.INNER_FAMILY, DominoConst.COLUMNS_COL, startId, cols.toByteArray()); ret.add(DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId, DominoConst.versionValue(startId, false)); return ret; }
switch (DominoConst.transactionStatus(tStatus)) { case DominoConst.TRX_ACTIVE: break; case DominoConst.TRX_COMMITTED: long commitId = DominoConst.commitId(tStatus); if (commitId > startId) continue; // Ignore the "future" value. committed.add(commitRow(tableWrapper, kv, transactionId, commitId,
if (status == null || status.size() == 0) break; columnsWritten = DominoConst.getColumnsAt(res, startId); if (columnsWritten == null && status.size() >= DominoConst.MAX_VERSION) { if (retried) {
@SuppressWarnings("deprecation") private void abort(byte[] startId, Integer lockId) throws IOException { Put put = new Put(startId); long startIdLong = DominoConst.getTidFromTMetaKey(startId); put.add(DominoConst.TRANSACTION_META_FAMILY, DominoConst.TRANSACTION_STATUS, startIdLong, DominoConst.TRX_ABORTED_B); region.put(put, lockId, true); }
DominoConst.STATUS_COL, startId, KeyValue.Type.Delete); commit.add(clearStatusKV); byte[] value = DominoConst.versionValue(startId, isDelete); if (isFresh) { KeyValue commitKV = new KeyValue(row, DominoConst.INNER_FAMILY,
protected RWTransaction(Configuration conf, DominoIdIface tidClient) throws IOException { // this.tidClient = tidClient; this.conf = conf; this.metaTable = new HTable(conf, DominoConst.TRANSACTION_META); this.startId = tidClient.getId(); this.startIdBytes = DominoConst.long2TranscationRowKey(startId); createTransactionMeta(); startReporter(); }