//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: @Test void countPageFaultsAndBytesRead() internal virtual void CountPageFaultsAndBytesRead() { PinEvent pinEvent = _pageCursorTracer.beginPin(true, 0, _swapper); { PageFaultEvent pageFaultEvent = pinEvent.BeginPageFault(); { pageFaultEvent.AddBytesRead(42); } pageFaultEvent.Done(); pageFaultEvent = pinEvent.BeginPageFault(); { pageFaultEvent.AddBytesRead(42); } pageFaultEvent.Done(); } pinEvent.Done(); assertEquals(1, _pageCursorTracer.pins()); assertEquals(1, _pageCursorTracer.unpins()); assertEquals(2, _pageCursorTracer.faults()); assertEquals(84, _pageCursorTracer.bytesRead()); }
private void GenerateEventSet() { PinEvent pinEvent = _pageCursorTracer.beginPin(false, 0, _swapper); { PageFaultEvent pageFaultEvent = pinEvent.BeginPageFault(); pageFaultEvent.AddBytesRead(150); { EvictionEvent evictionEvent = pageFaultEvent.BeginEviction(); { FlushEventOpportunity flushEventOpportunity = evictionEvent.FlushEventOpportunity(); FlushEvent flushEvent = flushEventOpportunity.BeginFlush(0, 0, _swapper); flushEvent.AddBytesWritten(10); flushEvent.Done(); } evictionEvent.ThrewException(new IOException("eviction exception")); evictionEvent.Close(); } pageFaultEvent.Done(); } pinEvent.Done(); }