use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class Database method registerUpgradeListener.
private void registerUpgradeListener() {
DatabaseUpgradeTransactionHandler handler = new DatabaseUpgradeTransactionHandler(storageEngine, globalDependencies.resolveDependency(DbmsRuntimeRepository.class), storageEngine.metadataProvider(), databaseTransactionEventListeners, UpgradeLocker.DEFAULT, internalLogProvider);
handler.registerUpgradeListener(commands -> {
PhysicalTransactionRepresentation transactionRepresentation = new PhysicalTransactionRepresentation(commands);
long time = clock.millis();
transactionRepresentation.setHeader(EMPTY_BYTE_ARRAY, time, storageEngine.metadataProvider().getLastClosedTransactionId(), time, leaseService.newClient().leaseId(), AuthSubject.AUTH_DISABLED);
TransactionToApply toApply = new TransactionToApply(transactionRepresentation, CursorContext.NULL);
TransactionCommitProcess commitProcess = databaseDependencies.resolveDependency(TransactionCommitProcess.class);
commitProcess.commit(toApply, CommitEvent.NULL, TransactionApplicationMode.INTERNAL);
});
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnEmptyTransactionApply.
@Test
void tracePageCacheAccessOnEmptyTransactionApply() throws TransactionFailureException {
var transaction = new PhysicalTransactionRepresentation(emptyList(), EMPTY_BYTE_ARRAY, 0, 0, 0, 0, ANONYMOUS);
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnEmptyTransactionApply"))) {
assertZeroCursor(cursorContext);
commitProcess.commit(new TransactionToApply(transaction, cursorContext), NULL, EXTERNAL);
assertCursor(cursorContext, 2);
}
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class GraphStoreFixture method apply.
public void apply(Transaction transaction) throws KernelException {
TransactionRepresentation representation = transaction.representation(idGenerator(), transactionIdStore.getLastCommittedTransactionId(), neoStores, indexingService);
commitProcess.commit(new TransactionToApply(representation, NULL), CommitEvent.NULL, TransactionApplicationMode.EXTERNAL);
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class ReplicatedTokenStateMachine method applyToStore.
private int applyToStore(Collection<StorageCommand> commands, long logIndex) throws NoSuchEntryException {
int tokenId = extractTokenId(commands);
PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(commands);
representation.setHeader(encodeLogIndexAsTxHeader(logIndex), 0, 0, 0, 0L, 0L, 0);
try (LockGroup ignored = new LockGroup()) {
commitProcess.commit(new TransactionToApply(representation), CommitEvent.NULL, TransactionApplicationMode.EXTERNAL);
} catch (TransactionFailureException e) {
throw new RuntimeException(e);
}
return tokenId;
}
use of org.neo4j.kernel.impl.api.TransactionToApply in project neo4j by neo4j.
the class SlaveTransactionCommitProcessTest method mustTranslateComExceptionsToTransientTransactionFailures.
@Test(expected = TransientTransactionFailureException.class)
public void mustTranslateComExceptionsToTransientTransactionFailures() throws Exception {
when(master.commit(requestContext, tx)).thenThrow(new ComException());
// When
commitProcess.commit(new TransactionToApply(tx), CommitEvent.NULL, TransactionApplicationMode.INTERNAL);
// Then we assert that the right exception is thrown
}
Aggregations