Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBasicFailover() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestBasicFailover()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  master  = cluster.Master;
            HighlyAvailableGraphDatabase  slave1  = cluster.AnySlave;
            HighlyAvailableGraphDatabase  slave2  = cluster.GetAnySlave(slave1);

            // When
            long start = System.nanoTime();

            ClusterManager.RepairKit repair = cluster.Shutdown(master);
            try
            {
                Logger.Logger.warning("Shut down master");
                cluster.Await(ClusterManager.masterAvailable());
                long end = System.nanoTime();
                Logger.Logger.warning("Failover took:" + (end - start) / 1000000 + "ms");
                // Then
                bool slave1Master = slave1.Master;
                bool slave2Master = slave2.Master;
                if (slave1Master)
                {
                    assertFalse(slave2Master);
                }
                else
                {
                    assertTrue(slave2Master);
                }
            }
            finally
            {
                repair.Repair();
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMasterElectionAfterMasterRecoversInSlaveOnlyCluster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestMasterElectionAfterMasterRecoversInSlaveOnlyCluster()
        {
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            assertThat(cluster.GetServerId(cluster.Master), equalTo(new InstanceId(3)));
            HighlyAvailableGraphDatabase master = cluster.Master;

            System.Threading.CountdownEvent masterFailedLatch = CreateMasterFailLatch(cluster);
            ClusterManager.RepairKit        repairKit         = cluster.Fail(master);
            try
            {
                assertTrue(masterFailedLatch.await(60, TimeUnit.SECONDS));
            }
            finally
            {
                repairKit.Repair();
            }

            cluster.Await(allSeesAllAsAvailable());
            long nodeId = CreateNodeWithPropertyOn(cluster.AnySlave, PROPERTY, VALUE);

            using (Transaction ignore = master.BeginTx())
            {
                assertThat(master.GetNodeById(nodeId).getProperty(PROPERTY), equalTo(VALUE));
            }
        }