@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return executeWithRecord(() -> timelockService.startIdentifiedAtlasDbTransaction(request)); }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { StartIdentifiedAtlasDbTransactionResponse response = executeOnTimeLock( () -> delegate.startIdentifiedAtlasDbTransaction(request)); lockRefresher.registerLock(response.immutableTimestamp().getLock()); return response; }
@Test public void startIdentifiedAtlasDbTransactionShouldFail() { StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransactionResponse = StartIdentifiedAtlasDbTransactionResponse.of(LOCK_IMMUTABLE_TIMESTAMP_RESPONSE, TimestampAndPartition.of(1L, 0)); when(rawTimelockService.startIdentifiedAtlasDbTransaction(any())) .thenReturn(startIdentifiedAtlasDbTransactionResponse); assertThrowsOnSecondCall(() -> timelockService.startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest.createForRequestor(UUID.randomUUID()))); }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return checkAndUpdateLowerBound(() -> delegate.startIdentifiedAtlasDbTransaction(request), r -> r.startTimestampAndPartition().timestamp(), r -> r.startTimestampAndPartition().timestamp()); }
when(timelock.lockImmutableTimestamp(any())).thenReturn( LockImmutableTimestampResponse.of(2L, LockToken.of(UUID.randomUUID()))); when(timelock.startIdentifiedAtlasDbTransaction(any())).thenReturn( StartIdentifiedAtlasDbTransactionResponse.of( LockImmutableTimestampResponse.of(2L, LockToken.of(UUID.randomUUID())),
@Override public TransactionAndImmutableTsLock setupRunTaskWithConditionThrowOnConflict(PreCommitCondition condition) { StartIdentifiedAtlasDbTransactionResponse transactionResponse = timelockService.startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest.createForRequestor(clientId)); try { LockToken immutableTsLock = transactionResponse.immutableTimestamp().getLock(); long immutableTs = transactionResponse.immutableTimestamp().getImmutableTimestamp(); recordImmutableTimestamp(immutableTs); cleaner.punch(transactionResponse.startTimestampAndPartition().timestamp()); Supplier<Long> startTimestampSupplier = Suppliers.ofInstance( transactionResponse.startTimestampAndPartition().timestamp()); SnapshotTransaction transaction = createTransaction(immutableTs, startTimestampSupplier, immutableTsLock, condition); return TransactionAndImmutableTsLock.of(transaction, immutableTsLock); } catch (Throwable e) { timelockService.tryUnlock(ImmutableSet.of(transactionResponse.immutableTimestamp().getLock())); throw Throwables.rewrapAndThrowUncheckedException(e); } }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return executeWithRecord(() -> timelockService.startIdentifiedAtlasDbTransaction(request)); }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { StartIdentifiedAtlasDbTransactionResponse response = executeOnTimeLock( () -> delegate.startIdentifiedAtlasDbTransaction(request)); lockRefresher.registerLock(response.immutableTimestamp().getLock()); return response; }
@Override public StartIdentifiedAtlasDbTransactionResponse startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest request) { return checkAndUpdateLowerBound(() -> delegate.startIdentifiedAtlasDbTransaction(request), r -> r.startTimestampAndPartition().timestamp(), r -> r.startTimestampAndPartition().timestamp()); }
@Override public TransactionAndImmutableTsLock setupRunTaskWithConditionThrowOnConflict(PreCommitCondition condition) { StartIdentifiedAtlasDbTransactionResponse transactionResponse = timelockService.startIdentifiedAtlasDbTransaction( StartIdentifiedAtlasDbTransactionRequest.createForRequestor(clientId)); try { LockToken immutableTsLock = transactionResponse.immutableTimestamp().getLock(); long immutableTs = transactionResponse.immutableTimestamp().getImmutableTimestamp(); recordImmutableTimestamp(immutableTs); cleaner.punch(transactionResponse.startTimestampAndPartition().timestamp()); Supplier<Long> startTimestampSupplier = Suppliers.ofInstance( transactionResponse.startTimestampAndPartition().timestamp()); SnapshotTransaction transaction = createTransaction(immutableTs, startTimestampSupplier, immutableTsLock, condition); return TransactionAndImmutableTsLock.of(transaction, immutableTsLock); } catch (Throwable e) { timelockService.tryUnlock(ImmutableSet.of(transactionResponse.immutableTimestamp().getLock())); throw Throwables.rewrapAndThrowUncheckedException(e); } }