Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB()
        public virtual void ShouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB()
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.newGraphDatabase();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(Label.label("A"));
                Db.createNode(Label.label("C"));
                Node node = Db.createNode(Label.label("D"));
                Db.createNode();
                node.Delete();
                tx.Success();
            }
            long lastCommittedTransactionId = GetLastTxId(db);

            Db.shutdown();

            RebuildCounts(lastCommittedTransactionId);

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker());
                assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1, store.TxId());
                assertEquals(3, store.TotalEntriesStored());
                assertEquals(3, Get(store, nodeKey(-1)));
                assertEquals(1, Get(store, nodeKey(0)));
                assertEquals(1, Get(store, nodeKey(1)));
                assertEquals(0, Get(store, nodeKey(2)));
                assertEquals(0, Get(store, nodeKey(3)));
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenClosingTheDatabase()
        public virtual void ShouldRotateCountsStoreWhenClosingTheDatabase()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(_a);
                tx.Success();
            }

            // WHEN
            Db.shutdown();

            // THEN
            assertTrue(_fs.fileExists(AlphaStoreFile()));
            assertTrue(_fs.fileExists(BetaStoreFile()));

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker(_pageCache));
                // a transaction for creating the label and a transaction for the node
                assertEquals(BASE_TX_ID + 1 + 1, store.TxId());
                assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion());
                // one for all nodes and one for the created "A" label
                assertEquals(1 + 1, store.TotalEntriesStored());
                assertEquals(1 + 1, AllRecords(store).Count);
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState()
        {
            // Given
            _dbBuilder.newGraphDatabase().shutdown();
            CountsTracker store = CreateCountsTracker(_pageCache, Config.defaults(GraphDatabaseSettings.counts_store_rotation_timeout, "100ms"));

            using (Lifespan lifespan = new Lifespan(store))
            {
                using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = store.Apply(2).get())
                {
                    updater.IncrementNodeCount(0, 1);
                }

                try
                {
                    // when
                    store.Rotate(3);
                    fail("should have thrown");
                }
                catch (RotationTimeoutException)
                {
                    // good
                }
            }

            // and also no exceptions closing the page cache
            _pageCache.close();
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase()
        public virtual void ShouldCreateEmptyCountsTrackerStoreWhenCreatingDatabase()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            // WHEN
            Db.shutdown();

            // THEN
            assertTrue(_fs.fileExists(AlphaStoreFile()));
            assertFalse(_fs.fileExists(BetaStoreFile()));

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker(_pageCache));

                assertEquals(BASE_TX_ID, store.TxId());
                assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion());
                assertEquals(0, store.TotalEntriesStored());
                assertEquals(0, AllRecords(store).Count);
            }

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker(_pageCache));
                assertEquals(BASE_TX_ID, store.TxId());
                assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion());
                assertEquals(0, store.TotalEntriesStored());
                assertEquals(0, AllRecords(store).Count);
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenRotatingLog() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRotateCountsStoreWhenRotatingLog()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            // WHEN doing a transaction (actually two, the label-mini-tx also counts)
            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(_b);
                tx.Success();
            }
            // and rotating the log (which implies flushing)
            CheckPoint(db);
            // and creating another node after it
            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(_c);
                tx.Success();
            }

            // THEN
            assertTrue(_fs.fileExists(AlphaStoreFile()));
            assertTrue(_fs.fileExists(BetaStoreFile()));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.pagecache.PageCache pageCache = db.getDependencyResolver().resolveDependency(org.neo4j.io.pagecache.PageCache.class);
            PageCache pageCache = Db.DependencyResolver.resolveDependency(typeof(PageCache));

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker(pageCache));
                // NOTE since the rotation happens before the second transaction is committed we do not see those changes
                // in the stats
                // a transaction for creating the label and a transaction for the node
                assertEquals(BASE_TX_ID + 1 + 1, store.TxId());
                assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion());
                // one for all nodes and one for the created "B" label
                assertEquals(1 + 1, store.TotalEntriesStored());
                assertEquals(1 + 1, AllRecords(store).Count);
            }

            // on the other hand the tracker should read the correct value by merging data on disk and data in memory
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CountsTracker tracker = db.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).testAccessNeoStores().getCounts();
            CountsTracker tracker = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().Counts;

            assertEquals(1 + 1, tracker.NodeCount(-1, newDoubleLongRegister()).readSecond());

            int labelId;

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction transaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true);
                labelId = transaction.TokenRead().nodeLabel(_c.name());
            }
            assertEquals(1, tracker.NodeCount(labelId, newDoubleLongRegister()).readSecond());

            Db.shutdown();
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldSupportTransactionsAppliedOutOfOrderOnRotation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSupportTransactionsAppliedOutOfOrderOnRotation()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CountsTracker tracker = resourceManager.managed(newTracker());
            CountsTracker tracker = ResourceManager.managed(NewTracker());

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(2).get())
            {
                tx.IncrementNodeCount(1, 1);
            }
            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(4).get())
            {
                tx.IncrementNodeCount(1, 1);
            }

            // when
            Future <long> rotated = Threading.executeAndAwait(new Rotation(2), tracker, thread =>
            {
                switch (thread.State)
                {
                case BLOCKED:
                case WAITING:
                case TIMED_WAITING:
                case TERMINATED:
                    return(true);

                default:
                    return(false);
                }
            }, 10, SECONDS);

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(5).get())
            {
                tx.IncrementNodeCount(1, 1);
            }
            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(3).get())
            {
                tx.IncrementNodeCount(1, 1);
            }

            // then
            assertEquals("rotated transaction", 4, rotated.get().longValue());
            assertEquals("stored transaction", 4, tracker.TxId());

            // the value in memory
            assertEquals("count", 4, tracker.NodeCount(1, Registers.newDoubleLongRegister()).readSecond());

            // the value in the store
            CountsVisitor visitor = mock(typeof(CountsVisitor));

            tracker.VisitFile(tracker.CurrentFile(), visitor);
            verify(visitor).visitNodeCount(1, 3);
            verifyNoMoreInteractions(visitor);

            assertEquals("final rotation", 5, tracker.Rotate(5));
        }
Пример #7
0
 private void CheckEmptyCountStore()
 {
     using (Lifespan life = new Lifespan())
     {
         CountsTracker store = life.Add(CreateCountsTracker());
         assertEquals(BASE_TX_ID, store.TxId());
         assertEquals(0, store.TotalEntriesStored());
     }
 }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation()
        {
            // given
            CountsOracle oracle            = SomeData();
            const int    firstTransaction  = 2;
            int          secondTransaction = 3;

            using (Lifespan life = new Lifespan())
            {
                CountsTracker tracker = life.Add(NewTracker());
                oracle.Update(tracker, firstTransaction);
                tracker.Rotate(firstTransaction);
            }

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.CountsOracle delta = new org.neo4j.kernel.impl.store.CountsOracle();
            CountsOracle delta = new CountsOracle();

            {
                CountsOracle.Node n1 = delta.Node(1);
                CountsOracle.Node n2 = delta.Node(1, 4);                 // Label 4 has not been used before...
                delta.Relationship(n1, 1, n2);
                delta.Relationship(n2, 2, n1);                           // relationshipType 2 has not been used before...
            }
            delta.Update(oracle);

            using (Lifespan life = new Lifespan())
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
                Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
                CountsTracker tracker = life.Add(new CountsTrackerAnonymousInnerClass(this, ResourceManager.logProvider(), ResourceManager.fileSystem(), ResourceManager.pageCache(), Config.defaults(), EmptyVersionContextSupplier.EMPTY, barrier));
                Future <Void> task    = Threading.execute(t =>
                {
                    try
                    {
                        delta.Update(t, secondTransaction);
                        t.rotate(secondTransaction);
                    }
                    catch (IOException e)
                    {
                        throw new AssertionError(e);
                    }
                    return(null);
                }, tracker);

                // then
                barrier.Await();
                oracle.Verify(tracker);
                barrier.Release();
                task.get();
                oracle.Verify(tracker);
            }
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOrderStoreByTxIdInHeaderThenMinorVersion()
        public virtual void ShouldOrderStoreByTxIdInHeaderThenMinorVersion()
        {
            // given
            FileVersion version = new FileVersion(16, 5);

            // then
            assertTrue(CountsTracker.Compare(version, new FileVersion(5, 5)) > 0);
            assertEquals(0, CountsTracker.Compare(version, new FileVersion(16, 5)));
            assertTrue(CountsTracker.Compare(version, new FileVersion(30, 1)) < 0);
            assertTrue(CountsTracker.Compare(version, new FileVersion(16, 1)) > 0);
            assertTrue(CountsTracker.Compare(version, new FileVersion(16, 7)) < 0);
        }
Пример #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldNotRotateIfNoDataChanges() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotRotateIfNoDataChanges()
        {
            // given
            CountsTracker tracker = ResourceManager.managed(NewTracker());
            File          before  = tracker.CurrentFile();

            // when
            tracker.Rotate(tracker.TxId());

            // then
            assertSame("not rotated", before, tracker.CurrentFile());
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldNotEndUpInBrokenStateAfterRotationFailure() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotEndUpInBrokenStateAfterRotationFailure()
        {
            // GIVEN
            FakeClock         clock             = Clocks.fakeClock();
            CallTrackingClock callTrackingClock = new CallTrackingClock(clock);
            CountsTracker     tracker           = ResourceManager.managed(NewTracker(callTrackingClock, EmptyVersionContextSupplier.EMPTY));
            int labelId = 1;

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(2).get())
            {
                tx.IncrementNodeCount(labelId, 1);                           // now at 1
            }

            // WHEN
            System.Predicate <Thread> arrived  = thread => stackTraceContains(thread, all(classNameContains("Rotation"), methodIs("rotate")));
            Future <object>           rotation = Threading.executeAndAwait(t => t.rotate(4), tracker, arrived, 1, SECONDS);

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(3).get())
            {
                tx.IncrementNodeCount(labelId, 1);                           // now at 2
            }
            while (callTrackingClock.CallsToNanos() == 0)
            {
                Thread.Sleep(10);
            }
            clock.Forward(Config.defaults().get(GraphDatabaseSettings.counts_store_rotation_timeout).toMillis() * 2, MILLISECONDS);
            try
            {
                rotation.get();
                fail("Should've failed rotation due to timeout");
            }
            catch (ExecutionException e)
            {
                // good
                assertTrue(e.InnerException is RotationTimeoutException);
            }

            // THEN
            Org.Neo4j.Register.Register_DoubleLongRegister register = Registers.newDoubleLongRegister();
            tracker.Get(CountsKeyFactory.nodeKey(labelId), register);
            assertEquals(2, register.ReadSecond());

            // and WHEN later attempting rotation again
            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(4).get())
            {
                tx.IncrementNodeCount(labelId, 1);                           // now at 3
            }
            tracker.Rotate(4);

            // THEN
            tracker.Get(CountsKeyFactory.nodeKey(labelId), register);
            assertEquals(3, register.ReadSecond());
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldRotateOnDataChangesEvenIfTransactionIsUnchanged() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRotateOnDataChangesEvenIfTransactionIsUnchanged()
        {
            // given
            CountsTracker tracker = ResourceManager.managed(NewTracker());
            File          before  = tracker.CurrentFile();

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_IndexStatsUpdater updater = tracker.UpdateIndexCounts())
            {
                updater.IncrementIndexUpdates(7, 100);
            }

            // when
            tracker.Rotate(tracker.TxId());

            // then
            assertNotEquals("rotated", before, tracker.CurrentFile());
        }
Пример #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateACountStoreWhenDBContainsDenseNodes()
        public virtual void ShouldCreateACountStoreWhenDBContainsDenseNodes()
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.setConfig(org.neo4j.graphdb.factory.GraphDatabaseSettings.dense_node_threshold, "2").newGraphDatabase();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.setConfig(GraphDatabaseSettings.dense_node_threshold, "2").newGraphDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Node nodeA = Db.createNode(Label.label("A"));
                Node nodeC = Db.createNode(Label.label("C"));
                Node nodeD = Db.createNode(Label.label("D"));
                nodeA.CreateRelationshipTo(nodeA, RelationshipType.withName("TYPE1"));
                nodeA.CreateRelationshipTo(nodeC, RelationshipType.withName("TYPE2"));
                nodeA.CreateRelationshipTo(nodeD, RelationshipType.withName("TYPE3"));
                nodeD.CreateRelationshipTo(nodeC, RelationshipType.withName("TYPE4"));
                tx.Success();
            }
            long lastCommittedTransactionId = GetLastTxId(db);

            Db.shutdown();

            RebuildCounts(lastCommittedTransactionId);

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker());
                assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1, store.TxId());
                assertEquals(22, store.TotalEntriesStored());
                assertEquals(3, Get(store, nodeKey(-1)));
                assertEquals(1, Get(store, nodeKey(0)));
                assertEquals(1, Get(store, nodeKey(1)));
                assertEquals(1, Get(store, nodeKey(2)));
                assertEquals(0, Get(store, nodeKey(3)));
                assertEquals(4, Get(store, relationshipKey(-1, -1, -1)));
                assertEquals(1, Get(store, relationshipKey(-1, 0, -1)));
                assertEquals(1, Get(store, relationshipKey(-1, 1, -1)));
                assertEquals(1, Get(store, relationshipKey(-1, 2, -1)));
                assertEquals(1, Get(store, relationshipKey(-1, 3, -1)));
                assertEquals(0, Get(store, relationshipKey(-1, 4, -1)));
                assertEquals(1, Get(store, relationshipKey(-1, 1, 1)));
                assertEquals(2, Get(store, relationshipKey(-1, -1, 1)));
                assertEquals(3, Get(store, relationshipKey(0, -1, -1)));
            }
        }
Пример #14
0
        private void RebuildCounts(long lastCommittedTransactionId, ProgressReporter progressReporter)
        {
            CleanupCountsForRebuilding();

            IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(_fs);
            StoreFactory       storeFactory = new StoreFactory(_testDir.databaseLayout(), _config, idGenFactory, _pageCache, _fs, _logProvider, EmptyVersionContextSupplier.EMPTY);

            using (Lifespan life = new Lifespan(), NeoStores neoStores = storeFactory.OpenAllNeoStores())
            {
                NodeStore         nodeStore           = neoStores.NodeStore;
                RelationshipStore relationshipStore   = neoStores.RelationshipStore;
                int            highLabelId            = ( int )neoStores.LabelTokenStore.HighId;
                int            highRelationshipTypeId = ( int )neoStores.RelationshipTypeTokenStore.HighId;
                CountsComputer countsComputer         = new CountsComputer(lastCommittedTransactionId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId, [email protected]_Fields.AutoWithoutPagecache, progressReporter);
                CountsTracker  countsTracker          = CreateCountsTracker();
                life.Add(countsTracker.setInitializer(countsComputer));
            }
        }
Пример #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStoreCounts()
        {
            // given
            CountsOracle oracle = SomeData();

            // when
            using (Lifespan life = new Lifespan())
            {
                CountsTracker tracker = life.Add(NewTracker());
                oracle.Update(tracker, 2);
                tracker.Rotate(2);
            }

            // then
            using (Lifespan life = new Lifespan())
            {
                oracle.Verify(life.Add(NewTracker()));
            }
        }
Пример #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldBeAbleToWriteDataToCountsTracker() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToWriteDataToCountsTracker()
        {
            // given
            CountsTracker tracker = ResourceManager.managed(NewTracker());
            long          indexId = 0;
            CountsOracle  oracle  = new CountsOracle();

            {
                CountsOracle.Node a = oracle.Node(1);
                CountsOracle.Node b = oracle.Node(1);
                oracle.Relationship(a, 1, b);
                oracle.IndexSampling(indexId, 2, 2);
                oracle.IndexUpdatesAndSize(indexId, 10, 2);
            }

            // when
            oracle.Update(tracker, 2);

            // then
            oracle.Verify(tracker);

            // when
            tracker.Rotate(2);

            // then
            oracle.Verify(tracker);

            // when
            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_IndexStatsUpdater updater = tracker.UpdateIndexCounts())
            {
                updater.IncrementIndexUpdates(indexId, 2);
            }

            // then
            oracle.IndexUpdatesAndSize(indexId, 12, 2);
            oracle.Verify(tracker);

            // when
            tracker.Rotate(2);

            // then
            oracle.Verify(tracker);
        }
Пример #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateCountsOnExistingStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUpdateCountsOnExistingStore()
        {
            // given
            CountsOracle oracle   = SomeData();
            int          firstTx  = 2;
            int          secondTx = 3;

            using (Lifespan life = new Lifespan())
            {
                CountsTracker tracker = life.Add(NewTracker());
                oracle.Update(tracker, firstTx);
                tracker.Rotate(firstTx);

                oracle.Verify(tracker);

                // when
                CountsOracle delta = new CountsOracle();
                {
                    CountsOracle.Node n1 = delta.Node(1);
                    CountsOracle.Node n2 = delta.Node(1, 4);                      // Label 4 has not been used before...
                    delta.Relationship(n1, 1, n2);
                    delta.Relationship(n2, 2, n1);                                // relationshipType 2 has not been used before...
                }
                delta.Update(tracker, secondTx);
                delta.Update(oracle);

                // then
                oracle.Verify(tracker);

                // when
                tracker.Rotate(secondTx);
            }

            // then
            using (Lifespan life = new Lifespan())
            {
                oracle.Verify(life.Add(NewTracker()));
            }
        }
Пример #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allowNonDirtyInMemoryDirtyVersionRead()
        public virtual void AllowNonDirtyInMemoryDirtyVersionRead()
        {
            int  labelId = 1;
            long lastClosedTransactionId = 15L;
            long writeTransactionId      = 13L;
            TransactionVersionContextSupplier versionContextSupplier = new TransactionVersionContextSupplier();

            versionContextSupplier.Init(() => lastClosedTransactionId);
            VersionContext versionContext = versionContextSupplier.VersionContext;

            using (Lifespan life = new Lifespan())
            {
                CountsTracker tracker = life.Add(NewTracker(versionContextSupplier));
                using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = tracker.Apply(writeTransactionId).get())
                {
                    updater.IncrementNodeCount(labelId, 1);
                }

                versionContext.InitRead();
                tracker.NodeCount(labelId, Registers.newDoubleLongRegister());
                assertFalse(versionContext.Dirty);
            }
        }
Пример #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rotationShouldNotCauseUnmappedFileProblem() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RotationShouldNotCauseUnmappedFileProblem()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            DependencyResolver  resolver      = Db.DependencyResolver;
            RecordStorageEngine storageEngine = resolver.ResolveDependency(typeof(RecordStorageEngine));
            CountsTracker       countStore    = storageEngine.TestAccessNeoStores().Counts;

            AtomicBoolean workerContinueFlag = new AtomicBoolean(true);
            AtomicLong    lookupsCounter     = new AtomicLong();
            int           rotations          = 100;

            for (int i = 0; i < 5; i++)
            {
                _threadingRule.execute(CountStoreLookup(workerContinueFlag, lookupsCounter), countStore);
            }

            long startTxId = countStore.TxId();

            for (int i = 1; (i < rotations) || (lookupsCounter.get() == 0); i++)
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(_b);
                    tx.Success();
                }
                CheckPoint(db);
            }
            workerContinueFlag.set(false);

            assertEquals("Should perform at least 100 rotations.", rotations, Math.Min(rotations, countStore.TxId() - startTxId));
            assertTrue("Should perform more then 0 lookups without exceptions.", lookupsCounter.get() > 0);

            Db.shutdown();
        }
Пример #20
0
 internal DelegatingVisitor(CountsTracker outerInstance, CountsVisitor visitor) : base(outerInstance)
 {
     this._outerInstance = outerInstance;
     this.Visitor        = visitor;
 }
Пример #21
0
 private long Get(CountsTracker store, CountsKey key)
 {
     Org.Neo4j.Register.Register_DoubleLongRegister value = Registers.newDoubleLongRegister();
     store.Get(key, value);
     return(value.ReadSecond());
 }
Пример #22
0
 public DataInitializerAnonymousInnerClass(CountsTracker outerInstance, DataInitializer <Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater> initializer)
 {
     this.outerInstance = outerInstance;
     this._initializer  = initializer;
 }