use of com.apple.foundationdb.Transaction in project fdb-record-layer by FoundationDB.
the class FDBRecordStoreStateCacheEntry method handleCachedState.
@Nonnull
CompletableFuture<Void> handleCachedState(@Nonnull FDBRecordContext context, @Nonnull FDBRecordStoreBase.StoreExistenceCheck existenceCheck) {
final Transaction tr = context.ensureActive();
tr.addReadConflictKey(subspace.pack(FDBRecordStoreKeyspace.STORE_INFO.key()));
return FDBRecordStore.checkStoreHeader(recordStoreState.getStoreHeader(), context, subspaceProvider, subspace, existenceCheck);
}
use of com.apple.foundationdb.Transaction in project lionrock by panghy.
the class TestFDBVersionstamp method testActualFDBGetVersionstamp.
/**
* Check that actual FDB client also hangs when using runAsync with getVersionstamp.
*/
@Test
public void testActualFDBGetVersionstamp() {
Database fdb = FDB.selectAPIVersion(630).open();
CompletableFuture<byte[]> cf = fdb.runAsync(Transaction::getVersionstamp);
assertFalse(cf.isDone());
}
use of com.apple.foundationdb.Transaction in project lionrock by panghy.
the class RemoteDatabase method runAsync.
@Override
public <T> CompletableFuture<T> runAsync(String name, Function<? super Transaction, ? extends CompletableFuture<T>> retryable, Executor e) {
final AtomicReference<Transaction> trRef = new AtomicReference<>(createTransaction(name, e));
final AtomicReference<T> returnValue = new AtomicReference<>();
return whileTrue(() -> composeHandleAsync(applySafely(retryable, trRef.get()).thenComposeAsync(returnVal -> trRef.get().commit().thenApply(o -> {
returnValue.set(returnVal);
return false;
}), e), (value, t) -> {
if (t == null) {
return CompletableFuture.completedFuture(value);
}
if (!(t instanceof RuntimeException)) {
throw new CompletionException(t);
}
return trRef.get().onError(t).thenApply(newTr -> {
trRef.set(newTr);
return true;
});
}, e), e).thenApply(o -> returnValue.get()).whenComplete((v, t) -> trRef.get().close());
}
use of com.apple.foundationdb.Transaction in project bsv-components-library by bitcoin-sv.
the class BlockChainStoreFDB method start.
@Override
public void start() {
super.start();
// If the DB is empty, we initialize it with the Genesis block:
if (getNumBlocks() == 0) {
Transaction tr = createTransaction();
executeInTransaction(tr, () -> _initGenesisBlock(tr, config.getGenesisBlock()));
}
// If enabled, we start the job to publish the DB State:
if (statePublishFrequency != null)
this.scheduledExecutorService.scheduleAtFixedRate(this::_publishState, statePublishFrequency.toMillis(), statePublishFrequency.toMillis(), TimeUnit.MILLISECONDS);
// If enabled, we start the job to do the automatic Prunning:
if (enableAutomaticForkPrunning)
this.scheduledExecutorService.scheduleAtFixedRate(this::_automaticForkPrunning, forkPrunningFrequency.toMillis(), forkPrunningFrequency.toMillis(), TimeUnit.MILLISECONDS);
// If enabled, we start the job to do the automatic ORPHAN Prunning:
if (enableAutomaticOrphanPrunning)
this.scheduledExecutorService.scheduleAtFixedRate(this::_automaticOrphanPrunning, orphanPrunningFrequency.toMillis(), orphanPrunningFrequency.toMillis(), TimeUnit.MILLISECONDS);
}
Aggregations