Beispiel #1
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());
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseTransactionLogsStoredWithDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseTransactionLogsStoredWithDatabase()
        {
            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);
            string ip   = ":" + backupPort;
            string name = "backupWithTxLogs" + RecordFormat;

            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", ip, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + name));
            _db.shutdown();

            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(_backupDir, name), fileSystem).build();
                assertTrue(logFiles.VersionExists(0));
                assertThat(logFiles.GetLogFileForVersion(0).length(), greaterThan(50L));
            }
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void extractTransactionFromLogFilesSkippingLastLogFileWithoutHeader() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExtractTransactionFromLogFilesSkippingLastLogFileWithoutHeader()
        {
            TransactionIdStore       transactionIdStore = new SimpleTransactionIdStore();
            TransactionMetadataCache positionCache      = new TransactionMetadataCache();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5};
            sbyte[]     additionalHeader             = new sbyte[] { 1, 2, 5 };
            const int   masterId                     = 2;
            int         authorId                     = 1;
            const long  timeStarted                  = 12345;
            long        latestCommittedTxWhenStarted = 4545;
            long        timeCommitted                = timeStarted + 10;
            LifeSupport life = new LifeSupport();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.builder(dir.databaseLayout(), fileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(LogVersionRepository.class)).build();
            LogFiles logFiles = LogFilesBuilder.builder(Dir.databaseLayout(), FileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(typeof(LogVersionRepository))).build();

            life.Add(logFiles);
            life.Start();
            try
            {
                AddATransactionAndRewind(life, logFiles, positionCache, transactionIdStore, additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted);
            }
            finally
            {
                life.Shutdown();
            }

            // create empty transaction log file and clear transaction cache to force re-read
            FileSystemRule.get().create(logFiles.GetLogFileForVersion(logFiles.HighestLogVersion + 1)).close();
            positionCache.Clear();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogicalTransactionStore store = new PhysicalLogicalTransactionStore(logFiles, positionCache, new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>(), monitors, true);
            LogicalTransactionStore store = new PhysicalLogicalTransactionStore(logFiles, positionCache, new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(), _monitors, true);

            VerifyTransaction(transactionIdStore, positionCache, additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, store);
        }