Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustFlushDirtyPagesOnEvictingAllPages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void MustFlushDirtyPagesOnEvictingAllPages()
        {
            WriteInitialDataTo(file("a"));
            RecordingPageCacheTracer  tracer       = new RecordingPageCacheTracer();
            RecordingPageCursorTracer cursorTracer = new RecordingPageCursorTracer(typeof(RecordingPageCursorTracer.Fault));
            ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer> cursorTracerSupplier = new ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer>(cursorTracer);

            using (MuninnPageCache pageCache = createPageCache(fs, 4, BlockCacheFlush(tracer), cursorTracerSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(0L);
                    assertTrue(cursor.Next());
                    cursor.PutLong(0L);
                    assertFalse(cursor.Next());
                }
                cursorTracer.ReportEvents();
                assertNotNull(cursorTracer.Observe(typeof(RecordingPageCursorTracer.Fault)));
                assertNotNull(cursorTracer.Observe(typeof(RecordingPageCursorTracer.Fault)));
                assertEquals(2, cursorTracer.Faults());
                assertEquals(2, tracer.Faults());

                long clockArm = pageCache.EvictPages(2, 0, tracer.BeginPageEvictions(2));
                assertThat(clockArm, @is(2L));
                assertNotNull(tracer.Observe(typeof(Evict)));
                assertNotNull(tracer.Observe(typeof(Evict)));

                ByteBuffer buf = ReadIntoBuffer("a");
                assertThat(buf.Long, @is(0L));
                assertThat(buf.Long, @is(0L));
            }
        }
Beispiel #2
0
 internal static void PutPoint(PageCursor cursor, long long0, long long3, long[] long1Array, int long1ArrayOffset)
 {
     cursor.PutLong(long0);
     for (int i = 0; i < long3; i++)
     {
         cursor.PutLong(long1Array[long1ArrayOffset + i]);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Assume the given cursor is writable and has already been positioned at the record offset.
        /// </summary>
        public virtual long IncrementCounter(PageCursor cursor, int threadId)
        {
            int recordOffset   = cursor.Offset;
            int fieldOffset    = recordOffset + (_fieldSize * threadId);
            int checksumOffset = recordOffset + _checksumFieldOffset;

            long newValue = 1 + cursor.GetLong(fieldOffset);

            cursor.PutLong(fieldOffset, newValue);
            cursor.PutLong(checksumOffset, 1 + cursor.GetLong(checksumOffset));
            return(newValue);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void doNotMarkContextAsDirtyWhenAnyEvictedPageHaveModificationTransactionLowerThenReader() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void DoNotMarkContextAsDirtyWhenAnyEvictedPageHaveModificationTransactionLowerThenReader()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 15);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(3);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(3);
                }

                cursorContext.InitWrite(13);
                using (PageCursor cursor = pagedFile.Io(1, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(4);
                }

                EvictAllPages(pageCache);

                cursorContext.InitRead();
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    assertEquals(3, cursor.Long);
                    assertFalse(cursorContext.Dirty);
                }
            }
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void pageModificationTracksHighestModifierTransactionId() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PageModificationTracksHighestModifierTransactionId()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 0);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(1);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(1);
                }
                cursorContext.InitWrite(12);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(2);
                }
                cursorContext.InitWrite(7);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(3);
                }

                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    MuninnPageCursor pageCursor = ( MuninnPageCursor )cursor;
                    assertEquals(12, pageCursor.PagedFile.getLastModifiedTxId(pageCursor.PinnedPageRef));
                    assertEquals(3, cursor.Long);
                }
            }
        }
        public override void Write(Record record, PageCursor cursor)
        {
            StandardRecord r = ( StandardRecord )record;

            sbyte[] pathBytes = r.File.Path.getBytes(StandardCharsets.UTF_8);
            sbyte   fileByte  = pathBytes[pathBytes.Length - 1];

            cursor.PutByte(r.Type);
            cursor.PutByte(fileByte);
            cursor.PutShort(r.Fill1);
            cursor.PutInt(r.RecordId);
            cursor.PutLong(r.Fill2);
        }
Beispiel #7
0
 public override void Write(DynamicRecord record, PageCursor cursor, int recordSize)
 {
     if (record.InUse())
     {
         Debug.Assert(record.Length < (1 << 24) - 1);
         sbyte headerByte = ( sbyte )((record.InUse() ? IN_USE_BIT : 0) | (record.StartRecord ? START_RECORD_BIT : 0));
         cursor.PutByte(headerByte);
         cursor.PutShort(( short )record.Length);
         cursor.PutByte(( sbyte )(( int )(( uint )record.Length >> 16)));
         cursor.PutLong(record.NextBlock);
         cursor.PutBytes(record.Data);
     }
     else
     {
         MarkAsUnused(cursor);
     }
 }
Beispiel #8
0
        public override void SetLong(long index, int offset, long value)
        {
            long pageId = pageId(index);

            offset += offset(index);
            try
            {
                using (PageCursor cursor = PagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    cursor.Next();
                    cursor.PutLong(offset, value);
                    CheckBounds(cursor);
                }
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void closingTheCursorMustUnlockModifiedPage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ClosingTheCursorMustUnlockModifiedPage()
        {
            WriteInitialDataTo(file("a"));

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> task = executor.submit(() ->
                Future <object> task = executor.submit(() =>
                {
                    try
                    {
                        using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                        {
                            assertTrue(cursor.Next());
                            cursor.PutLong(41);
                        }
                    }
                    catch (IOException e)
                    {
                        throw new Exception(e);
                    }
                });
                task.get();

                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    long value = cursor.Long;
                    cursor.Offset = 0;
                    cursor.PutLong(value + 1);
                }

                long clockArm = pageCache.EvictPages(1, 0, EvictionRunEvent.NULL);
                assertThat(clockArm, @is(1L));

                ByteBuffer buf = ReadIntoBuffer("a");
                assertThat(buf.Long, @is(42L));
                assertThat(buf.Long, @is(_y));
            }
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void pageModificationTrackingNoticeWriteFromAnotherThread() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PageModificationTrackingNoticeWriteFromAnotherThread()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 0);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(7);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> future = executor.submit(() ->
                Future <object> future = executor.submit(() =>
                {
                    try
                    {
                        using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                        {
                            assertTrue(cursor.Next());
                            cursor.PutLong(1);
                        }
                    }
                    catch (IOException e)
                    {
                        throw new Exception(e);
                    }
                });
                future.get();

                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    MuninnPageCursor pageCursor = ( MuninnPageCursor )cursor;
                    assertEquals(7, pageCursor.PagedFile.getLastModifiedTxId(pageCursor.PinnedPageRef));
                    assertEquals(1, cursor.Long);
                }
            }
        }
Beispiel #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void markCursorContextAsDirtyWhenReadingDataFromMoreRecentTransactions() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void MarkCursorContextAsDirtyWhenReadingDataFromMoreRecentTransactions()
        {
            TestVersionContext     cursorContext          = new TestVersionContext(() => 3);
            VersionContextSupplier versionContextSupplier = new ConfiguredVersionContextSupplier(cursorContext);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, versionContextSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                cursorContext.InitWrite(7);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(3);
                }

                cursorContext.InitRead();
                assertFalse(cursorContext.Dirty);
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                    assertEquals(3, cursor.Long);
                    assertTrue(cursorContext.Dirty);
                }
            }
        }
Beispiel #12
0
 public override void Write(MetaDataRecord record, PageCursor cursor, int recordSize)
 {
     Debug.Assert(record.InUse());
     cursor.PutByte(Record.IN_USE.byteValue());
     cursor.PutLong(record.Value);
 }
Beispiel #13
0
 internal virtual void Put(PageCursor cursor)
 {
     cursor.PutLong(EntityId);
     PutInternal(cursor);
 }
Beispiel #14
0
 public override void WriteKey(PageCursor cursor, StringIndexKey key)
 {
     cursor.PutLong(key.EntityId);
     cursor.PutBytes(key.Bytes, 0, key.BytesLengthConflict);
 }
Beispiel #15
0
 internal static void Put(PageCursor cursor, long long0, long long1)
 {
     cursor.PutLong(long1);
     cursor.PutInt(( int )long0);
 }