예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void masterRejoinsAfterFailureAndReelection() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MasterRejoinsAfterFailureAndReelection()
        {
            // Given
            HighlyAvailableGraphDatabase initialMaster = _cluster.Master;

            // When
            _cluster.info("Fail master");
            ClusterManager.RepairKit kit = _cluster.fail(initialMaster);

            _cluster.info("Wait for 2 to become master and 3 slave");
            _cluster.await(masterAvailable(initialMaster));
            _cluster.await(masterSeesSlavesAsAvailable(1));

            _cluster.info("Repair 1");
            kit.Repair();

            // Then
            _cluster.info("Wait for cluster recovery");
            _cluster.await(masterAvailable());
            _cluster.await(allSeesAllAsAvailable());
            assertEquals(3, _cluster.size());
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void isolatedMasterShouldRemoveSelfFromClusterAndBecomeReadOnly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IsolatedMasterShouldRemoveSelfFromClusterAndBecomeReadOnly()
        {
            int clusterSize = 3;

            ClusterManager manager = (new ClusterManager.Builder()).withRootDirectory(Dir.cleanDirectory("testcluster")).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();

            try
            {
                manager.Start();
                ClusterManager.ManagedCluster cluster = manager.Cluster;

                cluster.Await(allSeesAllAsAvailable());
                cluster.Await(masterAvailable());

                HighlyAvailableGraphDatabase oldMaster = cluster.Master;

                System.Threading.CountdownEvent masterTransitionLatch = new System.Threading.CountdownEvent(1);
                SetupForWaitOnSwitchToDetached(oldMaster, masterTransitionLatch);

                AddSomeData(oldMaster);

                ClusterManager.RepairKit fail = cluster.fail(oldMaster, Enum.GetValues(typeof(ClusterManager.NetworkFlag)));
                cluster.Await(instanceEvicted(oldMaster), 20);

                masterTransitionLatch.await();

                EnsureInstanceIsReadOnlyInPendingState(oldMaster);

                fail.Repair();

                cluster.Await(allSeesAllAsAvailable());

                EnsureInstanceIsWritable(oldMaster);
            }
            finally
            {
                manager.SafeShutdown();
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void aPendingMemberShouldBeAbleToServeReads() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void APendingMemberShouldBeAbleToServeReads()
        {
            // given
            CreateNodeOnMaster(_testLabel, _cluster.Master);
            _cluster.sync();

            HighlyAvailableGraphDatabase slave = _cluster.AnySlave;

            _cluster.fail(slave, Enum.GetValues(typeof(ClusterManager.NetworkFlag)));
            _cluster.await(instanceEvicted(slave));

            assertEquals(PENDING, slave.InstanceState);

            // when
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    using (Transaction tx = slave.BeginTx())
                    {
                        Node  single = Iterables.single(slave.AllNodes);
                        Label label  = Iterables.single(single.Labels);
                        assertEquals(_testLabel, label);
                        tx.Success();
                        break;
                    }
                }
                catch (TransactionTerminatedException)
                {
                    // Race between going to pending and reading, try again in a little while
                    Thread.Sleep(1_000);
                }
            }

            // then no exceptions thrown
        }