コード例 #1
0
        public override SegmentedRaftLog CreateRaftLog(FileSystemAbstraction fsa, File dir)
        {
            long                   rotateAtSize    = ByteUnit.mebiBytes(8);
            LogProvider            logProvider     = Instance;
            int                    readerPoolSize  = 8;
            CoreLogPruningStrategy pruningStrategy = (new CoreLogPruningStrategyFactory(raft_log_pruning_strategy.DefaultValue, logProvider)).newInstance();

            return(new SegmentedRaftLog(fsa, dir, rotateAtSize, new DummyRaftableContentSerializer(), logProvider, readerPoolSize, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void buildDefaultContext() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BuildDefaultContext()
        {
            TransactionLogFilesContext context = builder(TestDirectory.databaseLayout(), _fileSystem).withLogVersionRepository(new SimpleLogVersionRepository(2)).withTransactionIdStore(new SimpleTransactionIdStore()).buildContext();

            assertEquals(_fileSystem, context.FileSystem);
            assertNotNull(context.LogEntryReader);
            assertSame(LogFileCreationMonitor_Fields.NoMonitor, context.LogFileCreationMonitor);
            assertEquals(ByteUnit.mebiBytes(250), context.RotationThreshold.get());
            assertEquals(1, context.LastCommittedTransactionId);
            assertEquals(2, context.LogVersionRepository.CurrentLogVersion);
        }
コード例 #3
0
        private static string MmapSize(int numberOfRecords, int recordSize)
        {
            int  bytes    = numberOfRecords * recordSize;
            long mebiByte = ByteUnit.mebiBytes(1);

            if (bytes < mebiByte)
            {
                throw new System.ArgumentException("too few records: " + numberOfRecords);
            }
            return(bytes / mebiByte + "M");
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void buildDefaultContextWithDependencies() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BuildDefaultContextWithDependencies()
        {
            SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository(2);
            SimpleTransactionIdStore   transactionIdStore   = new SimpleTransactionIdStore();
            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(logVersionRepository);
            dependencies.SatisfyDependency(transactionIdStore);

            TransactionLogFilesContext context = builder(TestDirectory.databaseLayout(), _fileSystem).withDependencies(dependencies).buildContext();

            assertEquals(_fileSystem, context.FileSystem);
            assertNotNull(context.LogEntryReader);
            assertSame(LogFileCreationMonitor_Fields.NoMonitor, context.LogFileCreationMonitor);
            assertEquals(ByteUnit.mebiBytes(250), context.RotationThreshold.get());
            assertEquals(1, context.LastCommittedTransactionId);
            assertEquals(2, context.LogVersionRepository.CurrentLogVersion);
        }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void backupCorruptedContent(long recoveredTransactionLogVersion, long recoveredTransactionOffset) throws java.io.IOException
        private void BackupCorruptedContent(long recoveredTransactionLogVersion, long recoveredTransactionOffset)
        {
            File corruptedLogArchive = GetArchiveFile(recoveredTransactionLogVersion, recoveredTransactionOffset);

            using (ZipOutputStream recoveryContent = new ZipOutputStream(new BufferedOutputStream(_fs.openAsOutputStream(corruptedLogArchive, false))))
            {
                ByteBuffer zipBuffer = ByteBuffer.allocate(( int )ByteUnit.mebiBytes(1));
                CopyTransactionLogContent(recoveredTransactionLogVersion, recoveredTransactionOffset, recoveryContent, zipBuffer);
                ForEachSubsequentLogFile(recoveredTransactionLogVersion, fileIndex =>
                {
                    try
                    {
                        CopyTransactionLogContent(fileIndex, 0, recoveryContent, zipBuffer);
                    }
                    catch (IOException io)
                    {
                        throw new UncheckedIOException(io);
                    }
                });
            }
        }