Beispiel #1
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());
        }