//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleGroupCountBeyondSignedShortRange() public virtual void ShouldHandleGroupCountBeyondSignedShortRange() { // GIVEN long nodeId = 0; int limit = short.MaxValue + 10; RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(100), nodeId + 1); // WHEN first counting all groups per node for (int type = 0; type < limit; type++) { cache.IncrementGroupCount(nodeId); } // and WHEN later putting group records into the cache RelationshipGroupRecord group = new RelationshipGroupRecord(-1); group.OwningNode = nodeId; for (int type = 0; type < limit; type++) { group.Id = type; group.FirstOut = type; // just some relationship group.Type = type; cache.Put(group); } long prepared = cache.Prepare(nodeId); // THEN that should work, because it used to fail inside prepare, but we can also ask // the groupCount method to be sure assertEquals(nodeId, prepared); assertEquals(limit, cache.GroupCount(nodeId)); }
private static string BytesToString(long bytes) { if (_useRawReportingUnits) { return(bytes + "bytes"); } return(ByteUnit.bytesToString(bytes)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSortOutOfOrderTypes() public virtual void ShouldSortOutOfOrderTypes() { // GIVEN int nodeCount = 100; RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(40), nodeCount); int[] counts = new int[nodeCount]; int groupCount = 0; for (int nodeId = 0; nodeId < Counts.Length; nodeId++) { counts[nodeId] = Random.Next(10); SetCount(cache, nodeId, counts[nodeId]); groupCount += counts[nodeId]; } assertEquals(nodeCount, cache.Prepare(0)); bool thereAreMoreGroups = true; int cachedCount = 0; int[] types = ScrambledTypes(10); for (int i = 0; thereAreMoreGroups; i++) { int typeId = types[i]; thereAreMoreGroups = false; for (int nodeId = 0; nodeId < nodeCount; nodeId++) { if (counts[nodeId] > 0) { thereAreMoreGroups = true; if (cache.Put((new RelationshipGroupRecord(nodeId)).initialize(true, typeId, -1, -1, -1, nodeId, -1))) { cachedCount++; counts[nodeId]--; } } } } assertEquals(groupCount, cachedCount); // WHEN/THEN long currentNodeId = -1; int currentTypeId = -1; int readCount = 0; foreach (RelationshipGroupRecord group in cache) { assertTrue(group.OwningNode >= currentNodeId); if (group.OwningNode > currentNodeId) { currentNodeId = group.OwningNode; currentTypeId = -1; } assertTrue(group.Type > currentTypeId); readCount++; } assertEquals(cachedCount, readCount); }
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)); }
public override long PageCacheMemory() { string pageCacheMemory = Config.get(pagecache_memory); if (string.ReferenceEquals(pageCacheMemory, null)) { pageCacheMemory = ConfiguringPageCacheFactory.defaultHeuristicPageCacheMemory() + ""; } return(min(Configuration_Fields.MaxPageCacheMemory, ByteUnit.parse(pageCacheMemory))); }
//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); }
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"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPutGroupsOnlyWithinPreparedRange() public virtual void ShouldPutGroupsOnlyWithinPreparedRange() { // GIVEN int nodeCount = 1000; RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(4), nodeCount); int[] counts = new int[nodeCount]; for (int nodeId = 0; nodeId < Counts.Length; nodeId++) { counts[nodeId] = Random.Next(10); SetCount(cache, nodeId, counts[nodeId]); } long toNodeId = cache.Prepare(0); assertTrue(toNodeId < nodeCount); // WHEN bool thereAreMoreGroups = true; int cachedCount = 0; while (thereAreMoreGroups) { thereAreMoreGroups = false; for (int nodeId = 0; nodeId < nodeCount; nodeId++) { if (counts[nodeId] > 0) { thereAreMoreGroups = true; int typeId = counts[nodeId]--; if (cache.Put((new RelationshipGroupRecord(nodeId)).initialize(true, typeId, -1, -1, -1, nodeId, -1))) { cachedCount++; } } } } assertTrue(cachedCount >= toNodeId); // THEN the relationship groups we get back are only for those we prepared for int readCount = 0; foreach (RelationshipGroupRecord cachedGroup in cache) { assertTrue(cachedGroup.OwningNode >= 0 && cachedGroup.OwningNode < toNodeId); readCount++; } assertEquals(cachedCount, readCount); }
//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); }
//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); } }); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotFindSpaceToPutMoreGroupsThanSpecifiedForANode() public virtual void ShouldNotFindSpaceToPutMoreGroupsThanSpecifiedForANode() { // GIVEN int nodeCount = 10; RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(4), nodeCount); SetCount(cache, 1, 7); assertEquals(nodeCount, cache.Prepare(0)); // WHEN for (int i = 0; i < 7; i++) { cache.Put((new RelationshipGroupRecord(i + 1)).initialize(true, i, -1, -1, -1, 1, -1)); } try { cache.Put((new RelationshipGroupRecord(8)).initialize(true, 8, -1, -1, -1, 1, -1)); fail("Should have failed"); } catch (System.InvalidOperationException) { // Good } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _recordFormat = new PropertyRecordFormat(); _pageCursor = new StubPageCursor(0, ( int )ByteUnit.kibiBytes(8)); _idSequence = new ConstantIdSequence(); }
internal virtual void PrintProgress() { if (_output != null) { char lineSep = _interactive ? '\r' : '\n'; if (_done) { _output.println(lineSep + "Done: " + _currentFiles + " files, " + ByteUnit.bytesToString(_currentBytes) + " processed."); } else if (MaxFiles > 0 && MaxBytes > 0) { double progress = (_currentBytes / ( double )MaxBytes) * 100; _output.print(lineSep + "Files: " + _currentFiles + '/' + MaxFiles + ", data: " + string.Format("{0,4:F1}%", progress)); } else { _output.print(lineSep + "Files: " + _currentFiles + "/?" + ", data: ??.?%"); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _recordFormat = new NodeRecordFormat(); _pageCursor = new FixedLinkedStubPageCursor(0, ( int )ByteUnit.kibiBytes(8)); _idSequence = new ConstantIdSequence(); }