Search in sources :

Example 41 with RecordFormats

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

the class BatchingNeoStoresTest method shouldNotDecideToAllocateDoubleRelationshipRecordUnitsOnLargeAmountOfRelationshipsOnUnsupportedFormat.

@Test
void shouldNotDecideToAllocateDoubleRelationshipRecordUnitsOnLargeAmountOfRelationshipsOnUnsupportedFormat() throws Exception {
    // given
    RecordFormats formats = LATEST_RECORD_FORMATS;
    try (BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fileSystem, pageCache, PageCacheTracer.NULL, databaseLayout, formats, Configuration.DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults(), INSTANCE)) {
        stores.createNew();
        Input.Estimates estimates = Input.knownEstimates(0, DOUBLE_RELATIONSHIP_RECORD_UNIT_THRESHOLD << 1, 0, 0, 0, 0, 0);
        // when
        boolean doubleUnits = stores.determineDoubleRelationshipRecordUnits(estimates);
        // then
        assertFalse(doubleUnits);
    }
}
Also used : Input(org.neo4j.internal.batchimport.input.Input) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) ForcedSecondaryUnitRecordFormats(org.neo4j.kernel.impl.store.format.ForcedSecondaryUnitRecordFormats) Test(org.junit.jupiter.api.Test)

Example 42 with RecordFormats

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

the class NeoStoreOpenFailureTest method mustCloseAllStoresIfNeoStoresFailToOpen.

@Test
@DisabledForRoot
void mustCloseAllStoresIfNeoStoresFailToOpen() {
    Config config = Config.defaults();
    IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
    LogProvider logProvider = NullLogProvider.getInstance();
    RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
    RecordFormatPropertyConfigurator.configureRecordFormat(formats, config);
    boolean create = true;
    StoreType[] storeTypes = StoreType.values();
    ImmutableSet<OpenOption> openOptions = immutable.empty();
    NeoStores neoStores = new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions);
    Path schemaStore = neoStores.getSchemaStore().getStorageFile();
    neoStores.close();
    // Make the schema store inaccessible, to sabotage the next initialisation we'll do.
    assumeTrue(schemaStore.toFile().setReadable(false));
    assumeTrue(schemaStore.toFile().setWritable(false));
    assertThrows(RuntimeException.class, () -> new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions));
    // We verify that the successfully opened stores were closed again by the failed NeoStores open,
    // by closing the page cache, which will throw if not all files have been unmapped.
    pageCache.close();
}
Also used : Path(java.nio.file.Path) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) OpenOption(java.nio.file.OpenOption) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) Test(org.junit.jupiter.api.Test) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 43 with RecordFormats

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

the class CommonAbstractStoreTest method failStoreInitializationWhenHeaderRecordCantBeRead.

@Test
void failStoreInitializationWhenHeaderRecordCantBeRead() throws IOException {
    Path storeFile = dir.file("a");
    Path idFile = dir.file("idFile");
    PageCache pageCache = mock(PageCache.class);
    PagedFile pagedFile = mock(PagedFile.class);
    PageCursor pageCursor = mock(PageCursor.class);
    when(pageCache.map(eq(storeFile), anyInt(), any(), any())).thenReturn(pagedFile);
    when(pagedFile.io(eq(0L), eq(PagedFile.PF_SHARED_READ_LOCK), any())).thenReturn(pageCursor);
    when(pageCursor.next()).thenReturn(false);
    RecordFormats recordFormats = Standard.LATEST_RECORD_FORMATS;
    try (DynamicArrayStore dynamicArrayStore = new DynamicArrayStore(storeFile, idFile, config, IdType.NODE_LABELS, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), GraphDatabaseInternalSettings.label_block_size.defaultValue(), recordFormats, writable(), databaseLayout.getDatabaseName(), immutable.empty())) {
        StoreNotFoundException storeNotFoundException = assertThrows(StoreNotFoundException.class, () -> dynamicArrayStore.initialise(false, NULL));
        assertEquals("Fail to read header record of store file: " + storeFile.toAbsolutePath(), storeNotFoundException.getMessage());
    }
}
Also used : Path(java.nio.file.Path) PagedFile(org.neo4j.io.pagecache.PagedFile) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) PageCache(org.neo4j.io.pagecache.PageCache) PageCursor(org.neo4j.io.pagecache.PageCursor) Test(org.junit.jupiter.api.Test)

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