예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseWithCustomTransactionLogsLocation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseWithCustomTransactionLogsLocation()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(_serverStorePath, true, backupPort, "customLogLocation");

            try
            {
                CreateInitialDataSet(db);

                OnlineBackup backup      = OnlineBackup.From("127.0.0.1", backupPort);
                string       backupStore = _backupDatabasePath.Path;
                LogFiles     logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(backupStore), _fileSystemRule.get()).build();

                backup.Full(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                DbRepresentation representation = AddLotsOfData(db);
                backup.Incremental(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                assertEquals(representation, DbRepresentation);
            }
            finally
            {
                Db.shutdown();
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void restoreTransactionLogsInCustomDirectoryForTargetDatabaseWhenConfigured() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RestoreTransactionLogsInCustomDirectoryForTargetDatabaseWhenConfigured()
        {
            string databaseName                  = "to";
            Config config                        = ConfigWith(databaseName, Directory.absolutePath().AbsolutePath);
            File   customTxLogDirectory          = Directory.directory("customLogicalLog");
            string customTransactionLogDirectory = customTxLogDirectory.AbsolutePath;

            config.AugmentDefaults(GraphDatabaseSettings.logical_logs_location, customTransactionLogDirectory);

            File fromPath      = new File(Directory.absolutePath(), "from");
            File toPath        = config.Get(GraphDatabaseSettings.database_path);
            int  fromNodeCount = 10;
            int  toNodeCount   = 20;

            CreateDbAt(fromPath, fromNodeCount);

            GraphDatabaseService db = CreateDatabase(toPath, customTransactionLogDirectory);

            CreateTestData(toNodeCount, db);
            Db.shutdown();

            // when
            (new RestoreDatabaseCommand(FileSystemRule.get(), fromPath, config, databaseName, true)).execute();

            LogFiles fromStoreLogFiles         = LogFilesBuilder.logFilesBasedOnlyBuilder(fromPath, FileSystemRule.get()).build();
            LogFiles toStoreLogFiles           = LogFilesBuilder.logFilesBasedOnlyBuilder(toPath, FileSystemRule.get()).build();
            LogFiles customLogLocationLogFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(customTxLogDirectory, FileSystemRule.get()).build();

            assertThat(toStoreLogFiles.LogFilesConflict(), emptyArray());
            assertThat(customLogLocationLogFiles.LogFilesConflict(), arrayWithSize(1));
            assertEquals(fromStoreLogFiles.GetLogFileForVersion(0).length(), customLogLocationLogFiles.GetLogFileForVersion(0).length());
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void deleteLogs(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        private static void DeleteLogs(DatabaseLayout databaseLayout)
        {
            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fileSystem).build();
                foreach (File file in logFiles.LogFilesConflict())
                {
                    fileSystem.DeleteFile(file);
                }
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void deleteAllLogsOn(java.io.File storeDirectory) throws java.io.IOException
        private static void DeleteAllLogsOn(File storeDirectory)
        {
            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirectory, fileSystem).build();
                foreach (File file in logFiles.LogFilesConflict())
                {
                    fileSystem.DeleteFile(file);
                }
            }
        }
 /// <summary>
 /// Add all available log files as sources.
 /// </summary>
 /// <param name="sources"> destination of the sources. </param>
 private void GetTransactionLogFiles(IList <DiagnosticsReportSource> sources)
 {
     try
     {
         LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseLayout.databaseDirectory(), _fs).build();
         foreach (File file in logFiles.LogFilesConflict())
         {
             sources.Add(DiagnosticsReportSources.NewDiagnosticsFile("tx/" + file.Name, _fs, file));
         }
     }
     catch (IOException e)
     {
         sources.Add(DiagnosticsReportSources.NewDiagnosticsString("tx.txt", () => "Error getting tx logs: " + e.Message));
     }
 }
예제 #6
0
 private int CountTransactionLogs(LogFiles logFiles)
 {
     return(logFiles.LogFilesConflict().Length);
 }