Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void aReadReplicShouldBeAbleToRejoinTheCluster() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AReadReplicShouldBeAbleToRejoinTheCluster()
        {
            int readReplicaId = 4;
//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();

            cluster.CoreTx(_createSomeData);

            cluster.AddReadReplicaWithId(readReplicaId).start();

            // let's spend some time by adding more data
            cluster.CoreTx(_createSomeData);

            awaitEx(() => ReadReplicasUpToDateAsTheLeader(cluster.AwaitLeader(), cluster.ReadReplicas()), 1, TimeUnit.MINUTES);
            cluster.RemoveReadReplicaWithMemberId(readReplicaId);

            // let's spend some time by adding more data
            cluster.CoreTx(_createSomeData);

            cluster.AddReadReplicaWithId(readReplicaId).start();

            awaitEx(() => ReadReplicasUpToDateAsTheLeader(cluster.AwaitLeader(), cluster.ReadReplicas()), 1, TimeUnit.MINUTES);

            System.Func <ClusterMember, DbRepresentation> toRep = db => DbRepresentation.of(Db.database());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <DbRepresentation> dbs = cluster.CoreMembers().Select(toRep).collect(toSet());

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            dbs.addAll(cluster.ReadReplicas().Select(toRep).collect(toSet()));

            cluster.Shutdown();

            assertEquals(1, dbs.Count);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldShutdownRatherThanPullUpdatesFromCoreMemberWithDifferentStoreIdIfLocalStoreIsNonEmpty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldShutdownRatherThanPullUpdatesFromCoreMemberWithDifferentStoreIdIfLocalStoreIsNonEmpty()
        {
//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();

            cluster.CoreTx(_createSomeData);

            cluster.AwaitCoreMemberWithRole(Role.FOLLOWER, 2, TimeUnit.SECONDS);

            // Get a read replica and make sure that it is operational
            ReadReplica readReplica = cluster.AddReadReplicaWithId(4);

            readReplica.Start();
            readReplica.Database().beginTx().close();

            // Change the store id, so it should fail to join the cluster again
            ChangeStoreId(readReplica);
            readReplica.Shutdown();

            try
            {
                readReplica.Start();
                fail("Should have failed to start");
            }
            catch (Exception required)
            {
                // Lifecycle should throw exception, server should not start.
                assertThat(required.InnerException, instanceOf(typeof(LifecycleException)));
                assertThat(required.InnerException.InnerException, instanceOf(typeof(Exception)));
                assertThat(required.InnerException.InnerException.Message, containsString("This read replica cannot join the cluster. " + "The local database is not empty and has a mismatching storeId:"));
            }
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCatchupThroughHierarchy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCatchupThroughHierarchy()
        {
            ClusterRule = ClusterRule.withInstanceReadReplicaParam(CausalClusteringSettings.server_groups, id => _serverGroups[id]).withInstanceCoreParam(CausalClusteringSettings.server_groups, id => _serverGroups[id]);

            // 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();
            });

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

            // 3, 4 are other DCs
            ReadReplica east3 = cluster.AddReadReplicaWithId(3);

            east3.Start();
            ReadReplica west4 = cluster.AddReadReplicaWithId(4);

            west4.Start();

            checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);

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

            // 5, 6 are other DCs
            ReadReplica east5 = cluster.AddReadReplicaWithId(5);

            east5.UpstreamDatabaseSelectionStrategy = "connect-randomly-within-server-group";
            east5.Start();
            ReadReplica west6 = cluster.AddReadReplicaWithId(6);

            west6.UpstreamDatabaseSelectionStrategy = "connect-randomly-within-server-group";
            west6.Start();

            checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDiscoverNewReadReplicas() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDiscoverNewReadReplicas()
        {
            // given
            int coreMembers         = 3;
            int initialReadReplicas = 2;

            ClusterRule.withNumberOfCoreMembers(coreMembers);
            ClusterRule.withNumberOfReadReplicas(initialReadReplicas);

//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();

            // when
            cluster.AddReadReplicaWithId(initialReadReplicas).start();
            cluster.AddReadReplicaWithId(initialReadReplicas + 1).start();

            Matcher <IList <MemberInfo> > expected = allOf(ContainsAllMemberAddresses(cluster.CoreMembers(), cluster.ReadReplicas()), ContainsRole(LEADER, 1), ContainsRole(FOLLOWER, coreMembers - 1), ContainsRole(READ_REPLICA, initialReadReplicas + 2));

            // then
            AssertAllEventualOverviews(cluster, expected);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }