use of org.neo4j.storageengine.api.KernelVersionRepository in project neo4j by neo4j.
the class LogFilesBuilder method buildContext.
TransactionLogFilesContext buildContext() throws IOException {
if (logEntryReader == null) {
requireNonNull(commandReaderFactory);
logEntryReader = new VersionAwareLogEntryReader(commandReaderFactory);
}
if (config == null) {
config = Config.defaults();
}
requireNonNull(fileSystem);
Supplier<StoreId> storeIdSupplier = getStoreId();
Supplier<LogVersionRepository> logVersionRepositorySupplier = getLogVersionRepositorySupplier();
LongSupplier lastCommittedIdSupplier = lastCommittedIdSupplier();
LongSupplier committingTransactionIdSupplier = committingIdSupplier();
Supplier<LogPosition> lastClosedTransactionPositionSupplier = closePositionSupplier();
// Register listener for rotation threshold
AtomicLong rotationThreshold = getRotationThresholdAndRegisterForUpdates();
AtomicBoolean tryPreallocateTransactionLogs = getTryToPreallocateTransactionLogs();
var nativeAccess = getNativeAccess();
var monitors = getMonitors();
var health = getDatabaseHealth();
var clock = getClock();
// Or the latest version if we can't find the system db version.
if (kernelVersionRepository == null) {
kernelVersionRepository = () -> KernelVersion.LATEST;
if (dependencies != null) {
try {
this.kernelVersionRepository = dependencies.resolveDependency(KernelVersionRepository.class);
} catch (UnsatisfiedDependencyException e) {
// Use latest version if can't find version repository.
}
}
}
return new TransactionLogFilesContext(rotationThreshold, tryPreallocateTransactionLogs, logEntryReader, lastCommittedIdSupplier, committingTransactionIdSupplier, lastClosedTransactionPositionSupplier, logVersionRepositorySupplier, fileSystem, logProvider, databaseTracers, storeIdSupplier, nativeAccess, memoryTracker, monitors, config.get(fail_on_corrupted_log_files), health, kernelVersionRepository, clock, config);
}
use of org.neo4j.storageengine.api.KernelVersionRepository in project neo4j by neo4j.
the class DatabaseUpgradeTransactionHandlerTest method init.
private void init(KernelVersion initialKernelVersion, DbmsRuntimeVersion initialDbmsRuntimeVersion) {
setKernelVersion(initialKernelVersion);
setDbmsRuntime(initialDbmsRuntimeVersion);
StorageEngine storageEngine = mock(StorageEngine.class);
doAnswer(inv -> {
KernelVersion toKernelVersion = inv.getArgument(0, KernelVersion.class);
registeredTransactions.add(new RegisteredTransaction(toKernelVersion, true));
return List.of(new FakeKernelVersionUpgradeCommand(toKernelVersion));
}).when(storageEngine).createUpgradeCommands(any(), any());
DbmsRuntimeRepository dbmsRuntimeRepository = mock(DbmsRuntimeRepository.class);
doAnswer(inv -> currentDbmsRuntimeVersion).when(dbmsRuntimeRepository).getVersion();
KernelVersionRepository kernelVersionRepository = this::getKernelVersion;
DatabaseTransactionEventListeners databaseTransactionEventListeners = mock(DatabaseTransactionEventListeners.class);
doAnswer(inv -> listener = inv.getArgument(0, InternalTransactionEventListener.class)).when(databaseTransactionEventListeners).registerTransactionEventListener(any());
doAnswer(inv -> listenerUnregistered = true).when(databaseTransactionEventListeners).unregisterTransactionEventListener(any());
DatabaseUpgradeTransactionHandler handler = new DatabaseUpgradeTransactionHandler(storageEngine, dbmsRuntimeRepository, kernelVersionRepository, databaseTransactionEventListeners, lock, logProvider);
handler.registerUpgradeListener(commands -> setKernelVersion(((FakeKernelVersionUpgradeCommand) commands.iterator().next()).version));
}
Aggregations