Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void appendNullTransactionLogEntryToSetRaftIndexToMinusOne() throws java.io.IOException
        private void AppendNullTransactionLogEntryToSetRaftIndexToMinusOne()
        {
            ReadOnlyTransactionIdStore readOnlyTransactionIdStore = new ReadOnlyTransactionIdStore(_pageCache, _databaseLayout);
            LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(_databaseLayout, _fs, _pageCache).withConfig(_config).withLastCommittedTransactionIdSupplier(() => readOnlyTransactionIdStore.LastClosedTransactionId - 1).build();

            long dummyTransactionId;

            using (Lifespan lifespan = new Lifespan(logFiles))
            {
                FlushableChannel     channel = logFiles.LogFile.Writer;
                TransactionLogWriter writer  = new TransactionLogWriter(new LogEntryWriter(channel));

                long lastCommittedTransactionId      = readOnlyTransactionIdStore.LastCommittedTransactionId;
                PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Collections.emptyList());
                sbyte[] txHeaderBytes = LogIndexTxHeaderEncoding.encodeLogIndexAsTxHeader(-1);
                tx.SetHeader(txHeaderBytes, -1, -1, -1, lastCommittedTransactionId, -1, -1);

                dummyTransactionId = lastCommittedTransactionId + 1;
                writer.Append(tx, dummyTransactionId);
                channel.PrepareForFlush().flush();
            }

            File neoStoreFile = _databaseLayout.metadataStore();

            MetaDataStore.setRecord(_pageCache, neoStoreFile, LAST_TRANSACTION_ID, dummyTransactionId);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void appendCorruptedTransaction() throws java.io.IOException
        private void AppendCorruptedTransaction()
        {
            FlushablePositionAwareChannel channel = _logFile.Writer;
            TransactionLogWriter          writer  = new TransactionLogWriter(new CorruptedLogEntryWriter(channel));

            writer.Append(Tx(_random.intBetween(100, 1000)), ++_txId);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeTransactions(int transactionCount, int minTransactionSize, int maxTransactionSize) throws java.io.IOException
        private void WriteTransactions(int transactionCount, int minTransactionSize, int maxTransactionSize)
        {
            FlushablePositionAwareChannel channel = _logFile.Writer;
            TransactionLogWriter          writer  = new TransactionLogWriter(new LogEntryWriter(channel));

            for (int i = 0; i < transactionCount; i++)
            {
                writer.Append(Tx(_random.intBetween(minTransactionSize, maxTransactionSize)), ++_txId);
            }
            channel.PrepareForFlush().flush();
            // Don't close the channel, LogFile owns it
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void addCorruptedCommandsToLastLogFile() throws java.io.IOException
        private void AddCorruptedCommandsToLastLogFile()
        {
            PositiveLogFilesBasedLogVersionRepository versionRepository = new PositiveLogFilesBasedLogVersionRepository(_logFiles);
            LogFiles internalLogFiles = LogFilesBuilder.builder(_directory.databaseLayout(), _fileSystemRule).withLogVersionRepository(versionRepository).withTransactionIdStore(new SimpleTransactionIdStore()).build();

            using (Lifespan lifespan = new Lifespan(internalLogFiles))
            {
                LogFile transactionLogFile = internalLogFiles.LogFile;

                FlushablePositionAwareChannel channel = transactionLogFile.Writer;
                TransactionLogWriter          writer  = new TransactionLogWriter(new CorruptedLogEntryWriter(channel));

                ICollection <StorageCommand> commands = new List <StorageCommand>();
                commands.Add(new Command.PropertyCommand(new PropertyRecord(1), new PropertyRecord(2)));
                commands.Add(new Command.NodeCommand(new NodeRecord(2), new NodeRecord(3)));
                PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(commands);
                writer.Append(transaction, 1000);
            }
        }