//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void fault(long pageRef, org.neo4j.io.pagecache.PageSwapper swapper, int swapperId, long filePageId, org.neo4j.io.pagecache.tracing.PageFaultEvent event) throws java.io.IOException internal virtual void Fault(long pageRef, PageSwapper swapper, int swapperId, long filePageId, PageFaultEvent @event) { if (swapper == null) { throw SwapperCannotBeNull(); } int currentSwapper = GetSwapperId(pageRef); long currentFilePageId = GetFilePageId(pageRef); if (filePageId == PageCursor.UNBOUND_PAGE_ID || !IsExclusivelyLocked(pageRef) || currentSwapper != 0 || currentFilePageId != PageCursor.UNBOUND_PAGE_ID) { throw CannotFaultException(pageRef, swapper, swapperId, filePageId, currentSwapper, currentFilePageId); } // Note: It is important that we assign the filePageId before we swap // the page in. If the swapping fails, the page will be considered // loaded for the purpose of eviction, and will eventually return to // the freelist. However, because we don't assign the swapper until the // swapping-in has succeeded, the page will not be considered bound to // the file page, so any subsequent thread that finds the page in their // translation table will re-do the page fault. SetFilePageId(pageRef, filePageId); // Page now considered isLoaded() long bytesRead = swapper.Read(filePageId, GetAddress(pageRef), _cachePageSize); @event.AddBytesRead(bytesRead); @event.CachePageId = ToId(pageRef); SetSwapperId(pageRef, swapperId); // Page now considered isBoundTo( swapper, filePageId ) }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) void mustHandleMischiefInPositionedVectoredRead(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustHandleMischiefInPositionedVectoredRead(int noChannelStriping) { int bytesTotal = 512; int bytesPerPage = 32; int pageCount = bytesTotal / bytesPerPage; sbyte[] data = new sbyte[bytesTotal]; ThreadLocalRandom.current().NextBytes(data); PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(Fs, Configuration.EMPTY); File file = File; PageSwapper swapper = CreateSwapper(factory, file, bytesTotal, NoCallback, true, Bool(noChannelStriping)); try { long page = CreatePage(data); swapper.Write(0, page); } finally { swapper.Close(); } RandomAdversary adversary = new RandomAdversary(0.5, 0.0, 0.0); factory.Open(new AdversarialFileSystemAbstraction(adversary, Fs), Configuration.EMPTY); swapper = CreateSwapper(factory, file, bytesPerPage, NoCallback, false, Bool(noChannelStriping)); long[] pages = new long[pageCount]; for (int i = 0; i < pageCount; i++) { pages[i] = CreatePage(bytesPerPage); } sbyte[] temp = new sbyte[bytesPerPage]; try { for (int i = 0; i < 10_000; i++) { foreach (long page in pages) { Clear(page); } assertThat(swapper.Read(0, pages, bytesPerPage, 0, pages.Length), @is(( long )bytesTotal)); for (int j = 0; j < pageCount; j++) { Array.Copy(data, j * bytesPerPage, temp, 0, bytesPerPage); assertThat(Array(pages[j]), @is(temp)); } } } finally { swapper.Close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) void mustHandleMischiefInPositionedVectoredWrite(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustHandleMischiefInPositionedVectoredWrite(int noChannelStriping) { int bytesTotal = 512; int bytesPerPage = 32; int pageCount = bytesTotal / bytesPerPage; sbyte[] data = new sbyte[bytesTotal]; ThreadLocalRandom.current().NextBytes(data); long zeroPage = CreatePage(bytesPerPage); Clear(zeroPage); File file = File; PageSwapperFactory factory = CreateSwapperFactory(); RandomAdversary adversary = new RandomAdversary(0.5, 0.0, 0.0); factory.Open(new AdversarialFileSystemAbstraction(adversary, Fs), Configuration.EMPTY); PageSwapper swapper = CreateSwapper(factory, file, bytesPerPage, NoCallback, true, Bool(noChannelStriping)); long[] writePages = new long[pageCount]; long[] readPages = new long[pageCount]; long[] zeroPages = new long[pageCount]; for (int i = 0; i < pageCount; i++) { writePages[i] = CreatePage(bytesPerPage); PutBytes(writePages[i], data, 0, i * bytesPerPage, bytesPerPage); readPages[i] = CreatePage(bytesPerPage); zeroPages[i] = zeroPage; } try { for (int i = 0; i < 10_000; i++) { adversary.ProbabilityFactor = 0; swapper.Write(0, zeroPages, 0, pageCount); adversary.ProbabilityFactor = 1; swapper.Write(0, writePages, 0, pageCount); foreach (long readPage in readPages) { Clear(readPage); } adversary.ProbabilityFactor = 0; assertThat(swapper.Read(0, readPages, bytesPerPage, 0, pageCount), @is(( long )bytesTotal)); for (int j = 0; j < pageCount; j++) { assertThat(Array(readPages[j]), @is(Array(writePages[j]))); } } } finally { swapper.Close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) void mustZeroFillPageBeyondEndOfFile(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustZeroFillPageBeyondEndOfFile(int noChannelStriping) { sbyte[] bytes = new sbyte[] { 1, 2, 3, 4, 5, 6 }; StoreChannel channel = Fs.create(File); channel.WriteAll(Wrap(bytes)); channel.close(); PageSwapperFactory factory = CreateSwapperFactory(); PageSwapper swapper = CreateSwapper(factory, File, 4, null, false, Bool(noChannelStriping)); long target = CreatePage(4); swapper.Read(1, target, SizeOfAsInt(target)); assertThat(Array(target), byteArray(new sbyte[] { 5, 6, 0, 0 })); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) void swappingInMustFillPageWithData(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void SwappingInMustFillPageWithData(int noChannelStriping) { sbyte[] bytes = new sbyte[] { 1, 2, 3, 4 }; StoreChannel channel = Fs.create(File); channel.WriteAll(Wrap(bytes)); channel.close(); PageSwapperFactory factory = CreateSwapperFactory(); PageSwapper swapper = CreateSwapper(factory, File, 4, null, false, Bool(noChannelStriping)); long target = CreatePage(4); swapper.Read(0, target, SizeOfAsInt(target)); assertThat(Array(target), byteArray(bytes)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) void mustHandleMischiefInPositionedRead(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustHandleMischiefInPositionedRead(int noChannelStriping) { int bytesTotal = 512; sbyte[] data = new sbyte[bytesTotal]; ThreadLocalRandom.current().NextBytes(data); PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(Fs, Configuration.EMPTY); File file = File; PageSwapper swapper = CreateSwapper(factory, file, bytesTotal, NoCallback, true, Bool(noChannelStriping)); try { long page = CreatePage(data); swapper.Write(0, page); } finally { swapper.Close(); } RandomAdversary adversary = new RandomAdversary(0.5, 0.0, 0.0); factory.Open(new AdversarialFileSystemAbstraction(adversary, Fs), Configuration.EMPTY); swapper = CreateSwapper(factory, file, bytesTotal, NoCallback, false, Bool(noChannelStriping)); long page = CreatePage(bytesTotal); try { for (int i = 0; i < 10_000; i++) { Clear(page); assertThat(swapper.Read(0, page, SizeOfAsInt(page)), @is(( long )bytesTotal)); assertThat(Array(page), @is(data)); } } finally { swapper.Close(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long read(long filePageId, long bufferAddress, int bufferSize) throws java.io.IOException public override long Read(long filePageId, long bufferAddress, int bufferSize) { return(@delegate.Read(filePageId, bufferAddress, bufferSize)); }