コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void createStore()
        public virtual void CreateStore()
        {
            _file       = new File("target/test-data/index-provider-store");
            _fileSystem = new DefaultFileSystemAbstraction();
            _file.mkdirs();
            _fileSystem.deleteFile(_file);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void truncateLogFiles(long recoveredTransactionLogVersion, long recoveredTransactionOffset) throws java.io.IOException
        private void TruncateLogFiles(long recoveredTransactionLogVersion, long recoveredTransactionOffset)
        {
            File lastRecoveredTransactionLog = _logFiles.getLogFileForVersion(recoveredTransactionLogVersion);

            _fs.truncate(lastRecoveredTransactionLog, recoveredTransactionOffset);
            ForEachSubsequentLogFile(recoveredTransactionLogVersion, fileIndex => _fs.deleteFile(_logFiles.getLogFileForVersion(fileIndex)));
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void writeState(T state) throws java.io.IOException
        public override void WriteState(T state)
        {
            _fileSystem.mkdirs(_file.ParentFile);
            _fileSystem.deleteFile(_file);

            using (FlushableChannel channel = new PhysicalFlushableChannel(_fileSystem.create(_file)))
            {
                _marshal.marshal(state, channel);
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDeleteAnythingIfThresholdDoesNotAllow()
        public virtual void ShouldNotDeleteAnythingIfThresholdDoesNotAllow()
        {
            // Given
            File fileName0 = new File("logical.log.v0");
            File fileName1 = new File("logical.log.v1");
            File fileName2 = new File("logical.log.v2");
            File fileName3 = new File("logical.log.v3");
            File fileName4 = new File("logical.log.v4");
            File fileName5 = new File("logical.log.v5");
            File fileName6 = new File("logical.log.v6");

            when(_files.getLogFileForVersion(6)).thenReturn(fileName6);
            when(_files.getLogFileForVersion(5)).thenReturn(fileName5);
            when(_files.getLogFileForVersion(4)).thenReturn(fileName4);
            when(_files.getLogFileForVersion(3)).thenReturn(fileName3);
            when(_files.getLogFileForVersion(2)).thenReturn(fileName2);
            when(_files.getLogFileForVersion(1)).thenReturn(fileName1);
            when(_files.getLogFileForVersion(0)).thenReturn(fileName0);

            when(_fileSystem.fileExists(fileName6)).thenReturn(true);
            when(_fileSystem.fileExists(fileName5)).thenReturn(true);
            when(_fileSystem.fileExists(fileName4)).thenReturn(true);
            when(_fileSystem.fileExists(fileName3)).thenReturn(true);
            when(_fileSystem.fileExists(fileName2)).thenReturn(true);
            when(_fileSystem.fileExists(fileName1)).thenReturn(true);
            when(_fileSystem.fileExists(fileName0)).thenReturn(true);

            when(_fileSystem.getFileSize(any())).thenReturn(LOG_HEADER_SIZE + 1L);

            when(_threshold.reached(any(), anyLong(), any())).thenReturn(false);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ThresholdBasedPruneStrategy strategy = new ThresholdBasedPruneStrategy(fileSystem, files, threshold);
            ThresholdBasedPruneStrategy strategy = new ThresholdBasedPruneStrategy(_fileSystem, _files, _threshold);

            // When
            strategy.FindLogVersionsToDelete(7L).forEachOrdered(v => _fileSystem.deleteFile(_files.getLogFileForVersion(v)));

            // Then
            verify(_threshold, times(1)).init();
            verify(_fileSystem, never()).deleteFile(any());
        }
コード例 #5
0
ファイル: FusionIndexIT.cs プロジェクト: Neo4Net/Neo4Net
        private void DeleteIndexFilesFor(IndexProviderDescriptor descriptor)
        {
            File databaseDirectory = this._databaseLayout.databaseDirectory();
            File rootDirectory     = subProviderDirectoryStructure(databaseDirectory).forProvider(descriptor).rootDirectory();

            File[] files = _fs.listFiles(rootDirectory);
            foreach (File indexFile in files)
            {
                _fs.deleteFile(indexFile);
            }
        }
コード例 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void close() throws java.io.IOException
        public override void Close()
        {
            if (_allocated)
            {
                runAll("Failed while trying to close " + this.GetType().Name, () => closeAllUnchecked(_pageCursor, _storeChannel), () => _fs.deleteFile(_file));
            }
            else
            {
                _fs.deleteFile(_file);
            }
        }
コード例 #7
0
        private void Prepare34DatabaseWithNodes()
        {
            GraphDatabaseService embeddedDatabase = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(_storeDir);

            try
            {
                using (Transaction transaction = embeddedDatabase.BeginTx())
                {
                    for (int i = 0; i < 10; i++)
                    {
                        embeddedDatabase.CreateNode(Label.label("label" + i));
                    }
                    transaction.Success();
                }
            }
            finally
            {
                embeddedDatabase.Shutdown();
            }
            _fileSystem.deleteFile(_nativeLabelIndex);
        }
コード例 #8
0
ファイル: BatchingNeoStores.cs プロジェクト: Neo4Net/Neo4Net
        /// <summary>
        /// Called when expecting a clean {@code storeDir} folder and where a new store will be created.
        /// This happens on an initial attempt to import.
        /// </summary>
        /// <exception cref="IOException"> on I/O error. </exception>
        /// <exception cref="IllegalStateException"> if {@code storeDir} already contains a database. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void createNew() throws java.io.IOException
        public virtual void CreateNew()
        {
            AssertDatabaseIsEmptyOrNonExistent();

            // There may have been a previous import which was killed before it even started, where the label scan store could
            // be in a semi-initialized state. Better to be on the safe side and deleted it. We get her after determining that
            // the db is either completely empty or non-existent anyway, so deleting this file is OK.
            _fileSystem.deleteFile(getLabelScanStoreFile(_databaseLayout));

            InstantiateStores();
            _neoStores.MetaDataStore.setLastCommittedAndClosedTransactionId(_initialIds.lastCommittedTransactionId(), _initialIds.lastCommittedTransactionChecksum(), BASE_TX_COMMIT_TIMESTAMP, _initialIds.lastCommittedTransactionLogByteOffset(), _initialIds.lastCommittedTransactionLogVersion());
            _neoStores.startCountStore();
        }
コード例 #9
0
        private static java.io.File toFile(Org.Neo4j.Io.fs.FileSystemAbstraction fs, java.io.File directory, String name, ExistingTargetStrategy existingTargetStrategy)
        {
            java.io.File file = new java.io.File(directory, name); if (fs.fileExists(file))
            {
                switch (existingTargetStrategy)
                {
                case FAIL:
                case OVERWRITE: fs.deleteFile(file); return(file);

                case SKIP: return(null);

                default: throw new IllegalStateException(existingTargetStrategy.name());
                }
            }
            return(file);
        }
コード例 #10
0
        public virtual void Delete()
        {
            if (!_closed)
            {
                try
                {
                    CloseChannel();
                }
                catch (IOException e)
                {
                    throw new UnderlyingStorageException("Unable to close id file " + _file, e);
                }
            }

            if (!_fs.deleteFile(_file))
            {
                throw new UnderlyingStorageException("Unable to delete id file " + _file);
            }
        }