@Before public void before() { Configuration txConf = HBaseConfiguration.create(); TransactionManager txManager = new TransactionManager(txConf); txManager.startAndWait(); txClient = new InMemoryTxSystemClient(txManager); }
@Override public void destroy() throws Exception { txManager.stopAndWait(); } }
try { Transaction tx = txManager.startShort(); txManager.abort(tx); txManager.truncateInvalidTx(toTruncate); LOG.info("Removed {} invalid ids from the invalid list", toTruncate.size());
this.transactionManager = new TransactionManager(); public void initiateAndCloseOnNormalExecution() { TestTransaction transaction = new TestTransaction(); transactionManager.executeTransaction(transaction); assert(transaction.isInitiated() && transaction.isClosed()); public void initiateRollbackAndCloseOnFailure() { TestTransaction transaction = new FailingTestTransaction(); transactionManager.executeTransaction(transaction); assert(transaction.isInitiated() && transaction.isRollbacked && transaction.isClosed());
validateChangeSet(txId, changeIds, inProgressTx.clientId != null ? inProgressTx.clientId : DEFAULT_CLIENTID); checkForConflicts(txId, set); try { synchronized (this) { ensureAvailable(); addCommittingChangeSet(txId, inProgressTx.getClientId(), set); appendToLog(TransactionEdit.createCommitting(txId, set)); } finally { this.logReadLock.unlock();
@Override public void init() throws Exception { txManager.startAndWait(); }
TransactionManager txManager = new TransactionManager(txConf); txManager.startAndWait(); try { TransactionSystemClient txClient = new InMemoryTxSystemClient(txManager); ((TransactionAware) cube2).postTxCommit(); } finally { txManager.stopAndWait();
@Override public PhoenixTransactionClient getTransactionClient(Configuration config, ConnectionInfo connectionInfo) { if (connectionInfo.isConnectionless()) { TransactionManager txnManager = new TransactionManager(config); TransactionSystemClient txClient = new InMemoryTxSystemClient(txnManager); return new TephraTransactionClient(txClient);
expiration = getTxExpirationFromWritePointer(edit.getWritePointer(), defaultLongTimeout); type = TransactionType.LONG; } else if (type == null) { addInProgressAndAdvance(edit.getWritePointer(), edit.getVisibilityUpperBound(), expiration, type, null); break; case COMMITTING: addCommittingChangeSet(edit.getWritePointer(), null, edit.getChanges()); break; case COMMITTED: long writePointer = checkpointPointers == null || checkpointPointers.length == 0 ? transactionId : checkpointPointers[checkpointPointers.length - 1]; doCommit(transactionId, writePointer, new ChangeSet(null, edit.getChanges()), edit.getCommitPointer(), edit.getCanCommit()); break; case INVALID: doInvalidate(edit.getWritePointer()); break; case ABORTED: doInvalidate(edit.getWritePointer()); break; doAbort(edit.getWritePointer(), edit.getCheckpointPointers(), type); break; case TRUNCATE_INVALID_TX: if (edit.getTruncateInvalidTxTime() != 0) { doTruncateInvalidTxBefore(edit.getTruncateInvalidTxTime());
try { synchronized (this) { snapshot = getSnapshot(); if (snapshot == null && !closing) { return; abortService("Snapshot (timestamp " + snapshotTime + ") failed due to: " + ioe.getMessage(), ioe);
private void appendToLog(List<TransactionEdit> edits) { try { Stopwatch timer = new Stopwatch().start(); currentLog.append(edits); txMetricsCollector.rate("wal.append.count", edits.size()); txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis()); } catch (IOException ioe) { abortService("Error appending to transaction log", ioe); } }
@Override public void abort(Transaction tx) { txManager.abort(tx); }
@Override protected void doStart() { try { txManager = txManagerProvider.get(); txManager.startAndWait(); doRegister(); LOG.info("Transaction Thrift service started successfully on " + getAddress()); notifyStarted(); } catch (Throwable t) { LOG.info("Transaction Thrift service didn't start on " + getAddress()); notifyFailed(t); } }
@Override public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo connInfo, int port) { config.setInt(TxConstants.Service.CFG_DATA_TX_BIND_PORT, port); int retryTimeOut = config.getInt(TxConstants.Service.CFG_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC, TxConstants.Service.DEFAULT_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC); ZKClientService zkClient = ZKClientServices.delegate( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure( ZKClientService.Builder.of(connInfo.getZookeeperConnectionString()) .setSessionTimeout(config.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT)) .build(), RetryStrategies.exponentialDelay(500, retryTimeOut, TimeUnit.MILLISECONDS) ) ) ); DiscoveryService discovery = new ZKDiscoveryService(zkClient); TransactionManager txManager = new TransactionManager(config, new HDFSTransactionStateStorage(config, new SnapshotCodecProvider(config), new TxMetricsCollector()), new TxMetricsCollector()); TransactionService txService = new TransactionService(config, zkClient, discovery, Providers.of(txManager)); TephraTransactionService service = new TephraTransactionService(zkClient, txService); service.start(); return service; }
private void appendToLog(TransactionEdit edit) { try { Stopwatch timer = new Stopwatch().start(); currentLog.append(edit); txMetricsCollector.rate("wal.append.count"); txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis()); } catch (IOException ioe) { abortService("Error appending to transaction log", ioe); } }
@Override public void abortTx(TTransaction tx) throws TException { txManager.abort(TransactionConverterUtils.unwrap(tx)); }
@BeforeClass public static void setup() { txManager = new TransactionManager(new Configuration()); txManager.startAndWait(); txClient = new DummyTxClient(txManager); }
public static Injector startMetricsService(CConfiguration conf) { Injector injector = Guice.createInjector(new AppFabricTestModule(conf)); injector.getInstance(TransactionManager.class).startAndWait(); injector.getInstance(DatasetOpExecutor.class).startAndWait(); injector.getInstance(DatasetService.class).startAndWait(); return injector; }
@Override protected void doStop() { undoRegister(); txManager.stopAndWait(); notifyStopped(); }
@Override public PhoenixTransactionClient getTransactionClient(Configuration config, ConnectionInfo connectionInfo) { if (connectionInfo.isConnectionless()) { TransactionManager txnManager = new TransactionManager(config); TransactionSystemClient txClient = new InMemoryTxSystemClient(txnManager); return new TephraTransactionClient(txClient);