Search in sources :

Example 1 with KernelVersionRepository

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);
}
Also used : LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) KernelVersionRepository(org.neo4j.storageengine.api.KernelVersionRepository) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicLong(java.util.concurrent.atomic.AtomicLong) UnsatisfiedDependencyException(org.neo4j.exceptions.UnsatisfiedDependencyException) StoreId(org.neo4j.storageengine.api.StoreId) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) LongSupplier(java.util.function.LongSupplier) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition)

Example 2 with KernelVersionRepository

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));
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) DbmsRuntimeRepository(org.neo4j.dbms.database.DbmsRuntimeRepository) DatabaseTransactionEventListeners(org.neo4j.kernel.internal.event.DatabaseTransactionEventListeners) StorageEngine(org.neo4j.storageengine.api.StorageEngine) KernelVersionRepository(org.neo4j.storageengine.api.KernelVersionRepository)

Aggregations

KernelVersionRepository (org.neo4j.storageengine.api.KernelVersionRepository)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 LongSupplier (java.util.function.LongSupplier)1 DbmsRuntimeRepository (org.neo4j.dbms.database.DbmsRuntimeRepository)1 UnsatisfiedDependencyException (org.neo4j.exceptions.UnsatisfiedDependencyException)1 KernelVersion (org.neo4j.kernel.KernelVersion)1 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)1 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)1 DatabaseTransactionEventListeners (org.neo4j.kernel.internal.event.DatabaseTransactionEventListeners)1 LogVersionRepository (org.neo4j.storageengine.api.LogVersionRepository)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1 StoreId (org.neo4j.storageengine.api.StoreId)1