for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) { long writePointer = entry.getKey(); long expiration = entry.getValue().getExpiration(); if (entry.getValue().getType() == null && (expiration < 0 || (getTxExpirationFromWritePointer(writePointer, defaultLongTimeout) - expiration new InProgressTx(entry.getValue().getVisibilityUpperBound(), newExpiration, TransactionType.LONG, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx); } else if (entry.getValue().getType() == null) { InProgressTx compatTx = new InProgressTx(entry.getValue().getVisibilityUpperBound(), entry.getValue().getExpiration(), TransactionType.SHORT, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx);
private void doCheckpoint(long newWritePointer, long parentWritePointer) { InProgressTx existingTx = inProgress.get(parentWritePointer); existingTx.addCheckpointWritePointer(newWritePointer); advanceWritePointer(newWritePointer); }
/** * Returns the write pointer for the first "short" transaction that in the in-progress set, or * {@link Transaction#NO_TX_IN_PROGRESS} if none. */ public static long getFirstShortInProgress(Map<Long, TransactionManager.InProgressTx> inProgress) { long firstShort = Transaction.NO_TX_IN_PROGRESS; for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { if (!entry.getValue().isLongRunning()) { firstShort = entry.getKey(); break; } } return firstShort; }
InProgressTx inProgressTx = inProgress.get(edit.getWritePointer()); if (inProgressTx != null) { type = inProgressTx.getType(); } else {
InProgressTx inProgressTx = inProgress.get(edit.getWritePointer()); if (inProgressTx != null) { type = inProgressTx.getType(); } else {
long time1 = System.currentTimeMillis(); long wp1 = time1 * TxConstants.MAX_TX_PER_MS; inProgress.put(wp1, new TransactionManager.InProgressTx(wp1 - 5, -1L)); long time2 = time1 + 100; long wp2 = time2 * TxConstants.MAX_TX_PER_MS; inProgress.put(wp2, new TransactionManager.InProgressTx(wp2 - 50, time2 + 1000)); Map<Long, Set<ChangeId>> committing = Maps.newHashMap(); Map<Long, Set<ChangeId>> committed = Maps.newHashMap();
tLong, new TransactionManager.InProgressTx(readPtr, TransactionManager.getTxExpirationFromWritePointer( tLong, TxConstants.Manager.DEFAULT_TX_LONG_TIMEOUT), TransactionType.LONG), tShort, new TransactionManager.InProgressTx(readPtr, now + 1000, TransactionType.SHORT)));
Assert.assertNotNull(inProgressTx); Assert.assertArrayEquals(checkpointTx.getCheckpointWritePointers(), inProgressTx.getCheckpointWritePointers().toLongArray()); Assert.assertNotNull(inProgressTx); Assert.assertArrayEquals(checkpointTx.getCheckpointWritePointers(), inProgressTx.getCheckpointWritePointers().toLongArray());
Map.Entry<Long, TransactionManager.InProgressTx> entry = snapshot.getInProgress().entrySet().iterator().next(); assertNull(entry.getValue().getType()); txStorage.stopAndWait(); Map.Entry<Long, TransactionManager.InProgressTx> inProgressTx = snapshot2.getInProgress().entrySet().iterator().next(); assertEquals(TransactionType.LONG, inProgressTx.getValue().getType());
tLong, new TransactionManager.InProgressTx(readPtr, TransactionManager.getTxExpirationFromWritePointer(tLong, TxConstants.Manager.DEFAULT_TX_LONG_TIMEOUT), TransactionType.LONG), tShort, new TransactionManager.InProgressTx(readPtr, now + 1000, TransactionType.SHORT)));
new TransactionManager.InProgressTx(startPointer - 1, currentTime + TimeUnit.DAYS.toSeconds(1), TransactionType.LONG)); } else { inProgress.put(startPointer + i, new TransactionManager.InProgressTx(startPointer - 1, currentTime + 300000L, TransactionType.SHORT));
List<Long> timedOut = Lists.newArrayList(); for (Map.Entry<Long, InProgressTx> tx : inProgress.entrySet()) { long expiration = tx.getValue().getExpiration(); if (expiration >= 0L && currentTime > expiration) {
parentTx.getCheckpointWritePointers().toLongArray());
List<Long> timedOut = Lists.newArrayList(); for (Map.Entry<Long, InProgressTx> tx : inProgress.entrySet()) { long expiration = tx.getValue().getExpiration(); if (expiration >= 0L && currentTime > expiration) {
parentTx.getCheckpointWritePointers().toLongArray());
} else { LongArrayList childWritePointers = previous.getCheckpointWritePointers(); if (childWritePointers != null) { for (int i = 0; i < childWritePointers.size(); i++) { if (previous != null && !previous.isLongRunning()) {
new TransactionManager.InProgressTx(visibilityUpperBound, expiration, txType, checkpointPointers));
new TransactionManager.InProgressTx(visibilityUpperBound, expiration, txType, checkpointPointers));
} else { LongArrayList childWritePointers = previous.getCheckpointWritePointers(); if (childWritePointers != null) { for (int i = 0; i < childWritePointers.size(); i++) { if (previous != null && !previous.isLongRunning()) {
@Override protected NavigableMap<Long, TransactionManager.InProgressTx> decodeInProgress(BinaryDecoder decoder) throws IOException { int size = decoder.readInt(); NavigableMap<Long, TransactionManager.InProgressTx> inProgress = Maps.newTreeMap(); while (size != 0) { // zero denotes end of list as per AVRO spec for (int remaining = size; remaining > 0; --remaining) { long txId = decoder.readLong(); long expiration = decoder.readLong(); long visibilityUpperBound = decoder.readLong(); int txTypeIdx = decoder.readInt(); TransactionType txType; try { txType = TransactionType.values()[txTypeIdx]; } catch (ArrayIndexOutOfBoundsException e) { throw new IOException("Type enum ordinal value is out of range: " + txTypeIdx); } inProgress.put(txId, new TransactionManager.InProgressTx(visibilityUpperBound, expiration, txType, new LongArrayList())); } size = decoder.readInt(); } return inProgress; } }