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: @Before public void setUp()
        public virtual void SetUp()
        {
            TestHighlyAvailableGraphDatabaseFactory factory = new TestHighlyAvailableGraphDatabaseFactory();
            Monitors monitors = new Monitors();

            monitors.AddMonitorListener(_monitor);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            factory.RemoveKernelExtensions(extension => extension.GetType().FullName.Contains("LabelScan"));
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory("root"))).withDbFactory(factory).withMonitors(monitors).withStoreDirInitializer((serverId, storeDir) =>
            {
                if (serverId == 1)
                {
                    GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();
                    try
                    {
                        CreateSomeLabeledNodes(db, new Label[] { Labels.First }, new Label[] { Labels.First, Labels.Second }, new Label[] { Labels.Second });
                    }
                    finally
                    {
                        Db.shutdown();
                    }
                }
            }).build();

            _life.add(clusterManager);
            _life.start();
            _cluster = clusterManager.Cluster;
            _cluster.await(allSeesAllAsAvailable());
            _cluster.await(allAvailabilityGuardsReleased());
        }