Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recoverFirstCorruptedTransactionAfterCheckpointInLastLogFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RecoverFirstCorruptedTransactionAfterCheckpointInLastLogFile()
        {
            GraphDatabaseAPI database = ( GraphDatabaseAPI )_databaseFactory.newEmbeddedDatabase(_storeDir);

            GenerateTransactionsAndRotate(database, 5);
            database.Shutdown();

            File highestLogFile     = _logFiles.HighestLogFile;
            long originalFileLength = highestLogFile.length();

            AddCorruptedCommandsToLastLogFile();
            long modifiedFileLength = highestLogFile.length();

            assertThat(modifiedFileLength, greaterThan(originalFileLength));

            database = StartDbNoRecoveryOfCorruptedLogs();
            database.Shutdown();

            _logProvider.rawMessageMatcher().assertContains("Fail to read transaction log version 5.");
            _logProvider.rawMessageMatcher().assertContains("Fail to read first transaction of log version 5.");
            _logProvider.rawMessageMatcher().assertContains("Recovery required from position LogPosition{logVersion=5, byteOffset=593}");
            _logProvider.rawMessageMatcher().assertContains("Fail to recover all transactions. " + "Any later transactions after position LogPosition{logVersion=5, byteOffset=593} " + "are unreadable and will be truncated.");

            assertEquals(5, _logFiles.HighestLogVersion);
            ObjectLongMap <Type> logEntriesDistribution = GetLogEntriesDistribution(_logFiles);

            assertEquals(1, logEntriesDistribution.get(typeof(CheckPoint)));
            assertEquals(originalFileLength, highestLogFile.length());
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recoverFirstCorruptedTransactionSingleFileNoCheckpoint() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RecoverFirstCorruptedTransactionSingleFileNoCheckpoint()
        {
            AddCorruptedCommandsToLastLogFile();

            GraphDatabaseService recoveredDatabase = StartDbNoRecoveryOfCorruptedLogs();

            recoveredDatabase.Shutdown();

            _logProvider.rawMessageMatcher().assertContains("Fail to read transaction log version 0.");
            _logProvider.rawMessageMatcher().assertContains("Fail to read first transaction of log version 0.");
            _logProvider.rawMessageMatcher().assertContains("Recovery required from position LogPosition{logVersion=0, byteOffset=16}");
            _logProvider.rawMessageMatcher().assertContains("Fail to recover all transactions. Any later transactions after" + " position LogPosition{logVersion=0, byteOffset=16} are unreadable and will be truncated.");

            assertEquals(0, _logFiles.HighestLogVersion);
            ObjectLongMap <Type> logEntriesDistribution = GetLogEntriesDistribution(_logFiles);

            assertEquals(1, logEntriesDistribution.size());
            assertEquals(1, logEntriesDistribution.get(typeof(CheckPoint)));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recoverNotAFirstCorruptedTransactionMultipleFilesNoCheckpoints() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RecoverNotAFirstCorruptedTransactionMultipleFilesNoCheckpoints()
        {
            GraphDatabaseAPI   database           = ( GraphDatabaseAPI )_databaseFactory.newEmbeddedDatabase(_storeDir);
            TransactionIdStore transactionIdStore = GetTransactionIdStore(database);
            long lastClosedTransactionBeforeStart = transactionIdStore.LastClosedTransactionId;

            GenerateTransactionsAndRotate(database, 3);
            for (int i = 0; i < 7; i++)
            {
                GenerateTransaction(database);
            }
            long numberOfTransactions = transactionIdStore.LastClosedTransactionId - lastClosedTransactionBeforeStart;

            database.Shutdown();

            LogFiles logFiles           = BuildDefaultLogFiles();
            File     highestLogFile     = logFiles.HighestLogFile;
            long     originalFileLength = highestLogFile.length();

            RemoveLastCheckpointRecordFromLastLogFile();

            AddCorruptedCommandsToLastLogFile();
            long modifiedFileLength = highestLogFile.length();

            assertThat(modifiedFileLength, greaterThan(originalFileLength));

            database = StartDbNoRecoveryOfCorruptedLogs();
            database.Shutdown();

            _logProvider.rawMessageMatcher().assertContains("Fail to read transaction log version 3.");
            _logProvider.rawMessageMatcher().assertContains("Recovery required from position LogPosition{logVersion=0, byteOffset=16}");
            _logProvider.rawMessageMatcher().assertContains("Fail to recover all transactions.");
            _logProvider.rawMessageMatcher().assertContains("Any later transaction after LogPosition{logVersion=3, byteOffset=4632} are unreadable and will be truncated.");

            assertEquals(3, logFiles.HighestLogVersion);
            ObjectLongMap <Type> logEntriesDistribution = GetLogEntriesDistribution(logFiles);

            assertEquals(1, logEntriesDistribution.get(typeof(CheckPoint)));
            assertEquals(numberOfTransactions, _recoveryMonitor.NumberOfRecoveredTransactions);
            assertEquals(originalFileLength, highestLogFile.length());
        }