private NeoStores instantiateLegacyStore( RecordFormats format, DatabaseLayout directoryStructure ) { return new StoreFactory( directoryStructure, config, new ReadOnlyIdGeneratorFactory(), pageCache, fileSystem, format, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ).openAllNeoStores( true ); }
public void migrate( DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen ) { StoreType[] storesToOpen = ArrayUtil.concat( types, additionalTypesToOpen ); progressReporter.start( storesToOpen.length ); try ( NeoStores fromStores = new StoreFactory( fromDirectoryStructure, config, new DefaultIdGeneratorFactory( fs ), pageCache, fs, fromFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ); NeoStores toStores = new StoreFactory( toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom( fromStores, storesToOpen ), new DefaultIdGeneratorFactory( fs ), pageCache, fs, toFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ) ) { for ( StoreType type : types ) { // This condition will exclude counts store first and foremost. if ( type.isRecordStore() ) { migrate( fromStores.getRecordStore( type ), toStores.getRecordStore( type ) ); progressReporter.progress( 1 ); } } } }
private NeoStores open( FileSystemAbstraction fs, PageCache pageCache, RecordFormats format, Function<FileSystemAbstraction,IdGeneratorFactory> idGeneratorFactory, String... config ) throws IOException { assert neoStores == null : "Already opened"; TestDirectory testDirectory = TestDirectory.testDirectory( fs ); testDirectory.prepareDirectory( testClass, null ); Config configuration = configOf( config ); StoreFactory storeFactory = new StoreFactory( testDirectory.databaseLayout(), configuration, idGeneratorFactory.apply( fs ), pageCache, fs, format, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); return neoStores = stores.length == 0 ? storeFactory.openAllNeoStores( true ) : storeFactory.openNeoStores( true, stores ); }
@Before public void setUp() { StoreFactory storeFactory = getStoreFactory(); neoStores = storeFactory.openAllNeoStores( true ); }
private StoreFactory newStoreFactory( DatabaseLayout databaseLayout, OpenOption... openOptions ) { return new StoreFactory( databaseLayout, neo4jConfig, idGeneratorFactory, pageCache, fileSystem, recordFormats, logProvider, EmptyVersionContextSupplier.EMPTY, openOptions ); }
/** * Open {@link NeoStores} for requested and store types. If requested store depend from non request store, * it will be automatically opened as well. * If some store does not exist it will <b>not</b> be created. * @param storeTypes - types of stores to be opened. * @return container with opened stores */ public NeoStores openNeoStores( StoreType... storeTypes ) { return openNeoStores( false, storeTypes ); }
private DynamicArrayStore createDynamicArrayStore() { neoStores = storeFactory.openAllNeoStores( true ); return neoStores.getPropertyStore().getArrayStore(); }
private StoreFactory getStoreFactory( DatabaseLayout directoryStructure, String versionToMigrateFrom ) { NullLogProvider logProvider = NullLogProvider.getInstance(); RecordFormats recordFormats = selectForVersion( versionToMigrateFrom ); IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); return new StoreFactory( directoryStructure, config, idGeneratorFactory, pageCache, fileSystem, recordFormats, logProvider, EmptyVersionContextSupplier.EMPTY ); }
/** * Open {@link NeoStores} with all possible stores. If some store does not exist it will <b>not</b> be created. * @return container with all opened stores */ public NeoStores openAllNeoStores() { return openNeoStores( false, StoreType.values() ); }
public StoreAccess( FileSystemAbstraction fileSystem, PageCache pageCache, DatabaseLayout directoryStructure, Config config ) { this( new StoreFactory( directoryStructure, config, new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ).openAllNeoStores() ); this.closeable = true; }
private MetaDataStore newMetaDataStore() { LogProvider logProvider = NullLogProvider.getInstance(); StoreFactory storeFactory = new StoreFactory( testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( fs ), pageCacheWithFakeOverflow, fs, logProvider, EmptyVersionContextSupplier.EMPTY ); return storeFactory.openNeoStores( true, StoreType.META_DATA ).getMetaDataStore(); }
@Test( expected = StoreNotFoundException.class ) public void shouldThrowWhenOpeningNonExistingNeoStores() { try ( NeoStores neoStores = storeFactory( Config.defaults() ).openAllNeoStores() ) { neoStores.getMetaDataStore(); } }
private StoreFactory getStoreFactory( Config config, DatabaseLayout databaseLayout, FileSystemAbstraction ephemeralFileSystemAbstraction, NullLogProvider instance ) { return new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( ephemeralFileSystemAbstraction ), pageCache, ephemeralFileSystemAbstraction, instance, EmptyVersionContextSupplier.EMPTY ); } }
/** * Open {@link NeoStores} with all possible stores with a possibility to create store if it not exist. * @param createStoreIfNotExists - should store be created if it's not exist * @return container with all opened stores */ public NeoStores openAllNeoStores( boolean createStoreIfNotExists ) { return openNeoStores( createStoreIfNotExists, StoreType.values() ); }
private void createStore( DatabaseLayout migrationDirectoryStructure, RecordFormats newFormat ) { IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); NullLogProvider logProvider = NullLogProvider.getInstance(); StoreFactory storeFactory = new StoreFactory( migrationDirectoryStructure, config, idGeneratorFactory, pageCache, fileSystem, newFormat, logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores neoStores = storeFactory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); neoStores.getLabelTokenStore(); neoStores.getNodeStore(); neoStores.getPropertyStore(); neoStores.getRelationshipGroupStore(); neoStores.getRelationshipStore(); neoStores.getSchemaStore(); } }
@Test public void isPresentFalseAfterCreatingAllButLastStoreType() throws Exception { // given FileSystemAbstraction fileSystem = fs.get(); fileSystem.deleteRecursively( databaseLayout.databaseDirectory() ); DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory( fileSystem ); StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), idFactory, pageCache, fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); StoreType[] allStoreTypes = StoreType.values(); StoreType[] allButLastStoreTypes = Arrays.copyOf( allStoreTypes, allStoreTypes.length - 1 ); // when try ( NeoStores ignore = factory.openNeoStores( true, allButLastStoreTypes ) ) { // then assertFalse( NeoStores.isStorePresent( pageCache, databaseLayout ) ); } }
private void performTest( File idFile ) { // emulate the need for rebuilding id generators by deleting it fs.deleteFile( idFile ); try ( NeoStores neoStores = factory.openAllNeoStores() ) { // emulate a failure during rebuild: } catch ( UnderlyingStorageException expected ) { assertThat( expected.getMessage(), startsWith( "Id capacity exceeded" ) ); } }
private static StoreFactory newStoreFactory( DatabaseLayout databaseLayout, PageCache pageCache, FileSystemAbstraction fs ) { RecordFormats recordFormats = RecordFormatSelector.defaultFormat(); Config config = Config.defaults(); IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory( fs ); return new StoreFactory( databaseLayout, config, idGeneratorFactory, pageCache, fs, recordFormats, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); }
private NeoStores instantiateTempStores() { return newStoreFactory( temporaryDatabaseLayout ).openNeoStores( true, TEMP_STORE_TYPES ); }
private NodeStore newNodeStore( FileSystemAbstraction fs, PageCache pageCache ) throws IOException { idGeneratorFactory = spy( new DefaultIdGeneratorFactory( fs ) { @Override protected IdGenerator instantiate( FileSystemAbstraction fs, File fileName, int grabSize, long maxValue, boolean aggressiveReuse, IdType idType, LongSupplier highId ) { return spy( super.instantiate( fs, fileName, grabSize, maxValue, aggressiveReuse, idType, highId ) ); } } ); StoreFactory factory = new StoreFactory( testDirectory.databaseLayout( "new" ), Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); neoStores = factory.openAllNeoStores( true ); nodeStore = neoStores.getNodeStore(); return nodeStore; } }