コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void coreShouldStartWithSeedHavingPartialTransactionWriteCrash() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CoreShouldStartWithSeedHavingPartialTransactionWriteCrash()
        {
            // given: a fully synced cluster with some data
            dataMatchesEventually(createEmptyNodes(_cluster, 10), _cluster.coreMembers());

            // when: shutting down a core
            CoreClusterMember core = _cluster.getCoreMemberById(0);

            core.Shutdown();

            // and making sure there will be something new to pull
            CoreClusterMember lastWrites = createEmptyNodes(_cluster, 10);

            // and writing a partial tx
            WritePartialTx(core.DatabaseDirectory());

            // and deleting the cluster state, making sure a snapshot is required during startup
            // effectively a seeding scenario -- representing the use of the unbind command on a crashed store
            _fs.deleteRecursively(core.ClusterStateDirectory());

            // then: we should still be able to start
            core.Start();

            // and become fully synced again
            dataMatchesEventually(lastWrites, singletonList(core));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void actuallyDeletesTheFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ActuallyDeletesTheFiles()
        {
            // 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();

            CoreClusterMember coreGraphDatabase = null;
            int txs = 10;

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

            // when pruning kicks in then some files are actually deleted
            File raftLogDir = coreGraphDatabase.RaftLogDirectory();
            int  expectedNumberOfLogFilesAfterPruning = 2;

            assertEventually("raft logs eventually pruned", () => NumberOfFiles(raftLogDir), equalTo(expectedNumberOfLogFilesAfterPruning), 5, TimeUnit.SECONDS);
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.util.Optional<java.io.File> generate(java.io.File backupDir, org.neo4j.causalclustering.discovery.Cluster<?> backupCluster) throws Exception
        public override Optional <File> Generate <T1>(File backupDir, Cluster <T1> backupCluster)
        {
            CoreClusterMember core = CreateData(backupCluster);
            File backupFromCore    = createBackupFromCore(core, BackupName(), backupDir);

            Modify(backupFromCore);
            return(backupFromCore);
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreateBufferedIdComponentsByDefault()
        {
            Cluster            cluster            = ClusterRule.startCluster();
            CoreClusterMember  leader             = cluster.awaitLeader();
            DependencyResolver dependencyResolver = leader.Database().DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(FreeIdFilteredIdGeneratorFactory)));
        }
コード例 #5
0
        public static long CountNodes(CoreClusterMember member)
        {
            CoreGraphDatabase db = member.Database();
            long count;

            using (Transaction tx = Db.beginTx())
            {
                count = count(Db.AllNodes);
                tx.Success();
            }
            return(count);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetupClusterWithIPv6() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetupClusterWithIPv6()
        {
            // given
            int numberOfNodes = 10;

            // when
            CoreClusterMember leader = DataCreator.createEmptyNodes(_cluster, numberOfNodes);

            // then
            assertEquals(numberOfNodes, countNodes(leader));
            dataMatchesEventually(leader, _cluster.coreMembers());
            dataMatchesEventually(leader, _cluster.readReplicas());
        }
コード例 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.causalclustering.discovery.CoreClusterMember createEmptyNodes(org.neo4j.causalclustering.discovery.Cluster<?> cluster, int numberOfNodes) throws Exception
        public static CoreClusterMember CreateEmptyNodes <T1>(Cluster <T1> cluster, int numberOfNodes)
        {
            CoreClusterMember last = null;

            for (int i = 0; i < numberOfNodes; i++)
            {
                last = cluster.CoreTx((db, tx) =>
                {
                    Db.createNode();
                    tx.success();
                });
            }
            return(last);
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreateBufferedIdComponentsByDefault()
        {
//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();
            CoreClusterMember  leader             = cluster.AwaitLeader();
            DependencyResolver dependencyResolver = leader.Database().DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(FreeIdFilteredIdGeneratorFactory)));
        }
コード例 #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.causalclustering.discovery.CoreClusterMember createLabelledNodesWithProperty(org.neo4j.causalclustering.discovery.Cluster<?> cluster, int numberOfNodes, org.neo4j.graphdb.Label label, System.Func<org.neo4j.helpers.collection.Pair<String,Object>> propertyPair) throws Exception
        public static CoreClusterMember CreateLabelledNodesWithProperty <T1>(Cluster <T1> cluster, int numberOfNodes, Label label, System.Func <Pair <string, object> > propertyPair)
        {
            CoreClusterMember last = null;

            for (int i = 0; i < numberOfNodes; i++)
            {
                last = cluster.CoreTx((db, tx) =>
                {
                    Node node = Db.createNode(label);
                    node.setProperty(propertyPair().first(), propertyPair().other());
                    tx.success();
                });
            }
            return(last);
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMonitorMessageDelay() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMonitorMessageDelay()
        {
            // given
            _cluster = ClusterRule.startCluster();

            // then
            CoreClusterMember leader = _cluster.awaitLeader();
            File coreMetricsDir      = new File(leader.HomeDir(), csvPath.DefaultValue);

            assertEventually("message delay eventually recorded", () => readLongValue(metricsCsv(coreMetricsDir, CoreMetrics.DELAY)), greaterThanOrEqualTo(0L), TIMEOUT, TimeUnit.SECONDS);

            assertEventually("message timer count eventually recorded", () => readTimerLongValueAndAssert(metricsCsv(coreMetricsDir, CoreMetrics.TIMER), (newValue, currentValue) => newValue >= currentValue, MetricsTestHelper.TimerField.Count), greaterThan(0L), TIMEOUT, TimeUnit.SECONDS);

            assertEventually("message timer max eventually recorded", () => readTimerDoubleValue(metricsCsv(coreMetricsDir, CoreMetrics.TIMER), MetricsTestHelper.TimerField.Max), greaterThanOrEqualTo(0d), TIMEOUT, TimeUnit.SECONDS);
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStartElectionIfLeaderRemoved() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStartElectionIfLeaderRemoved()
        {
            // 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();
            CoreClusterMember oldLeader = cluster.AwaitLeader();

            // when
            cluster.RemoveCoreMember(oldLeader);

            // then
            CoreClusterMember newLeader = cluster.AwaitLeader();

            assertThat(newLeader.ServerId(), not(equalTo(oldLeader.ServerId())));
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldElectANewLeaderIfAServerRefusesToBeLeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldElectANewLeaderIfAServerRefusesToBeLeader()
        {
            // given
            ClusterRule.withInstanceCoreParam(CausalClusteringSettings.refuse_to_be_leader, this.firstServerRefusesToBeLeader).withSharedCoreParam(CausalClusteringSettings.multi_dc_license, "true");
//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();
            CoreClusterMember oldLeader = cluster.AwaitLeader();

            // when
            cluster.RemoveCoreMember(oldLeader);

            // then
            CoreClusterMember newLeader = cluster.AwaitLeader();

            assertThat(newLeader.ServerId(), not(equalTo(oldLeader.ServerId())));
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotStartAnElectionIfAMinorityOfServersHaveTimedOutOnHeartbeats() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotStartAnElectionIfAMinorityOfServersHaveTimedOutOnHeartbeats()
        {
            // 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();
            CoreClusterMember follower = cluster.AwaitCoreMemberWithRole(Role.FOLLOWER, 1, TimeUnit.MINUTES);

            // when
            follower.Raft().triggerElection(Clock.systemUTC());

            // then
            try
            {
                cluster.AwaitCoreMemberWithRole(Role.CANDIDATE, 1, TimeUnit.MINUTES);
                fail("Should not have started an election if less than a quorum have timed out");
            }
            catch (TimeoutException)
            {
                // pass
            }
        }
コード例 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void coreShouldStartAfterPartialTransactionWriteCrash() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CoreShouldStartAfterPartialTransactionWriteCrash()
        {
            // given: a fully synced cluster with some data
            dataMatchesEventually(createEmptyNodes(_cluster, 10), _cluster.coreMembers());

            // when: shutting down a core
            CoreClusterMember core = _cluster.getCoreMemberById(0);

            core.Shutdown();

            // and making sure there will be something new to pull
            CoreClusterMember lastWrites = createEmptyNodes(_cluster, 10);

            // and writing a partial tx
            WritePartialTx(core.DatabaseDirectory());

            // then: we should still be able to start
            core.Start();

            // and become fully synced again
            dataMatchesEventually(lastWrites, singletonList(core));
        }
コード例 #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long warmUpCluster() throws Exception
		 private long WarmUpCluster()
		 {
			  _leader = _cluster.awaitLeader(); // Make sure we have a cluster leader.
			  _cluster.coreTx((db, tx) =>
			  {
				// Create some test data to touch a bunch of pages.
				CreateTestData( db );
				tx.success();
			  });
			  AtomicLong pagesInMemory = new AtomicLong();
			  _cluster.coreTx((db, tx) =>
			  {
				// Wait for an initial profile on the leader. This profile might have raced with the 'createTestData'
				// transaction above, so it might be incomplete.
				WaitForCacheProfile( _leader.monitors() );
				// Now we can wait for a clean profile on the leader, and note the count for verifying later.
				pagesInMemory.set( WaitForCacheProfile( _leader.monitors() ) );
			  });
			  foreach ( CoreClusterMember member in _cluster.coreMembers() )
			  {
					WaitForCacheProfile( member.Monitors() );
			  }
			  return pagesInMemory.get();
		 }
コード例 #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cacheProfilesMustBeIncludedInStoreCopyToCore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void CacheProfilesMustBeIncludedInStoreCopyToCore()
		 {
			  long pagesInMemory = WarmUpCluster();
			  CoreClusterMember member = _cluster.newCoreMember();
			  VerifyWarmupHappensAfterStoreCopy( member, pagesInMemory );
		 }
コード例 #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static java.io.File createBackupFromCore(org.neo4j.causalclustering.discovery.CoreClusterMember core, String backupName, java.io.File baseBackupDir) throws Exception
        public static File CreateBackupFromCore(CoreClusterMember core, string backupName, File baseBackupDir)
        {
            string[] args = backupArguments(BackupAddress(core), baseBackupDir, backupName);
            assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(baseBackupDir, args));
            return(new File(baseBackupDir, backupName));
        }
コード例 #18
0
 private static string BackupAddress(CoreClusterMember core)
 {
     return(core.SettingValue("causal_clustering.transaction_listen_address"));
 }