示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCatchUpFromCoresWhenPreferredReadReplicasAreUnavailable() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCatchUpFromCoresWhenPreferredReadReplicasAreUnavailable()
        {
            // given
//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();
            int numberOfNodes                 = 1;
            int firstReadReplicaLocalMemberId = 101;

            cluster.CoreTx((db, tx) =>
            {
                Db.schema().constraintFor(label("Foo")).assertPropertyIsUnique("foobar").create();
                tx.success();
            });

            createLabelledNodesWithProperty(cluster, numberOfNodes, label("Foo"), () => Pair.of("foobar", string.Format("baz_bat{0}", System.Guid.randomUUID())));

            ReadReplica firstReadReplica = cluster.AddReadReplicaWithIdAndMonitors(firstReadReplicaLocalMemberId, new Monitors());

            firstReadReplica.Start();

            CheckDataHasReplicatedToReadReplicas(cluster, numberOfNodes);

            upstreamFactory.Current = firstReadReplica;

            ReadReplica secondReadReplica = cluster.AddReadReplicaWithId(202);

            secondReadReplica.UpstreamDatabaseSelectionStrategy = "specific";

            secondReadReplica.Start();

            CheckDataHasReplicatedToReadReplicas(cluster, numberOfNodes);

            firstReadReplica.Shutdown();
            upstreamFactory.reset();

            cluster.RemoveReadReplicaWithMemberId(firstReadReplicaLocalMemberId);

            // when
            // More transactions into core
            createLabelledNodesWithProperty(cluster, numberOfNodes, label("Foo"), () => Pair.of("foobar", string.Format("baz_bat{0}", System.Guid.randomUUID())));

            // then
            // reached second read replica from cores
            CheckDataHasReplicatedToReadReplicas(cluster, numberOfNodes * 2);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEventuallyPullTransactionAcrossReadReplicas() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldEventuallyPullTransactionAcrossReadReplicas()
        {
            // given
//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();
            int numberOfNodesToCreate = 100;

            cluster.CoreTx((db, tx) =>
            {
                Db.schema().constraintFor(label("Foo")).assertPropertyIsUnique("foobar").create();
                tx.success();
            });

            createLabelledNodesWithProperty(cluster, numberOfNodesToCreate, label("Foo"), () => Pair.of("foobar", string.Format("baz_bat{0}", System.Guid.randomUUID())));

            ReadReplica firstReadReplica = cluster.AddReadReplicaWithIdAndMonitors(101, new Monitors());

            firstReadReplica.Start();

            CheckDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);

            foreach (CoreClusterMember coreClusterMember in cluster.CoreMembers())
            {
                coreClusterMember.DisableCatchupServer();
            }

            // when
            upstreamFactory.Current = firstReadReplica;
            ReadReplica secondReadReplica = cluster.AddReadReplicaWithId(202);

            secondReadReplica.UpstreamDatabaseSelectionStrategy = "specific";

            secondReadReplica.Start();

            // then

            CheckDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEventuallyPullTransactionDownToAllReadReplicas() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldEventuallyPullTransactionDownToAllReadReplicas()
        {
            // given
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
            Cluster <object> cluster         = ClusterRule.withNumberOfReadReplicas(0).startCluster();
            int nodesBeforeReadReplicaStarts = 1;

            cluster.CoreTx((db, tx) =>
            {
                Db.schema().constraintFor(Label.label("Foo")).assertPropertyIsUnique("foobar").create();
                tx.success();
            });

            // when
            for (int i = 0; i < 100; i++)
            {
                cluster.CoreTx((db, tx) =>
                {
                    createData(db, nodesBeforeReadReplicaStarts);
                    tx.success();
                });
            }

            ISet <Path> labelScanStoreFiles = new HashSet <Path>();

            cluster.CoreTx((db, tx) => gatherLabelScanStoreFiles(db, labelScanStoreFiles));

            AtomicBoolean labelScanStoreCorrectlyPlaced = new AtomicBoolean(false);
            Monitors      monitors = new Monitors();
            ReadReplica   rr       = cluster.AddReadReplicaWithIdAndMonitors(0, monitors);

            monitors.AddMonitorListener((FileCopyMonitor)file =>
            {
                if (labelScanStoreFiles.Contains(file.toPath().FileName))
                {
                    labelScanStoreCorrectlyPlaced.set(true);
                }
            });

            rr.Start();

            for (int i = 0; i < 100; i++)
            {
                cluster.CoreTx((db, tx) =>
                {
                    createData(db, nodesBeforeReadReplicaStarts);
                    tx.success();
                });
            }

            // then
            foreach (ReadReplica server in cluster.ReadReplicas())
            {
                GraphDatabaseService readReplica = server.database();
                using (Transaction tx = readReplica.BeginTx())
                {
                    ThrowingSupplier <long, Exception> nodeCount = () => count(readReplica.AllNodes);
                    assertEventually("node to appear on read replica", nodeCount, @is(400L), 1, MINUTES);

                    foreach (Node node in readReplica.AllNodes)
                    {
                        assertThat(node.GetProperty("foobar").ToString(), startsWith("baz_bat"));
                    }

                    tx.Success();
                }
            }

            assertTrue(labelScanStoreCorrectlyPlaced.get());
        }