Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBasicPropagationFromMasterToSlave()
        public virtual void TestBasicPropagationFromMasterToSlave()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            long nodeId = 4;
            HighlyAvailableGraphDatabase master = cluster.Master;

            using (Transaction tx = master.BeginTx())
            {
                Node node = master.CreateNode();
                node.SetProperty("Hello", "World");
                nodeId = node.Id;

                tx.Success();
            }

            cluster.Sync();

            // No need to wait, the push factor is 2
            HighlyAvailableGraphDatabase slave1 = cluster.AnySlave;

            CheckNodeOnSlave(nodeId, slave1);

            HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1);

            CheckNodeOnSlave(nodeId, slave2);
        }