Exemple #1
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);
            }
        }
Exemple #2
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);
        }
Exemple #3
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()));
            }
        }
Exemple #4
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()));
            }
        }