Пример #1
0
 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);
     }
 }
Пример #2
0
 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);
         }
     }
 }
Пример #3
0
 /// <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);
 }
Пример #4
0
//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();
        }
Пример #5
0
//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;
        }
Пример #6
0
        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));
        }
Пример #7
0
//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);
        }
Пример #8
0
 /// <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()));
 }
Пример #9
0
 /// <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()));
 }