@Override public long getReadPointer() { Transaction tx = getCurrentTransaction(); if (tx == null) { return (-1); } return tx.getReadPointer(); }
+ getCurrentTransaction().getReadPointer());
@Override public long getReadPointer() { Transaction tx = getCurrentTransaction(); if (tx == null) { return (-1); } return tx.getReadPointer(); }
@Override public long getReadPointer() { Transaction tx = getCurrentTransaction(); if (tx == null) { return (-1); } return tx.getReadPointer(); }
/** * Gets the stop row for scan up to the read pointer of a transaction. Stop row is queueName + (readPointer + 1). */ public static byte[] getStopRowForTransaction(byte[] queueRowPrefix, Transaction transaction) { return Bytes.add(queueRowPrefix, Bytes.toBytes(transaction.getReadPointer() + 1)); }
/** * Returns whether or not the given version should be visible to the current transaction. A version will be visible * if it was successfully committed prior to the current transaction starting, or was written by the current * transaction (using either the current write pointer or the write pointer from a prior checkpoint). * * @param version the data version to check for visibility * @return true if the version is visible, false if it should be hidden (filtered) * * @see #setVisibility(VisibilityLevel) to control whether the current write pointer is visible. */ public boolean isVisible(long version) { // either it was committed before or the change belongs to current tx return (version <= getReadPointer() && !isExcluded(version)) || (isCurrentWrite(version) && (visibilityLevel != VisibilityLevel.SNAPSHOT_EXCLUDE_CURRENT || writePointer != version)); }
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); }
} else { LOG.info("Started tx: " + tx.getTransactionId() + ", readPointer: " + tx.getReadPointer() + ", invalids: " + tx.getInvalids().length + ", inProgress: " + tx.getInProgress().length);
/** * 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); } }
private void populateRowCache(Set<byte[]> excludeRows, int maxBatchSize, Stopwatch stopwatch) throws IOException { long readPointer = transaction.getReadPointer();
if (partitions.size() < limit) { scanUpTo = Math.min(tx.getWritePointer(), tx.getReadPointer() + 1); Long endTxId; try (Scanner scanner = partitionsTable.scanByIndex(WRITE_PTR_COL,
if (partitions.size() < limit) { scanUpTo = Math.min(tx.getWritePointer(), tx.getReadPointer() + 1); Long endTxId; try (Scanner scanner = partitionsTable.scanByIndex(WRITE_PTR_COL,
if (tx.getReadPointer() < key.txId) {
@Override public void commitDDLFence(PTable dataTable) throws SQLException { byte[] key = dataTable.getName().getBytes(); try { FenceWait fenceWait = VisibilityFence.prepareWait(key, txServiceClient); fenceWait.await(10000, TimeUnit.MILLISECONDS); if (logger.isInfoEnabled()) { logger.info("Added write fence at ~" + getCurrentTransaction().getReadPointer()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new SQLExceptionInfo.Builder( SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e) .build().buildException(); } catch (TimeoutException | TransactionFailureException e) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.TX_UNABLE_TO_GET_WRITE_FENCE) .setSchemaName(dataTable.getSchemaName().getString()) .setTableName(dataTable.getTableName().getString()).build() .buildException(); } }
+ getCurrentTransaction().getReadPointer());
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())); }