Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static java.io.File clean(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File dir) throws java.io.IOException
        private static File Clean(FileSystemAbstraction fs, File dir)
        {
            if (fs.FileExists(dir))
            {
                fs.DeleteRecursively(dir);
            }
            fs.Mkdirs(dir);
            return(dir);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void prepareSampleDatabase(String version, org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout, java.io.File databaseDirectory) throws java.io.IOException
        protected internal override void PrepareSampleDatabase(string version, FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout, File databaseDirectory)
        {
            File resourceDirectory = FindFormatStoreDirectoryForVersion(version, databaseDirectory);
            File directory         = databaseLayout.DatabaseDirectory();

            fileSystem.DeleteRecursively(directory);
            fileSystem.Mkdirs(directory);
            fileSystem.CopyRecursively(resourceDirectory, directory);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "Migrate: {0}->{1}") public static Iterable<Object[]> data() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public static IEnumerable <object[]> Data()
        {
            FileSystemAbstraction fs            = _fileSystemRule.get();
            PageCache             pageCache     = _pageCacheRule.getPageCache(fs);
            TestDirectory         testDirectory = TestDirectory.testDirectory();

            testDirectory.PrepareDirectory(typeof(StoreMigrationIT), "migration");
            DatabaseLayout    databaseLayout    = testDirectory.DatabaseLayout();
            StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache);
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles             logFiles      = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fs).withLogEntryReader(logEntryReader).build();
            LogTailScanner       tailScanner   = new LogTailScanner(logFiles, logEntryReader, new Monitors());
            IList <object[]>     data          = new List <object[]>();
            List <RecordFormats> recordFormats = new List <RecordFormats>();

            RecordFormatSelector.allFormats().forEach(f => addIfNotThere(f, recordFormats));
            foreach (RecordFormats toFormat in recordFormats)
            {
                UpgradableDatabase upgradableDatabase = new UpgradableDatabase(storeVersionCheck, toFormat, tailScanner);
                foreach (RecordFormats fromFormat in recordFormats)
                {
                    try
                    {
                        CreateDb(fromFormat, databaseLayout.DatabaseDirectory());
                        if (!upgradableDatabase.HasCurrentVersion(databaseLayout))
                        {
                            upgradableDatabase.CheckUpgradable(databaseLayout);
                            data.Add(new object[] { fromFormat, toFormat });
                        }
                    }
                    catch (Exception)
                    {
                        //This means that the combination is not migratable.
                    }
                    fs.DeleteRecursively(databaseLayout.DatabaseDirectory());
                }
            }

            return(data);
        }
Beispiel #4
0
        /// <summary>
        /// Deletes index folder with the specific indexId, but has the option to first archive the index if it exists.
        /// The zip archive will be placed next to the root directory for that index with a timestamp included in its name.
        /// </summary>
        /// <param name="fs"> <seealso cref="FileSystemAbstraction"/> this index lives in. </param>
        /// <param name="directoryStructure"> <seealso cref="IndexDirectoryStructure"/> knowing the directory structure for the provider owning the index. </param>
        /// <param name="indexId"> id of the index. </param>
        /// <param name="archiveIfExists"> whether or not to archive the index before deleting it, if it exists. </param>
        /// <returns> whether or not an archive was created. </returns>
        /// <exception cref="IOException"> on I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static boolean deleteIndex(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.kernel.api.index.IndexDirectoryStructure directoryStructure, long indexId, boolean archiveIfExists) throws java.io.IOException
        public static bool DeleteIndex(FileSystemAbstraction fs, IndexDirectoryStructure directoryStructure, long indexId, bool archiveIfExists)
        {
            File rootIndexDirectory = directoryStructure.DirectoryForIndex(indexId);

            if (archiveIfExists && fs.IsDirectory(rootIndexDirectory) && fs.FileExists(rootIndexDirectory) && fs.ListFiles(rootIndexDirectory).Length > 0)
            {
                ZipUtils.zip(fs, rootIndexDirectory, new File(rootIndexDirectory.Parent, "archive-" + rootIndexDirectory.Name + "-" + DateTimeHelper.CurrentUnixTimeMillis() + ".zip"));
                return(true);
            }
            int attempt = 0;

            while (attempt < 5)
            {
                attempt++;
                try
                {
                    fs.DeleteRecursively(rootIndexDirectory);
                    break;
                }
                catch (Exception concurrentModificationException) when(concurrentModificationException is DirectoryNotEmptyException || concurrentModificationException is NoSuchFileException)
                {
                    // Looks like someone was poking around in our directory while we where deleting.
                    // Let's sleep for a bit and try again.
                    try
                    {
                        Thread.Sleep(100);
                    }
                    catch (InterruptedException)
                    {
                        // Let's abandon this attempt to clean up.
                        Thread.CurrentThread.Interrupt();
                        break;
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void deleteIndexFolder(java.io.File databaseDir, org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException
        private void DeleteIndexFolder(File databaseDir, FileSystemAbstraction fs)
        {
            fs.DeleteRecursively(IndexDirectoryStructure.baseSchemaIndexFolder(databaseDir));
        }