@Override public void startTx(Transaction tx) { this.tx = tx; if (inProgressChanges == null) { inProgressChanges = new TreeSet<>(UnsignedBytes.lexicographicalComparator()); for (long inProgressTx : tx.getInProgress()) { inProgressChanges.add(Bytes.concat(fenceId, Longs.toByteArray(inProgressTx))); } } }
public static void write(DataOutput dataOutput, Transaction tx) throws IOException { dataOutput.writeLong(tx.getReadPointer()); dataOutput.writeLong(tx.getWritePointer()); dataOutput.writeLong(tx.getFirstShortInProgress()); write(dataOutput, tx.getInProgress()); write(dataOutput, tx.getInvalids()); }
/** * Returns the maximum transaction that can be removed from the invalid list for the state represented by the given * transaction. */ public static long getPruneUpperBound(Transaction tx) { // If there are no invalid transactions, and no in-progress transactions then we can prune the invalid list // up to the current read pointer if (tx.getInvalids().length == 0 && tx.getInProgress().length == 0) { return tx.getReadPointer() - 1; } long maxInvalidTx = tx.getInvalids().length > 0 ? tx.getInvalids()[tx.getInvalids().length - 1] : Transaction.NO_TX_IN_PROGRESS; long firstInProgress = tx.getFirstInProgress(); return Math.min(maxInvalidTx, firstInProgress - 1); }
", readPointer: " + tx.getReadPointer() + ", invalids: " + tx.getInvalids().length + ", inProgress: " + tx.getInProgress().length);
Predicate<PartitionDetail> predicate) { List<Long> previousInProgress = partitionConsumerState.getVersionsToCheck(); Set<Long> noLongerInProgress = setDiff(previousInProgress, tx.getInProgress()); for (long txId : tx.getInProgress()) { if (txId >= scanUpTo) { break;
Predicate<PartitionDetail> predicate) { List<Long> previousInProgress = partitionConsumerState.getVersionsToCheck(); Set<Long> noLongerInProgress = setDiff(previousInProgress, tx.getInProgress()); for (long txId : tx.getInProgress()) { if (txId >= scanUpTo) { break;
/** * Creates a new transaction for a checkpoint operation, copying all members from the original transaction, * with the updated checkpoint write pointers. * * @param toCopy the original transaction containing the state to copy * @param writePointer the new write pointer to use for the transaction * @param checkpointPointers the list of write pointers added from checkpoints on the transaction */ public Transaction(Transaction toCopy, long writePointer, long[] checkpointPointers) { this(toCopy.getReadPointer(), toCopy.getTransactionId(), writePointer, toCopy.getInvalids(), toCopy.getInProgress(), toCopy.getFirstShortInProgress(), toCopy.getType(), checkpointPointers, toCopy.getVisibilityLevel()); }
@Override public void collect() throws Exception { Collection<MetricTimeSeries> collection = metricStore.query(new MetricDataQuery(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, METRICS, Constants.Metrics.TRANSACTION_MANAGER_CONTEXT, Collections.<String>emptyList(), null)); for (MetricTimeSeries metricTimeSeries : collection) { if (metricTimeSeries.getMetricName().equals("system.committing.size")) { numCommittingChangeSets = (int) aggregateMetricValue(metricTimeSeries); } if (metricTimeSeries.getMetricName().equals("system.committed.size")) { numCommittedChangeSets = (int) aggregateMetricValue(metricTimeSeries); } } Transaction transaction = txClient.startShort(); readPointer = transaction.getReadPointer(); writePointer = transaction.getWritePointer(); numInProgressTx = transaction.getInProgress().length; numInvalidTx = transaction.getInvalids().length; txClient.abort(transaction); } }
public static TTransaction wrap(Transaction tx) { return new TTransaction(tx.getTransactionId(), tx.getReadPointer(), Longs.asList(tx.getInvalids()), Longs.asList(tx.getInProgress()), tx.getFirstShortInProgress(), getTTransactionType(tx.getType()), tx.getWritePointer(), Longs.asList(tx.getCheckpointWritePointers()), getTVisibilityLevel(tx.getVisibilityLevel())); }