public synchronized TransactionSnapshot getSnapshot() throws IOException { TransactionSnapshot snapshot = null; if (!isRunning() && !isStopping()) { return null; } long now = System.currentTimeMillis(); // avoid duplicate snapshots at same timestamp if (now == lastSnapshotTime || (currentLog != null && now == currentLog.getTimestamp())) { try { TimeUnit.MILLISECONDS.sleep(1); } catch (InterruptedException ie) { } } // copy in memory state snapshot = getCurrentState(); LOG.debug("Starting snapshot of transaction state with timestamp {}", snapshot.getTimestamp()); LOG.debug("Returning snapshot of state: " + snapshot); return snapshot; }
public synchronized TransactionSnapshot getSnapshot() throws IOException { TransactionSnapshot snapshot = null; if (!isRunning() && !isStopping()) { return null; } long now = System.currentTimeMillis(); // avoid duplicate snapshots at same timestamp if (now == lastSnapshotTime || (currentLog != null && now == currentLog.getTimestamp())) { try { TimeUnit.MILLISECONDS.sleep(1); } catch (InterruptedException ie) { } } // copy in memory state snapshot = getCurrentState(); LOG.debug("Starting snapshot of transaction state with timestamp {}", snapshot.getTimestamp()); LOG.debug("Returning snapshot of state: " + snapshot); return snapshot; }
TransactionSnapshot snapshot2 = txManager2.getCurrentState(); assertEquals(1, snapshot2.getInProgress().size()); Map.Entry<Long, TransactionManager.InProgressTx> inProgressTx =
TransactionSnapshot snapshot1 = txm.getCurrentState(); Assert.assertEquals(ImmutableSortedSet.of(wp1, wp2, wp3, wp4), snapshot1.getInProgress().keySet()); verifyInProgress(snapshot1.getInProgress().get(wp1), TransactionType.LONG, time1 + longTimeout);
TransactionSnapshot origState = txManager.getCurrentState(); LOG.info("Orig state: " + origState); TransactionSnapshot newState = txManager.getCurrentState(); LOG.info("New state: " + newState); assertEquals(origState, newState);
snapshot = txManager.getCurrentState(); inProgress = snapshot.getInProgress(); Assert.assertEquals(1, inProgress.size());
ImmutableList.of(tx1.getTransactionId(), tx2.getTransactionId(), tx5.getTransactionId(), tx6.getTransactionId()), txm1.getCurrentState().getInvalid() ); txm1.getCurrentState().getInvalid()); txm1.getCurrentState().getInProgress().keySet()); try { txm1.truncateInvalidTxBefore(timeBeforeTx5); txm1.getCurrentState().getInProgress().keySet()); txm1.getCurrentState().getInvalid()); txm2.startAndWait(); Assert.assertEquals(ImmutableList.of(tx5.getTransactionId(), tx6.getTransactionId()), txm2.getCurrentState().getInvalid()); Assert.assertEquals(ImmutableSet.of(tx3.getTransactionId(), tx4.getTransactionId()), txm2.getCurrentState().getInProgress().keySet()); } finally { txm1.stopAndWait();
ImmutableList.of(tx1.getTransactionId(), tx2.getTransactionId(), tx5.getTransactionId(), tx6.getTransactionId()), txm1.getCurrentState().getInvalid() ); txm1.getCurrentState().getInvalid()); txm1.getCurrentState().getInProgress().keySet()); Assert.assertFalse(txm1.truncateInvalidTx(ImmutableSet.of(tx3.getTransactionId(), tx4.getTransactionId()))); txm1.getCurrentState().getInProgress().keySet()); txm1.getCurrentState().getInvalid()); txm2.startAndWait(); Assert.assertEquals(ImmutableList.of(tx2.getTransactionId(), tx5.getTransactionId()), txm2.getCurrentState().getInvalid()); Assert.assertEquals(ImmutableSet.of(tx3.getTransactionId(), tx4.getTransactionId()), txm2.getCurrentState().getInProgress().keySet()); } finally { txm1.stopAndWait();
TransactionSnapshot snapshot1 = txm.getCurrentState(); Assert.assertEquals(ImmutableList.of(wp1, wp2), snapshot1.getInvalid()); Assert.assertEquals(0, snapshot1.getInProgress().size());
try { TransactionSnapshot snapshot1 = txm.getCurrentState(); Assert.assertEquals(ImmutableList.of(wp1, wp2, wp3), snapshot1.getInvalid()); Assert.assertEquals(0, snapshot1.getInProgress().size());
TransactionSnapshot origState = txManager.getCurrentState(); LOG.info("Orig state: " + origState); TransactionSnapshot newState = txManager.getCurrentState(); LOG.info("New state: " + newState); assertEquals(origState, newState); tx = txManager.startShort(); origState = txManager.getCurrentState(); newState = txManager.getCurrentState(); assertEquals(origState, newState);
try { TransactionSnapshot snapshot = txm.getCurrentState(); Assert.assertEquals(ImmutableList.of(wp4), snapshot.getInvalid()); Assert.assertEquals(0, snapshot.getInProgress().size());
Assert.assertEquals(tx3.getTransactionId(), (long) txm.getCurrentState().getInvalid().iterator().next()); Assert.assertEquals(1, txm.getExcludedListSize()); } finally {