protected ReadOnlyTransaction(Configuration conf, DominoIdIface tidClient) throws IOException { this.conf = conf; this.metaTable = new HTable(conf, DominoConst.TRANSACTION_META); /* * Read-only transactions don't need to create transaction status rows in * meta table. * * To get a start id is the only additional work to do. */ this.startId = tidClient.getId(); }
@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); } }
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(); }