예제 #1
0
		 private HighlyAvailableGraphDatabase GetNthSlave( ClusterManager.ManagedCluster cluster, int slaveOrder )
		 {
			  Debug.Assert( slaveOrder > 0 );
			  HighlyAvailableGraphDatabase slave = null;

			  IList<HighlyAvailableGraphDatabase> excluded = new List<HighlyAvailableGraphDatabase>();
			  while ( slaveOrder-- > 0 )
			  {
					slave = cluster.GetAnySlave( ToArray( excluded ) );
					excluded.Add( slave );
			  }

			  return slave;
		 }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void Setup()
            {
                // setup a cluster with some data and entries in log files in fully functional and shutdown state
                ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

                try
                {
                    cluster.Await(allSeesAllAsAvailable());

                    OldMaster = cluster.Master;
                    CreateSomeData(OldMaster);
                    cluster.Sync();

                    OldSlave1 = cluster.AnySlave;
                    OldSlave2 = cluster.GetAnySlave(OldSlave1);
                }
                finally
                {
                    ClusterRule.shutdownCluster();
                }
                AssertAllStoreConsistent(cluster);
            }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void losingQuorumAbruptlyShouldMakeAllInstancesPendingAndReadOnly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LosingQuorumAbruptlyShouldMakeAllInstancesPendingAndReadOnly()
        {
            int clusterSize = 5;               // we need 5 to differentiate between all other instances gone and just quorum being gone

            assumeTrue(TestRunConditions.shouldRunAtClusterSize(clusterSize));

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

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

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

                HighlyAvailableGraphDatabase master = cluster.Master;
                AddSomeData(master);

                /*
                 * we need 3 failures. We'll end up with the old master and a slave connected. They should both be in
                 * PENDING state, allowing reads but not writes. Repairing just one of the removed instances should
                 * result in a master being elected and all instances being read and writable.
                 * The instances we remove do not need additional verification for their state. Their behaviour is already
                 * known by other tests.
                 */
                HighlyAvailableGraphDatabase failed1;
                ClusterManager.RepairKit     rk1;
                HighlyAvailableGraphDatabase failed2;
                HighlyAvailableGraphDatabase failed3;
                HighlyAvailableGraphDatabase remainingSlave;

                failed1        = cluster.AnySlave;
                failed2        = cluster.GetAnySlave(failed1);
                failed3        = cluster.GetAnySlave(failed1, failed2);
                remainingSlave = cluster.GetAnySlave(failed1, failed2, failed3);

                System.Threading.CountdownEvent masterTransitionLatch = new System.Threading.CountdownEvent(1);
                System.Threading.CountdownEvent slaveTransitionLatch  = new System.Threading.CountdownEvent(1);

                SetupForWaitOnSwitchToDetached(master, masterTransitionLatch);
                SetupForWaitOnSwitchToDetached(remainingSlave, slaveTransitionLatch);

                rk1 = KillAbruptly(cluster, failed1, failed2, failed3);

                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed1));
                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed2));
                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed3));

                cluster.Await(memberSeesOtherMemberAsFailed(master, failed1));
                cluster.Await(memberSeesOtherMemberAsFailed(master, failed2));
                cluster.Await(memberSeesOtherMemberAsFailed(master, failed3));

                masterTransitionLatch.await();
                slaveTransitionLatch.await();

                EnsureInstanceIsReadOnlyInPendingState(master);
                EnsureInstanceIsReadOnlyInPendingState(remainingSlave);

                rk1.Repair();

                cluster.Await(masterAvailable(failed2, failed3));
                cluster.Await(masterSeesSlavesAsAvailable(2));

                EnsureInstanceIsWritable(master);
                EnsureInstanceIsWritable(remainingSlave);
                EnsureInstanceIsWritable(failed1);
            }
            finally
            {
                manager.Shutdown();
            }
        }