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);
}
}
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();
}
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());
}
}
Aggregations