public virtual void FlushAndForce() { if (_propertyKeyRepository != null) { _propertyKeyRepository.flush(); } if (_labelRepository != null) { _labelRepository.flush(); } if (_relationshipTypeRepository != null) { _relationshipTypeRepository.flush(); } if (_neoStores != null) { _neoStores.flush(UNLIMITED); FlushIdFiles(_neoStores, StoreType.values()); } if (_temporaryNeoStores != null) { _temporaryNeoStores.flush(UNLIMITED); FlushIdFiles(_temporaryNeoStores, _tempStoreTypes); } if (_labelScanStore != null) { _labelScanStore.force(UNLIMITED); } }
private object OpenStore(StoreType type) { int storeIndex = type.ordinal(); object store = type.open(this); _stores[storeIndex] = store; return(store); }
/// <summary> /// Returns specified store by type from already opened store array. Will open a new store if can't find any. /// Should be used only during construction of stores. /// </summary> /// <seealso cref= #getStore </seealso> /// <param name="storeType"> store type to get or create </param> /// <returns> store of requested type </returns> private object GetOrCreateStore(StoreType storeType) { object store = _stores[storeType.ordinal()]; if (store == null) { store = OpenStore(storeType); } return(store); }
/// <summary> /// Returns specified store by type from already opened store array. If store is not opened exception will be /// thrown. /// </summary> /// <seealso cref= #getOrCreateStore </seealso> /// <param name="storeType"> store type to retrieve </param> /// <returns> store of requested type </returns> /// <exception cref="IllegalStateException"> if opened store not found </exception> private object GetStore(StoreType storeType) { object store = _stores[storeType.ordinal()]; if (store == null) { string message = ArrayUtil.contains(_initializedStores, storeType) ? STORE_ALREADY_CLOSED_MESSAGE : string.format(_storeNotInitializedTemplate, storeType.name()); throw new System.InvalidOperationException(message); } return(store); }
private void DeleteStoreFiles(DatabaseLayout databaseLayout, System.Predicate <StoreType> storesToKeep) { foreach (StoreType type in StoreType.values()) { if (type.RecordStore && !storesToKeep(type)) { DatabaseFile databaseFile = type.DatabaseFile; databaseLayout.File(databaseFile).forEach(_fileSystem.deleteFile); databaseLayout.IdFile(databaseFile).ifPresent(_fileSystem.deleteFile); } } }
/// <summary> /// Determine type of a store base on provided database file. /// </summary> /// <param name="databaseFile"> - database file to map </param> /// <returns> an <seealso cref="Optional"/> that wraps the matching store type of the specified file, /// or <seealso cref="Optional.empty()"/> if the given file name does not match any store files. </returns> public static Optional <StoreType> TypeOf(Org.Neo4j.Io.layout.DatabaseFile databaseFile) { Objects.requireNonNull(databaseFile); StoreType[] values = StoreType.values(); foreach (StoreType value in values) { if (value.DatabaseFile.Equals(databaseFile)) { return(value); } } return(null); }
private void CloseStore(StoreType type) { int i = type.ordinal(); if (_stores[i] != null) { try { type.close(_stores[i]); } finally { _stores[i] = null; } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustCloseAllStoresIfNeoStoresFailToOpen() public virtual void MustCloseAllStoresIfNeoStoresFailToOpen() { PageCache pageCache = Rules.pageCache(); DatabaseLayout databaseLayout = Rules.directory().databaseLayout(); Config config = Config.defaults(); FileSystemAbstraction fs = Rules.fileSystem(); IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fs); LogProvider logProvider = NullLogProvider.Instance; VersionContextSupplier versions = EmptyVersionContextSupplier.EMPTY; RecordFormats formats = Standard.LATEST_RECORD_FORMATS; (new RecordFormatPropertyConfigurator(formats, config)).configure(); bool create = true; StoreType[] storeTypes = StoreType.values(); OpenOption[] openOptions = new OpenOption[0]; NeoStores neoStores = new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions); File schemaStore = neoStores.SchemaStore.StorageFile; neoStores.Close(); // Make the schema store inaccessible, to sabotage the next initialisation we'll do. assumeTrue(schemaStore.setReadable(false)); assumeTrue(schemaStore.setWritable(false)); try { // This should fail due to the permissions we changed above. // And when it fails, the already-opened stores should be closed. new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions); fail("Opening NeoStores should have thrown."); } catch (Exception) { } // 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(); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: NeoStores(org.neo4j.io.layout.DatabaseLayout layout, org.neo4j.kernel.configuration.Config config, org.neo4j.kernel.impl.store.id.IdGeneratorFactory idGeneratorFactory, org.neo4j.io.pagecache.PageCache pageCache, final org.neo4j.logging.LogProvider logProvider, org.neo4j.io.fs.FileSystemAbstraction fileSystemAbstraction, org.neo4j.io.pagecache.tracing.cursor.context.VersionContextSupplier versionContextSupplier, org.neo4j.kernel.impl.store.format.RecordFormats recordFormats, boolean createIfNotExist, StoreType[] storeTypes, java.nio.file.OpenOption[] openOptions) internal NeoStores(DatabaseLayout layout, Config config, IdGeneratorFactory idGeneratorFactory, PageCache pageCache, LogProvider logProvider, FileSystemAbstraction fileSystemAbstraction, VersionContextSupplier versionContextSupplier, RecordFormats recordFormats, bool createIfNotExist, StoreType[] storeTypes, OpenOption[] openOptions) { this._layout = layout; this._metadataStore = layout.MetadataStore(); this._config = config; this._idGeneratorFactory = idGeneratorFactory; this._pageCache = pageCache; this._logProvider = logProvider; this._fileSystemAbstraction = fileSystemAbstraction; this._versionContextSupplier = versionContextSupplier; this._recordFormats = recordFormats; this._createIfNotExist = createIfNotExist; this._openOptions = openOptions; VerifyRecordFormat(); _stores = new object[StoreType.values().length]; try { foreach (StoreType type in storeTypes) { GetOrCreateStore(type); } } catch (Exception initException) { try { Close(); } catch (Exception closeException) { initException.addSuppressed(closeException); } throw initException; } _initializedStores = storeTypes; }
private StoreType[] RelevantRecordStores() { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(Stream.of(StoreType.values()).filter(type => type.RecordStore && type != StoreType.META_DATA).toArray(StoreType[] ::new)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public <RECORD extends org.neo4j.kernel.impl.store.record.AbstractBaseRecord> RecordStore<RECORD> getRecordStore(StoreType type) public virtual RecordStore <RECORD> GetRecordStore <RECORD>(StoreType type) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { Debug.Assert(type.RecordStore); return((RecordStore <RECORD>)GetStore(type)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDelegateDeletionOptionToStores() public virtual void ShouldDelegateDeletionOptionToStores() { // GIVEN StoreFactory storeFactory = storeFactory(Config.defaults(), DELETE_ON_CLOSE); // WHEN _neoStores = storeFactory.OpenAllNeoStores(true); assertTrue(_fsRule.get().listFiles(_testDirectory.databaseDir()).length >= StoreType.values().length); // THEN _neoStores.close(); assertEquals(0, _fsRule.get().listFiles(_testDirectory.databaseDir()).length); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeTypeofSomeInvalidFile() public virtual void StoreTypeofSomeInvalidFile() { assertThat(StoreType.typeOf(DatabaseFile.LABEL_SCAN_STORE), @is(null)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeTypeOfMetaDataStoreFile() public virtual void StoreTypeOfMetaDataStoreFile() { StoreType matchedType = StoreType.typeOf(DatabaseFile.METADATA_STORE).orElseThrow(() => new System.InvalidOperationException("Store type not found")); assertEquals(StoreType.MetaData, matchedType); }
/// <summary> /// Open <seealso cref="NeoStores"/> with all possible stores with a possibility to create store if it not exist. </summary> /// <param name="createStoreIfNotExists"> - should store be created if it's not exist </param> /// <returns> container with all opened stores </returns> public virtual NeoStores OpenAllNeoStores(bool createStoreIfNotExists) { return(openNeoStores(createStoreIfNotExists, StoreType.values())); }
/// <summary> /// Open <seealso cref="NeoStores"/> with all possible stores. If some store does not exist it will <b>not</b> be created. </summary> /// <returns> container with all opened stores </returns> public virtual NeoStores OpenAllNeoStores() { return(openNeoStores(false, StoreType.values())); }