Esempio n. 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));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void singleServerWithinClusterShouldBeConsistentAfterRestart() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SingleServerWithinClusterShouldBeConsistentAfterRestart()
        {
            // 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 clusterSize          = cluster.NumberOfCoreMembersReportedByTopology();

            FireSomeLoadAtTheCluster(cluster);

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <File> storeDirs = cluster.CoreMembers().Select(CoreClusterMember::databaseDirectory).collect(toSet());

            // when
            for (int i = 0; i < clusterSize; i++)
            {
                cluster.RemoveCoreMemberWithServerId(i);
                FireSomeLoadAtTheCluster(cluster);
                cluster.AddCoreMemberWithId(i).start();
            }

            // then
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            assertEventually("All cores have the same data", () => cluster.CoreMembers().Select(RecoveryIT.dbRepresentation).collect(toSet()).size(), equalTo(1), 10, TimeUnit.SECONDS);

            cluster.Shutdown();

            storeDirs.forEach(RecoveryIT.assertConsistent);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void restartSecondServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RestartSecondServer()
        {
            // 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();

            // when
            cluster.RemoveCoreMemberWithServerId(1);
            cluster.AddCoreMemberWithId(1).start();

            // then
            cluster.Shutdown();
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void restartWhileDoingTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RestartWhileDoingTransactions()
        {
            // 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();

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.GraphDatabaseService coreDB = cluster.getCoreMemberById(0).database();
            GraphDatabaseService coreDB = cluster.GetCoreMemberById(0).database();

            ExecutorService executor = Executors.newCachedThreadPool();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean done = new java.util.concurrent.atomic.AtomicBoolean(false);
            AtomicBoolean done = new AtomicBoolean(false);

            executor.execute(() =>
            {
                while (!done.get())
                {
                    try
                    {
                        using (Transaction tx = coreDB.BeginTx())
                        {
                            Node node = coreDB.CreateNode(label("boo"));
                            node.setProperty("foobar", "baz_bat");
                            tx.success();
                        }
                    }
                    catch (Exception e) when(e is AcquireLockTimeoutException || e is WriteOperationsNotAllowedException)
                    {
                        // expected sometimes
                    }
                }
            });
            Thread.Sleep(500);

            cluster.RemoveCoreMemberWithServerId(1);
            cluster.AddCoreMemberWithId(1).start();
            Thread.Sleep(500);

            // then
            done.set(true);
            executor.shutdown();
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDiscoverNewCoreMembers() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDiscoverNewCoreMembers()
        {
            // given
            int initialCoreMembers = 3;

            ClusterRule.withNumberOfCoreMembers(initialCoreMembers);
            ClusterRule.withNumberOfReadReplicas(0);

//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
            int extraCoreMembers = 2;
            int finalCoreMembers = initialCoreMembers + extraCoreMembers;

            IntStream.range(0, extraCoreMembers).forEach(idx => cluster.AddCoreMemberWithId(initialCoreMembers + idx).start());

            Matcher <IList <MemberInfo> > expected = allOf(ContainsMemberAddresses(cluster.CoreMembers()), ContainsRole(LEADER, 1), ContainsRole(FOLLOWER, finalCoreMembers - 1));

            // then
            AssertAllEventualOverviews(cluster, expected);
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readReplicaTest() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadReplicaTest()
        {
            // given
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withNumberOfCoreMembers(2).withNumberOfReadReplicas(1).startCluster();
            Cluster <object> cluster = ClusterRule.withNumberOfCoreMembers(2).withNumberOfReadReplicas(1).startCluster();

            // when
            CoreClusterMember last = cluster.CoreTx((db, tx) =>
            {
                Node node = Db.createNode(label("boo"));
                node.setProperty("foobar", "baz_bat");
                tx.success();
            });

            cluster.AddCoreMemberWithId(2).start();
            dataMatchesEventually(last, cluster.CoreMembers());
            dataMatchesEventually(last, cluster.ReadReplicas());

            cluster.Shutdown();

            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                foreach (CoreClusterMember core in cluster.CoreMembers())
                {
                    ConsistencyCheckService.Result result = (new ConsistencyCheckService()).runFullConsistencyCheck(DatabaseLayout.of(core.DatabaseDirectory()), Config.defaults(), ProgressMonitorFactory.NONE, NullLogProvider.Instance, fileSystem, false, new ConsistencyFlags(true, true, true, true, false));
                    assertTrue("Inconsistent: " + core, result.Successful);
                }

                foreach (ReadReplica readReplica in cluster.ReadReplicas())
                {
                    ConsistencyCheckService.Result result = (new ConsistencyCheckService()).runFullConsistencyCheck(DatabaseLayout.of(readReplica.DatabaseDirectory()), Config.defaults(), ProgressMonitorFactory.NONE, NullLogProvider.Instance, fileSystem, false, new ConsistencyFlags(true, true, true, true, false));
                    assertTrue("Inconsistent: " + readReplica, result.Successful);
                }
            }
        }