コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pageFaultsFromReplicationMustCountInMetrics() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PageFaultsFromReplicationMustCountInMetrics()
        {
            // Given initial pin counts on all members
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.startCluster();
            Cluster <object> cluster = ClusterRule.startCluster();

            System.Func <ReadReplica, PageCacheCounters> getPageCacheCounters = ccm => ccm.database().DependencyResolver.resolveDependency(typeof(PageCacheCounters));
            IList <PageCacheCounters> countersList = cluster.ReadReplicas().Select(getPageCacheCounters).ToList();

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            long[] initialPins = countersList.Select(PageCacheCounters::pins).ToArray();

            // when the leader commits a write transaction,
            cluster.CoreTx((db, tx) =>
            {
                Node node = Db.createNode(label("boo"));
                node.setProperty("foobar", "baz_bat");
                tx.success();
            });

            // then the replication should cause pins on a majority of core members to increase.
            // However, the commit returns as soon as the transaction has been replicated through the Raft log, which
            // happens before the transaction is applied on the members, and then replicated to read-replicas.
            // Therefor we are racing with the transaction application on the read-replicas, so we have to spin.
            int minimumUpdatedMembersCount = countersList.Count / 2 + 1;

            assertEventually("Expected followers to eventually increase pin counts", () =>
            {
                long[] pinsAfterCommit           = countersList.Select(PageCacheCounters.pins).ToArray();
                int membersWithIncreasedPinCount = 0;
                for (int i = 0; i < initialPins.Length; i++)
                {
                    long before = initialPins[i];
                    long after  = pinsAfterCommit[i];
                    if (before < after)
                    {
                        membersWithIncreasedPinCount++;
                    }
                }
                return(membersWithIncreasedPinCount);
            }, Matchers.@is(greaterThanOrEqualTo(minimumUpdatedMembersCount)), 10, SECONDS);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void streamFilesRecursiveMustBeEmptyForEmptyBaseDirectory() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StreamFilesRecursiveMustBeEmptyForEmptyBaseDirectory()
        {
            File dir = ExistingDirectory("dir");

            assertThat(Fsa.streamFilesRecursive(dir).count(), Matchers.@is(0L));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void leaderShouldStepDownWhenFollowersAreGone() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LeaderShouldStepDownWhenFollowersAreGone()
        {
            // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.startCluster();
            Cluster <object> cluster = ClusterRule.startCluster();

            //Do some work to make sure the cluster is operating normally.
            CoreClusterMember leader = cluster.CoreTx((db, tx) =>
            {
                Node node = Db.createNode(Label.label("bam"));
                node.setProperty("bam", "bam");
                tx.success();
            });

            ThrowingSupplier <IList <CoreClusterMember>, Exception> followers = () => cluster.CoreMembers().Where(m => m.raft().currentRole() != Role.LEADER).ToList();

            assertEventually("All followers visible", followers, Matchers.hasSize(7), 2, TimeUnit.MINUTES);

            //when
            //shutdown 4 servers, leaving 4 remaining and therefore not a quorum.
            followers.Get().subList(0, 4).forEach(CoreClusterMember.shutdown);

            //then
            assertEventually("Leader should have stepped down.", () => leader.Raft().Leader, Matchers.@is(false), 2, TimeUnit.MINUTES);
        }