Search in sources :

Example 31 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class VersionCommandTest method readsLatestStoreVersionCorrectly.

@Test
public void readsLatestStoreVersionCorrectly() throws Exception {
    RecordFormats currentFormat = RecordFormatSelector.defaultFormat();
    prepareNeoStoreFile(currentFormat.storeVersion());
    execute(databaseDirectory.toString());
    verify(out, times(3)).accept(outCaptor.capture());
    assertEquals(Arrays.asList(String.format("Store format version:    %s", currentFormat.storeVersion()), String.format("Introduced in version:   %s", currentFormat.introductionVersion()), String.format("Current version:         %s", Version.getNeo4jVersion())), outCaptor.getAllValues());
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Test(org.junit.Test)

Example 32 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class NeoStoreDataSource method start.

@Override
public void start() throws IOException {
    dependencies = new Dependencies();
    life = new LifeSupport();
    schemaIndexProvider = dependencyResolver.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
    labelScanStoreProvider = dependencyResolver.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config));
    dependencyResolver.resolveDependency(LabelScanStoreProvider.class, new DeleteStoresFromOtherLabelScanStoreProviders(labelScanStoreProvider));
    IndexConfigStore indexConfigStore = new IndexConfigStore(storeDir, fs);
    dependencies.satisfyDependency(lockService);
    dependencies.satisfyDependency(indexConfigStore);
    life.add(indexConfigStore);
    // Monitor listeners
    LoggingLogFileMonitor loggingLogMonitor = new LoggingLogFileMonitor(msgLog);
    monitors.addMonitorListener(loggingLogMonitor);
    life.add(new Delegate(Lifecycles.multiple(indexProviders.values())));
    // Upgrade the store before we begin
    RecordFormats formats = selectStoreFormats(config, storeDir, fs, pageCache, logService);
    upgradeStore(formats);
    // Build all modules and their services
    StorageEngine storageEngine = null;
    try {
        UpdateableSchemaState updateableSchemaState = new KernelSchemaStateStore(logProvider);
        SynchronizedArrayIdOrderingQueue legacyIndexTransactionOrdering = new SynchronizedArrayIdOrderingQueue(20);
        storageEngine = buildStorageEngine(propertyKeyTokenHolder, labelTokens, relationshipTypeTokens, legacyIndexProviderLookup, indexConfigStore, updateableSchemaState::clear, legacyIndexTransactionOrdering);
        LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>(storageEngine.commandReaderFactory());
        TransactionIdStore transactionIdStore = dependencies.resolveDependency(TransactionIdStore.class);
        LogVersionRepository logVersionRepository = dependencies.resolveDependency(LogVersionRepository.class);
        NeoStoreTransactionLogModule transactionLogModule = buildTransactionLogs(storeDir, config, logProvider, scheduler, fs, storageEngine, logEntryReader, legacyIndexTransactionOrdering, transactionIdStore, logVersionRepository);
        transactionLogModule.satisfyDependencies(dependencies);
        buildRecovery(fs, transactionIdStore, logVersionRepository, monitors.newMonitor(Recovery.Monitor.class), monitors.newMonitor(PositionToRecoverFrom.Monitor.class), transactionLogModule.logFiles(), startupStatistics, storageEngine, logEntryReader, transactionLogModule.logicalTransactionStore());
        // At the time of writing this comes from the storage engine (IndexStoreView)
        PropertyAccessor propertyAccessor = dependencies.resolveDependency(PropertyAccessor.class);
        final NeoStoreKernelModule kernelModule = buildKernel(transactionLogModule.transactionAppender(), dependencies.resolveDependency(IndexingService.class), storageEngine.storeReadLayer(), updateableSchemaState, dependencies.resolveDependency(LabelScanStore.class), storageEngine, indexConfigStore, transactionIdStore, availabilityGuard, clock, propertyAccessor);
        kernelModule.satisfyDependencies(dependencies);
        // Do these assignments last so that we can ensure no cyclical dependencies exist
        this.storageEngine = storageEngine;
        this.transactionLogModule = transactionLogModule;
        this.kernelModule = kernelModule;
        dependencies.satisfyDependency(this);
        dependencies.satisfyDependency(updateableSchemaState);
        dependencies.satisfyDependency(storageEngine.storeReadLayer());
        dependencies.satisfyDependency(logEntryReader);
        dependencies.satisfyDependency(storageEngine);
    } catch (Throwable e) {
        // Something unexpected happened during startup
        msgLog.warn("Exception occurred while setting up store modules. Attempting to close things down.", e);
        try {
            // Close the neostore, so that locks are released properly
            if (storageEngine != null) {
                storageEngine.forceClose();
            }
        } catch (Exception closeException) {
            msgLog.error("Couldn't close neostore after startup failure", closeException);
        }
        throw Exceptions.launderedException(e);
    }
    // NOTE: please make sure this is performed after having added everything to the life, in fact we would like
    // to perform the checkpointing as first step when the life is shutdown.
    life.add(lifecycleToTriggerCheckPointOnShutdown());
    try {
        life.start();
    } catch (Throwable e) {
        // Something unexpected happened during startup
        msgLog.warn("Exception occurred while starting the datasource. Attempting to close things down.", e);
        try {
            life.shutdown();
            // Close the neostore, so that locks are released properly
            storageEngine.forceClose();
        } catch (Exception closeException) {
            msgLog.error("Couldn't close neostore after startup failure", closeException);
        }
        throw Exceptions.launderedException(e);
    }
    /*
         * At this point recovery has completed and the datasource is ready for use. Whatever panic might have
         * happened before has been healed. So we can safely set the kernel health to ok.
         * This right now has any real effect only in the case of internal restarts (for example, after a store copy
         * in the case of HA). Standalone instances will have to be restarted by the user, as is proper for all
         * kernel panics.
         */
    databaseHealth.healed();
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) StorageEngine(org.neo4j.storageengine.api.StorageEngine) LogVersionRepository(org.neo4j.kernel.impl.transaction.log.LogVersionRepository) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) TransactionMonitor(org.neo4j.kernel.impl.transaction.TransactionMonitor) LoggingLogFileMonitor(org.neo4j.kernel.impl.transaction.log.LoggingLogFileMonitor) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) KernelSchemaStateStore(org.neo4j.kernel.impl.api.KernelSchemaStateStore) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) Dependencies(org.neo4j.kernel.impl.util.Dependencies) DeleteStoresFromOtherLabelScanStoreProviders(org.neo4j.kernel.extension.dependency.DeleteStoresFromOtherLabelScanStoreProviders) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) LoggingLogFileMonitor(org.neo4j.kernel.impl.transaction.log.LoggingLogFileMonitor) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) IOException(java.io.IOException) KernelException(org.neo4j.kernel.api.exceptions.KernelException) UpdateableSchemaState(org.neo4j.kernel.impl.api.UpdateableSchemaState) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) SynchronizedArrayIdOrderingQueue(org.neo4j.kernel.impl.util.SynchronizedArrayIdOrderingQueue)

Example 33 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class InputEntityCacherTokenCreationTest method mockRecordFormats.

private RecordFormats mockRecordFormats(long maxPropertyKeyId, long maxLabelId, long maxRelationshipTypeId, long maxRelationshipGroupId) {
    RecordFormats recordFormats = mock(RecordFormats.class);
    RecordFormat propertyKeyTokenFormat = getRecordFormatMock(maxPropertyKeyId);
    RecordFormat labelTokenFormat = getRecordFormatMock(maxLabelId);
    RecordFormat relationshipTypeTokenFormat = getRecordFormatMock(maxRelationshipTypeId);
    RecordFormat relationshipGroupTokenFormat = getRecordFormatMock(maxRelationshipGroupId);
    when(recordFormats.propertyKeyToken()).thenReturn(propertyKeyTokenFormat);
    when(recordFormats.labelToken()).thenReturn(labelTokenFormat);
    when(recordFormats.relationshipTypeToken()).thenReturn(relationshipTypeTokenFormat);
    when(recordFormats.relationshipGroup()).thenReturn(relationshipGroupTokenFormat);
    return recordFormats;
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) RecordFormat(org.neo4j.kernel.impl.store.format.RecordFormat)

Example 34 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class BatchingNeoStoresTest method shouldRespectDbConfig.

@Test
public void shouldRespectDbConfig() throws Exception {
    // GIVEN
    int size = 10;
    Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.array_block_size.name(), String.valueOf(size), GraphDatabaseSettings.string_block_size.name(), String.valueOf(size)));
    // WHEN
    RecordFormats recordFormats = Standard.LATEST_RECORD_FORMATS;
    int headerSize = recordFormats.dynamic().getRecordHeaderSize();
    try (BatchingNeoStores store = BatchingNeoStores.batchingNeoStores(fsr.get(), storeDir, recordFormats, DEFAULT, NullLogService.getInstance(), EMPTY, config)) {
        // THEN
        assertEquals(size + headerSize, store.getPropertyStore().getArrayStore().getRecordSize());
        assertEquals(size + headerSize, store.getPropertyStore().getStringStore().getRecordSize());
    }
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 35 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class MultipleIndexPopulationStressIT method createRandomData.

private void createRandomData(int count) throws IOException {
    Config config = Config.empty();
    RecordFormats recordFormats = RecordFormatSelector.selectForConfig(config, NullLogProvider.getInstance());
    BatchImporter importer = new ParallelBatchImporter(directory.graphDbDir(), fileSystemRule.get(), DEFAULT, NullLogService.getInstance(), ExecutionMonitors.invisible(), EMPTY, config, recordFormats);
    importer.doImport(new RandomDataInput(count));
}
Also used : ParallelBatchImporter(org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) BatchImporter(org.neo4j.unsafe.impl.batchimport.BatchImporter) ParallelBatchImporter(org.neo4j.unsafe.impl.batchimport.ParallelBatchImporter) Config(org.neo4j.kernel.configuration.Config)

Aggregations

RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)43 Test (org.junit.jupiter.api.Test)13 IOException (java.io.IOException)10 Config (org.neo4j.configuration.Config)8 PageCache (org.neo4j.io.pagecache.PageCache)8 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)7 NullLogProvider (org.neo4j.logging.NullLogProvider)7 Config (org.neo4j.kernel.configuration.Config)6 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)6 File (java.io.File)5 Path (java.nio.file.Path)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)5 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 ForcedSecondaryUnitRecordFormats (org.neo4j.kernel.impl.store.format.ForcedSecondaryUnitRecordFormats)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)4 PagedFile (org.neo4j.io.pagecache.PagedFile)4 LogProvider (org.neo4j.logging.LogProvider)4 NoSuchFileException (java.nio.file.NoSuchFileException)3