示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToDownloadToNewInstanceAfterPruning() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToDownloadToNewInstanceAfterPruning()
        {
            // given
            IDictionary <string, string> @params = stringMap(CausalClusteringSettings.state_machine_flush_window_size.name(), "1", CausalClusteringSettings.raft_log_pruning_strategy.name(), "3 entries", CausalClusteringSettings.raft_log_rotation_size.name(), "1K");

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withSharedCoreParams(params).startCluster();
            Cluster <object> cluster = ClusterRule.withSharedCoreParams(@params).startCluster();

            CoreClusterMember leader = cluster.CoreTx((db, tx) =>
            {
                createData(db, 10000);
                tx.success();
            });

            // when
            foreach (CoreClusterMember coreDb in cluster.CoreMembers())
            {
                coreDb.RaftLogPruner().prune();
            }

            cluster.RemoveCoreMember(leader);                 // to force a change of leader
            leader = cluster.AwaitLeader();

            int newDbId = 3;

            cluster.AddCoreMemberWithId(newDbId).start();
            CoreGraphDatabase newDb = cluster.GetCoreMemberById(newDbId).database();

            // then
            assertEquals(DbRepresentation.of(leader.Database()), DbRepresentation.of(newDb));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToDownloadANewStoreAfterPruning() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToDownloadANewStoreAfterPruning()
        {
            // given
            IDictionary <string, string> @params = stringMap(GraphDatabaseSettings.keep_logical_logs.name(), "keep_none", GraphDatabaseSettings.logical_log_rotation_threshold.name(), "1M", GraphDatabaseSettings.check_point_interval_time.name(), "100ms");

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withSharedCoreParams(params).startCluster();
            Cluster <object> cluster = ClusterRule.withSharedCoreParams(@params).startCluster();

            cluster.CoreTx((db, tx) =>
            {
                createData(db, 10);
                tx.success();
            });

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

            ReadReplica readReplica = cluster.GetReadReplicaById(0);
            long        highestReadReplicaLogVersion = PhysicalLogFiles(readReplica).HighestLogVersion;

            // when
            readReplica.Shutdown();

            CoreClusterMember core;

            do
            {
                core = cluster.CoreTx((db, tx) =>
                {
                    createData(db, 1_000);
                    tx.success();
                });
            } while (PhysicalLogFiles(core).LowestLogVersion <= highestReadReplicaLogVersion);

            readReplica.Start();

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

            assertEventually("The read replica has the same data as the core members", () => DbRepresentation.of(readReplica.Database()), equalTo(DbRepresentation.of(cluster.AwaitLeader().database())), 10, TimeUnit.SECONDS);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFindReadWriteAndRouteServers() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFindReadWriteAndRouteServers()
        {
            // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withSharedCoreParams(config).withNumberOfReadReplicas(1).startCluster();
            Cluster <object> cluster = ClusterRule.withSharedCoreParams(Config).withNumberOfReadReplicas(1).startCluster();

            // then
            int cores         = cluster.CoreMembers().Count;
            int readReplicas  = cluster.ReadReplicas().Count;
            int readEndPoints = ExpectFollowersAsReadEndPoints ? (cores - 1 + readReplicas) : readReplicas;

            for (int i = 0; i < 3; i++)
            {
                IList <IDictionary <string, object> > members = GetMembers(cluster.GetCoreMemberById(i).database());

                assertEquals(1, members.Where(x => x.get("role").Equals("WRITE")).flatMap(x => Arrays.stream(( object[] )x.get("addresses"))).Count());

                assertEquals(readEndPoints, members.Where(x => x.get("role").Equals("READ")).flatMap(x => Arrays.stream(( object[] )x.get("addresses"))).Count());

                assertEquals(cores, members.Where(x => x.get("role").Equals("ROUTE")).flatMap(x => Arrays.stream(( object[] )x.get("addresses"))).Count());
            }
        }