InProgressTx compatTx = 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);
InProgressTx compatTx = 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);
/** * Creates a new Transaction. This method only get called from start transaction, which is already * synchronized. */ private Transaction createTransaction(long writePointer, TransactionType type) { // For holding the first in progress short transaction Id (with timeout >= 0). long firstShortTx = Transaction.NO_TX_IN_PROGRESS; LongArrayList inProgressIds = new LongArrayList(inProgress.size()); for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) { long txId = entry.getKey(); inProgressIds.add(txId); // add any checkpointed write pointers to the in-progress list LongArrayList childIds = entry.getValue().getCheckpointWritePointers(); if (childIds != null) { for (int i = 0; i < childIds.size(); i++) { inProgressIds.add(childIds.get(i)); } } if (firstShortTx == Transaction.NO_TX_IN_PROGRESS && !entry.getValue().isLongRunning()) { firstShortTx = txId; } } return new Transaction(readPointer, writePointer, invalidArray, inProgressIds.toLongArray(), firstShortTx, type); }
Assert.assertNotNull(inProgressTx); Assert.assertArrayEquals(checkpointTx.getCheckpointWritePointers(), inProgressTx.getCheckpointWritePointers().toLongArray()); Assert.assertNotNull(inProgressTx); Assert.assertArrayEquals(checkpointTx.getCheckpointWritePointers(), inProgressTx.getCheckpointWritePointers().toLongArray());
parentTx.getCheckpointWritePointers().toLongArray());
parentTx.getCheckpointWritePointers().toLongArray());
} else { LongArrayList childWritePointers = previous.getCheckpointWritePointers(); if (childWritePointers != null) { for (int i = 0; i < childWritePointers.size(); i++) {
} else { LongArrayList childWritePointers = previous.getCheckpointWritePointers(); if (childWritePointers != null) { for (int i = 0; i < childWritePointers.size(); i++) {
/** * Creates a new Transaction. This method only get called from start transaction, which is already * synchronized. */ private Transaction createTransaction(long writePointer, TransactionType type) { // For holding the first in progress short transaction Id (with timeout >= 0). long firstShortTx = Transaction.NO_TX_IN_PROGRESS; LongArrayList inProgressIds = new LongArrayList(inProgress.size()); for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) { long txId = entry.getKey(); inProgressIds.add(txId); // add any checkpointed write pointers to the in-progress list LongArrayList childIds = entry.getValue().getCheckpointWritePointers(); if (childIds != null) { for (int i = 0; i < childIds.size(); i++) { inProgressIds.add(childIds.get(i)); } } if (firstShortTx == Transaction.NO_TX_IN_PROGRESS && !entry.getValue().isLongRunning()) { firstShortTx = txId; } } return new Transaction(readPointer, writePointer, invalidArray, inProgressIds.toLongArray(), firstShortTx, type); }
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); // write checkpoint tx IDs LongArrayList checkpointPointers = entry.getValue().getCheckpointWritePointers(); if (checkpointPointers != null && !checkpointPointers.isEmpty()) { encoder.writeInt(checkpointPointers.size()); for (int i = 0; i < checkpointPointers.size(); i++) { encoder.writeLong(checkpointPointers.getLong(i)); } } encoder.writeInt(0); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); // write checkpoint tx IDs LongArrayList checkpointPointers = entry.getValue().getCheckpointWritePointers(); if (checkpointPointers != null && !checkpointPointers.isEmpty()) { encoder.writeInt(checkpointPointers.size()); for (int i = 0; i < checkpointPointers.size(); i++) { encoder.writeLong(checkpointPointers.getLong(i)); } } encoder.writeInt(0); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }