@Test public void callsStartTransactionForReadOnlyTransactionsIfFlagIsSet() throws InterruptedException { TimelockService timelockService = spy(new LegacyTimelockService(timestampService, closeableLockService, LockClient.of("lock"))); when(closeableLockService.lock(any(), any())).thenReturn(new LockRefreshToken(BigInteger.ONE, Long.MAX_VALUE)); SnapshotTransactionManager transactionManager = createSnapshotTransactionManager(timelockService, true); transactionManager.runTaskReadOnly(tx -> "ignored"); verify(timelockService).startIdentifiedAtlasDbTransactionBatch(1); transactionManager.runTaskWithConditionReadOnly(PreCommitConditions.NO_OP, (tx, condition) -> "ignored"); verify(timelockService, times(2)).startIdentifiedAtlasDbTransactionBatch(1); }
@Override public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithConditionReadOnly( C condition, ConditionAwareTransactionTask<T, C, E> task) throws E { if (transactionConfig.get().lockImmutableTsOnReadOnlyTransactions()) { return runTaskWithConditionThrowOnConflict(condition, task); } else { return runTaskWithConditionReadOnlyInternal(condition, task); } }
SnapshotTransactionManager extends AbstractLockAwareTransactionManager { @Override public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithConditionReadOnly( C condition, ConditionAwareTransactionTask<T, C, E> task) throws E { if (transactionConfig.get().lockImmutableTsOnReadOnlyTransactions()) { return runTaskWithConditionThrowOnConflict(condition, task); } else { return runTaskWithConditionReadOnlyInternal(condition, task); } } }
SnapshotTransactionManager extends AbstractLockAwareTransactionManager { @Override public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithConditionReadOnly( C condition, ConditionAwareTransactionTask<T, C, E> task) throws E { if (transactionConfig.get().lockImmutableTsOnReadOnlyTransactions()) { return runTaskWithConditionThrowOnConflict(condition, task); } else { return runTaskWithConditionReadOnlyInternal(condition, task); } } protected  SnapshotTransactionManager(
            MetricsManager metricsManager,
            KeyValueService keyValueService,
            TimelockService timelockService,
            LockWatchManager lockWatchManager,
            LockWatchEventCache lockWatchEventCache,
            TimestampManagementService timestampManagementService,
            LockService lockService,
            @NotNull TransactionService transactionService,
            Supplier<AtlasDbConstraintCheckingMode> constraintModeSupplier,
            ConflictDetectionManager conflictDetectionManager,
            SweepStrategyManager sweepStrategyManager,
            Cleaner cleaner,
            boolean allowHiddenTableAccess,
            int concurrentGetRangesThreadPoolSize,
            int defaultGetRangesConcurrency,
            TimestampCache timestampCache,
            MultiTableSweepQueueWriter sweepQueueWriter,
            ExecutorService deleteExecutor,
            boolean validateLocksOnReads,
            Supplier<TransactionConfig> transactionConfig,
            ConflictTracer conflictTracer,
            MetricsFilterEvaluationContext metricsFilterEvaluationContext); }
SnapshotTransactionManager extends AbstractLockAwareTransactionManager { @Override public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithConditionReadOnly( C condition, ConditionAwareTransactionTask<T, C, E> task) throws E { if (transactionConfig.get().lockImmutableTsOnReadOnlyTransactions()) { return runTaskWithConditionThrowOnConflict(condition, task); } else { return runTaskWithConditionReadOnlyInternal(condition, task); } } protected  SnapshotTransactionManager(
            MetricsManager metricsManager,
            KeyValueService keyValueService,
            TimelockService timelockService,
            LockWatchManager lockWatchManager,
            LockWatchEventCache lockWatchEventCache,
            TimestampManagementService timestampManagementService,
            LockService lockService,
            @NotNull TransactionService transactionService,
            Supplier<AtlasDbConstraintCheckingMode> constraintModeSupplier,
            ConflictDetectionManager conflictDetectionManager,
            SweepStrategyManager sweepStrategyManager,
            Cleaner cleaner,
            boolean allowHiddenTableAccess,
            int concurrentGetRangesThreadPoolSize,
            int defaultGetRangesConcurrency,
            TimestampCache timestampCache,
            MultiTableSweepQueueWriter sweepQueueWriter,
            ExecutorService deleteExecutor,
            boolean validateLocksOnReads,
            Supplier<TransactionConfig> transactionConfig,
            ConflictTracer conflictTracer,
            MetricsFilterEvaluationContext metricsFilterEvaluationContext); @Override T runTaskWithConditionThrowOnConflict(
            C condition, ConditionAwareTransactionTask<T, C, E> task); @Override List<OpenTransaction> startTransactions(List<? extends PreCommitCondition> conditions); @Override T runTaskWithConditionReadOnly(
            C condition, ConditionAwareTransactionTask<T, C, E> task); @Override void registerClosingCallback(Runnable closingCallback); @Override void close(); @Override void clearTimestampCache(); @Override LockService getLockService(); @Override TimelockService getTimelockService(); @Override LockWatchManager getLockWatchManager(); @Override long getImmutableTimestamp(); @Override long getUnreadableTimestamp(); @Override Cleaner getCleaner(); @Override KeyValueService getKeyValueService(); @Override TimestampService getTimestampService(); @Override TimestampManagementService getTimestampManagementService(); @Override TransactionService getTransactionService(); @Override KeyValueServiceStatus getKeyValueServiceStatus(); }
SnapshotTransactionManager extends AbstractLockAwareTransactionManager { @Override public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithConditionReadOnly( C condition, ConditionAwareTransactionTask<T, C, E> task) throws E { if (transactionConfig.get().lockImmutableTsOnReadOnlyTransactions()) { return runTaskWithConditionThrowOnConflict(condition, task); } else { return runTaskWithConditionReadOnlyInternal(condition, task); } } protected  SnapshotTransactionManager(
            MetricsManager metricsManager,
            KeyValueService keyValueService,
            TimelockService timelockService,
            LockWatchManager lockWatchManager,
            LockWatchEventCache lockWatchEventCache,
            TimestampManagementService timestampManagementService,
            LockService lockService,
            @NotNull TransactionService transactionService,
            Supplier<AtlasDbConstraintCheckingMode> constraintModeSupplier,
            ConflictDetectionManager conflictDetectionManager,
            SweepStrategyManager sweepStrategyManager,
            Cleaner cleaner,
            boolean allowHiddenTableAccess,
            int concurrentGetRangesThreadPoolSize,
            int defaultGetRangesConcurrency,
            TimestampCache timestampCache,
            MultiTableSweepQueueWriter sweepQueueWriter,
            ExecutorService deleteExecutor,
            boolean validateLocksOnReads,
            Supplier<TransactionConfig> transactionConfig,
            ConflictTracer conflictTracer,
            MetricsFilterEvaluationContext metricsFilterEvaluationContext); @Override T runTaskWithConditionThrowOnConflict(
            C condition, ConditionAwareTransactionTask<T, C, E> task); @Override List<OpenTransaction> startTransactions(List<? extends PreCommitCondition> conditions); @Override T runTaskWithConditionReadOnly(
            C condition, ConditionAwareTransactionTask<T, C, E> task); @Override void registerClosingCallback(Runnable closingCallback); @Override void close(); @Override void clearTimestampCache(); @Override LockService getLockService(); @Override TimelockService getTimelockService(); @Override LockWatchManager getLockWatchManager(); @Override long getImmutableTimestamp(); @Override long getUnreadableTimestamp(); @Override Cleaner getCleaner(); @Override KeyValueService getKeyValueService(); @Override TimestampService getTimestampService(); @Override TimestampManagementService getTimestampManagementService(); @Override TransactionService getTransactionService(); @Override KeyValueServiceStatus getKeyValueServiceStatus();  }