//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPullUpdatesOnStartupNoMatterWhat() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPullUpdatesOnStartupNoMatterWhat() { HighlyAvailableGraphDatabase slave = null; HighlyAvailableGraphDatabase master = null; try { File testRootDir = ClusterRule.cleanDirectory("shouldPullUpdatesOnStartupNoMatterWhat"); File masterDir = ClusterRule.TestDirectory.databaseDir("master"); int masterClusterPort = PortAuthority.allocatePort(); master = ( HighlyAvailableGraphDatabase )(new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(masterDir).setConfig(ClusterSettings.server_id, "1").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.initial_hosts, "localhost:" + masterClusterPort).setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase(); // Copy the store, then shutdown, so update pulling later makes sense File slaveDir = ClusterRule.TestDirectory.databaseDir("slave"); slave = ( HighlyAvailableGraphDatabase )(new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(slaveDir).setConfig(ClusterSettings.server_id, "2").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.initial_hosts, "localhost:" + masterClusterPort).setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase(); // Required to block until the slave has left for sure //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch slaveLeftLatch = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent slaveLeftLatch = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.client.ClusterClient masterClusterClient = master.getDependencyResolver().resolveDependency(org.neo4j.cluster.client.ClusterClient.class); ClusterClient masterClusterClient = master.DependencyResolver.resolveDependency(typeof(ClusterClient)); masterClusterClient.AddClusterListener(new ClusterListener_AdapterAnonymousInnerClass(this, slaveLeftLatch, masterClusterClient)); master.DependencyResolver.resolveDependency(typeof(LogService)).getInternalLog(this.GetType()).info("SHUTTING DOWN SLAVE"); slave.Shutdown(); slave = null; // Make sure that the slave has left, because shutdown() may return before the master knows assertTrue("Timeout waiting for slave to leave", slaveLeftLatch.await(60, TimeUnit.SECONDS)); long nodeId; using (Transaction tx = master.BeginTx()) { Node node = master.CreateNode(); node.SetProperty("from", "master"); nodeId = node.Id; tx.Success(); } // Store is already in place, should pull updates slave = ( HighlyAvailableGraphDatabase )(new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(slaveDir).setConfig(ClusterSettings.server_id, "2").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.initial_hosts, "localhost:" + masterClusterPort).setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(HaSettings.pull_interval, "0").setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase(); slave.BeginTx().close(); // Make sure switch to slave completes and so does the update pulling on startup using (Transaction tx = slave.BeginTx()) { assertEquals("master", slave.GetNodeById(nodeId).getProperty("from")); tx.Success(); } } finally { if (slave != null) { slave.Shutdown(); } if (master != null) { master.Shutdown(); } } }