Ejemplo n.º 1
0
 public override void Load(long pageId)
 {
     _received.AndIncrement;
     _executor.execute(() =>
     {
         try
         {
             try
             {
                 using (PageCursor cursor = _file.io(pageId, PF_SHARED_READ_LOCK))
                 {
                     cursor.next();
                 }
             }
             catch (IOException)
             {
             }
         }
         finally
         {
             _pageCache.reportEvents();
             _processed.AndIncrement;
         }
     });
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void prepareCursor() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PrepareCursor()
        {
            Cursor = new PageAwareByteArrayCursor(PAGE_SIZE);
            Cursor.next();
            _layout = Layout;
            _node   = GetNode(PAGE_SIZE, _layout);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void write(byte[] data) throws java.io.IOException
            internal override void Write(sbyte[] data)
            {
                if (Cursor.Offset == File.pageSize())
                {
                    Cursor.next();
                }
                Cursor.putBytes(data);
            }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGrant_read_shouldRetry_next() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGrantReadShouldRetryNext()
        {
            // GIVEN
            _cursor.getByte(0);

            // WHEN
            _cursor.shouldRetry();

            // THEN
            _cursor.next();
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setUpgradeTransactionMustBeAtomic() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUpgradeTransactionMustBeAtomic()
        {
            using (MetaDataStore store = NewMetaDataStore())
            {
                PagedFile pf = store.PagedFile;
                store.SetUpgradeTransaction(0, 0, 0);
                AtomicLong writeCount    = new AtomicLong();
                AtomicLong fileReadCount = new AtomicLong();
                AtomicLong apiReadCount  = new AtomicLong();
                int        upperLimit    = 10_000;
                int        lowerLimit    = 100;
                long       endTime       = currentTimeMillis() + SECONDS.toMillis(10);

                Race race = new Race();
                race.WithEndCondition(() => writeCount.get() >= upperLimit && fileReadCount.get() >= upperLimit && apiReadCount.get() >= upperLimit);
                race.WithEndCondition(() => writeCount.get() >= lowerLimit && fileReadCount.get() >= lowerLimit && apiReadCount.get() >= lowerLimit && currentTimeMillis() >= endTime);
                // writers
                race.AddContestants(3, () =>
                {
                    long count = writeCount.incrementAndGet();
                    store.SetUpgradeTransaction(count, count, count);
                });

                // file readers
                race.AddContestants(3, throwing(() =>
                {
                    using (PageCursor cursor = pf.Io(0, PagedFile.PF_SHARED_READ_LOCK))
                    {
                        assertTrue(cursor.next());
                        long id;
                        long checksum;
                        do
                        {
                            id       = store.GetRecordValue(cursor, MetaDataStore.Position.UpgradeTransactionId);
                            checksum = store.GetRecordValue(cursor, MetaDataStore.Position.UpgradeTransactionChecksum);
                        } while (cursor.shouldRetry());
                        AssertIdEqualsChecksum(id, checksum, "file");
                        fileReadCount.incrementAndGet();
                    }
                }));

                race.AddContestants(3, () =>
                {
                    TransactionId transaction = store.UpgradeTransaction;
                    AssertIdEqualsChecksum(transaction.TransactionIdConflict(), transaction.Checksum(), "API");
                    apiReadCount.incrementAndGet();
                });
                race.Go();
            }
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void transactionClosedMustBeAtomic() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TransactionClosedMustBeAtomic()
        {
            using (MetaDataStore store = NewMetaDataStore())
            {
                PagedFile pf           = store.PagedFile;
                int       initialValue = 2;
                store.TransactionClosed(initialValue, initialValue, initialValue);
                AtomicLong writeCount    = new AtomicLong();
                AtomicLong fileReadCount = new AtomicLong();
                AtomicLong apiReadCount  = new AtomicLong();
                int        upperLimit    = 10_000;
                int        lowerLimit    = 100;
                long       endTime       = currentTimeMillis() + SECONDS.toMillis(10);

                Race race = new Race();
                race.WithEndCondition(() => writeCount.get() >= upperLimit && fileReadCount.get() >= upperLimit && apiReadCount.get() >= upperLimit);
                race.WithEndCondition(() => writeCount.get() >= lowerLimit && fileReadCount.get() >= lowerLimit && apiReadCount.get() >= lowerLimit && currentTimeMillis() >= endTime);
                race.AddContestants(3, () =>
                {
                    long count = writeCount.incrementAndGet();
                    store.TransactionCommitted(count, count, count);
                });

                race.AddContestants(3, throwing(() =>
                {
                    using (PageCursor cursor = pf.Io(0, PagedFile.PF_SHARED_READ_LOCK))
                    {
                        assertTrue(cursor.next());
                        long logVersion;
                        long byteOffset;
                        do
                        {
                            logVersion = store.GetRecordValue(cursor, MetaDataStore.Position.LastClosedTransactionLogVersion);
                            byteOffset = store.GetRecordValue(cursor, MetaDataStore.Position.LastClosedTransactionLogByteOffset);
                        } while (cursor.shouldRetry());
                        AssertLogVersionEqualsByteOffset(logVersion, byteOffset, "file");
                        fileReadCount.incrementAndGet();
                    }
                }));

                race.AddContestants(3, () =>
                {
                    long[] transaction = store.LastClosedTransaction;
                    AssertLogVersionEqualsByteOffset(transaction[0], transaction[1], "API");
                    apiReadCount.incrementAndGet();
                });
                race.Go();
            }
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean next() throws java.io.IOException
        public override bool Next()
        {
            return(Delegate.next());
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: PageWriter(org.neo4j.io.pagecache.PagedFile file) throws java.io.IOException
            internal PageWriter(PagedFile file)
            {
                this.File   = file;
                this.Cursor = file.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock);
                Cursor.next();
            }