コード例 #1
0
//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);
        }
コード例 #2
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);
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void appendCheckpoint(org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles, org.neo4j.kernel.recovery.LogTailScanner tailScanner) throws java.io.IOException
        private static void AppendCheckpoint(LogFiles logFiles, LogTailScanner tailScanner)
        {
            using (Lifespan lifespan = new Lifespan(logFiles))
            {
                FlushablePositionAwareChannel writer = logFiles.LogFile.Writer;
                TransactionLogWriter          transactionLogWriter = new TransactionLogWriter(new LogEntryWriter(writer));
                transactionLogWriter.CheckPoint(tailScanner.TailInformation.lastCheckPoint.LogPosition);
                writer.PrepareForFlush().flush();
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _lastCommittedTxId    = new AtomicLong(BASE_TX_ID);
            _logVersionRepository = new SimpleLogVersionRepository();
            _logFiles             = LogFilesBuilder.builder(_directory.databaseLayout(), _fs).withLogVersionRepository(_logVersionRepository).withTransactionIdStore(new SimpleTransactionIdStore()).build();
            _life.add(_logFiles);
            _logFile = _logFiles.LogFile;
            _writer  = _logFile.Writer;
            _transactionLogWriter = new TransactionLogWriter(new LogEntryWriter(_writer));
            _monitor = new VerifyingMonitor();
        }
コード例 #5
0
//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
        }
コード例 #6
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);
            }
        }
コード例 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: TransactionLogCatchUpWriter(org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.kernel.configuration.Config config, org.neo4j.logging.LogProvider logProvider, long fromTxId, boolean asPartOfStoreCopy, boolean keepTxLogsInStoreDir, boolean forceTransactionRotations) throws java.io.IOException
        internal TransactionLogCatchUpWriter(DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, Config config, LogProvider logProvider, long fromTxId, bool asPartOfStoreCopy, bool keepTxLogsInStoreDir, bool forceTransactionRotations)
        {
            this._pageCache                  = pageCache;
            this._log                        = logProvider.getLog(this.GetType());
            this._asPartOfStoreCopy          = asPartOfStoreCopy;
            this._rotateTransactionsManually = forceTransactionRotations;
            RecordFormats recordFormats = RecordFormatSelector.selectForStoreOrConfig(Config.defaults(), databaseLayout, fs, pageCache, logProvider);

            this._stores = (new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, recordFormats, logProvider, EMPTY)).openNeoStores(META_DATA);
            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(_stores.MetaDataStore);
            LogFilesBuilder logFilesBuilder = LogFilesBuilder.builder(databaseLayout, fs).withDependencies(dependencies).withLastCommittedTransactionIdSupplier(() => fromTxId - 1).withConfig(CustomisedConfig(config, keepTxLogsInStoreDir, forceTransactionRotations)).withLogVersionRepository(_stores.MetaDataStore);

            this._logFiles = logFilesBuilder.Build();
            this._lifespan.add(_logFiles);
            this._writer         = new TransactionLogWriter(new LogEntryWriter(_logFiles.LogFile.Writer));
            this._databaseLayout = databaseLayout;
            this._expectedTxId   = fromTxId;
        }