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(); }
private void init(Configuration config) throws IOException { this.config = config; try { tidClient = DominoIdService.getClient(config); } catch (IOException e) { LOG.error("Error connecting to domino id service. ", e); throw e; } admin = new HBaseAdmin(config); initInnerTables(); }
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(); }
@Override public void start(CoprocessorEnvironment env) throws IOException { LOG.info("-------------TrxMetaEndpoint starting, version:{} ------------", Version.VERSION); // this.env = env; conf = env.getConfiguration(); tidClient = DominoIdService.getClient(conf); this.region = ((RegionCoprocessorEnvironment) env).getRegion(); }
@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); } }