//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void countFlushesAndBytesWritten()
        internal virtual void CountFlushesAndBytesWritten()
        {
            PinEvent pinEvent = _pageCursorTracer.beginPin(true, 0, _swapper);

            {
                PageFaultEvent faultEvent = pinEvent.BeginPageFault();
                {
                    EvictionEvent evictionEvent = faultEvent.BeginEviction();
                    {
                        FlushEventOpportunity flushEventOpportunity = evictionEvent.FlushEventOpportunity();
                        {
                            FlushEvent flushEvent = flushEventOpportunity.BeginFlush(0, 0, _swapper);
                            flushEvent.AddBytesWritten(27);
                            flushEvent.Done();
                            FlushEvent flushEvent1 = flushEventOpportunity.BeginFlush(0, 1, _swapper);
                            flushEvent1.AddBytesWritten(13);
                            flushEvent1.Done();
                        }
                    }
                    evictionEvent.Close();
                }
                faultEvent.Done();
            }
            pinEvent.Done();

            assertEquals(1, _pageCursorTracer.pins());
            assertEquals(1, _pageCursorTracer.unpins());
            assertEquals(1, _pageCursorTracer.faults());
            assertEquals(1, _pageCursorTracer.evictions());
            assertEquals(2, _pageCursorTracer.flushes());
            assertEquals(40, _pageCursorTracer.bytesWritten());
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustCountEvictions()
        internal virtual void MustCountEvictions()
        {
            using (EvictionRunEvent evictionRunEvent = _tracer.beginPageEvictions(2))
            {
                using (EvictionEvent evictionEvent = evictionRunEvent.BeginEviction())
                {
                    FlushEvent flushEvent = evictionEvent.FlushEventOpportunity().beginFlush(0, 0, _swapper);
                    flushEvent.AddBytesWritten(12);
                    flushEvent.Done();
                }

                using (EvictionEvent evictionEvent = evictionRunEvent.BeginEviction())
                {
                    FlushEvent flushEvent = evictionEvent.FlushEventOpportunity().beginFlush(0, 0, _swapper);
                    flushEvent.AddBytesWritten(12);
                    flushEvent.Done();
                    evictionEvent.ThrewException(new IOException());
                }

                using (EvictionEvent evictionEvent = evictionRunEvent.BeginEviction())
                {
                    FlushEvent flushEvent = evictionEvent.FlushEventOpportunity().beginFlush(0, 0, _swapper);
                    flushEvent.AddBytesWritten(12);
                    flushEvent.Done();
                    evictionEvent.ThrewException(new IOException());
                }

                evictionRunEvent.BeginEviction().close();
            }

            AssertCounts(0, 0, 0, 0, 4, 2, 3, 0, 36, 0, 0, 0d);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void evict(long pageRef, org.neo4j.io.pagecache.tracing.EvictionEvent evictionEvent) throws java.io.IOException
        private void Evict(long pageRef, EvictionEvent evictionEvent)
        {
            long filePageId = GetFilePageId(pageRef);

            evictionEvent.FilePageId  = filePageId;
            evictionEvent.CachePageId = pageRef;
            int swapperId = GetSwapperId(pageRef);

            if (swapperId != 0)
            {
                // If the swapper id is non-zero, then the page was not only loaded, but also bound, and possibly modified.
                SwapperSet.SwapperMapping swapperMapping = _swappers.getAllocation(swapperId);
                if (swapperMapping != null)
                {
                    // The allocation can be null if the file has been unmapped, but there are still pages
                    // lingering in the cache that were bound to file page in that file.
                    PageSwapper swapper = swapperMapping.Swapper;
                    evictionEvent.Swapper = swapper;

                    if (IsModified(pageRef))
                    {
                        FlushModifiedPage(pageRef, evictionEvent, filePageId, swapper);
                    }
                    swapper.Evicted(filePageId);
                }
            }
            ClearBinding(pageRef);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: boolean tryEvict(long pageRef, org.neo4j.io.pagecache.tracing.EvictionEventOpportunity evictionOpportunity) throws java.io.IOException
        internal virtual bool TryEvict(long pageRef, EvictionEventOpportunity evictionOpportunity)
        {
            if (TryExclusiveLock(pageRef))
            {
                if (IsLoaded(pageRef))
                {
                    using (EvictionEvent evictionEvent = evictionOpportunity.BeginEviction())
                    {
                        Evict(pageRef, evictionEvent);
                        return(true);
                    }
                }
                UnlockExclusive(pageRef);
            }
            return(false);
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void flushModifiedPage(long pageRef, org.neo4j.io.pagecache.tracing.EvictionEvent evictionEvent, long filePageId, org.neo4j.io.pagecache.PageSwapper swapper) throws java.io.IOException
        private void FlushModifiedPage(long pageRef, EvictionEvent evictionEvent, long filePageId, PageSwapper swapper)
        {
            FlushEvent flushEvent = evictionEvent.FlushEventOpportunity().beginFlush(filePageId, pageRef, swapper);

            try
            {
                long address      = GetAddress(pageRef);
                long bytesWritten = swapper.Write(filePageId, address);
                ExplicitlyMarkPageUnmodifiedUnderExclusiveLock(pageRef);
                flushEvent.AddBytesWritten(bytesWritten);
                flushEvent.AddPagesFlushed(1);
                flushEvent.Done();
            }
            catch (IOException e)
            {
                UnlockExclusive(pageRef);
                flushEvent.Done(e);
                evictionEvent.ThrewException(e);
                throw e;
            }
        }
        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();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void countPageEvictions()
        internal virtual void CountPageEvictions()
        {
            PinEvent pinEvent = _pageCursorTracer.beginPin(true, 0, _swapper);

            {
                PageFaultEvent faultEvent = pinEvent.BeginPageFault();
                {
                    EvictionEvent evictionEvent = faultEvent.BeginEviction();
                    evictionEvent.FilePageId  = 0;
                    evictionEvent.CachePageId = 0;
                    evictionEvent.ThrewException(new IOException("exception"));
                    evictionEvent.Close();
                }
                faultEvent.Done();
            }
            pinEvent.Done();

            assertEquals(1, _pageCursorTracer.pins());
            assertEquals(1, _pageCursorTracer.unpins());
            assertEquals(1, _pageCursorTracer.faults());
            assertEquals(1, _pageCursorTracer.evictions());
            assertEquals(1, _pageCursorTracer.evictionExceptions());
        }