//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCopyStoreFromMasterIfBranched() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCopyStoreFromMasterIfBranched() { // GIVEN File dir = _directory.directory(); ClusterManager clusterManager = _life.add(new ClusterManager.Builder(dir) .withCluster(clusterOfSize(2)).build()); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); CreateNode(cluster.Master, "A"); cluster.Sync(); // WHEN HighlyAvailableGraphDatabase slave = cluster.AnySlave; File databaseDir = slave.DatabaseLayout().databaseDirectory(); ClusterManager.RepairKit starter = cluster.Shutdown(slave); HighlyAvailableGraphDatabase master = cluster.Master; CreateNode(master, "B1"); CreateNode(master, "C"); CreateNodeOffline(databaseDir, "B2"); slave = starter.Repair(); // THEN cluster.Await(allSeesAllAsAvailable()); slave.BeginTx().close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void LastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent() { ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(3)).build(); try { clusterManager.Start(); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); RunSomeTransactions(cluster.Master); cluster.Sync(); HighlyAvailableGraphDatabase slave = cluster.AnySlave; DatabaseLayout databaseLayout = slave.DatabaseLayout(); ClusterManager.RepairKit slaveRepairKit = cluster.Shutdown(slave); ClearLastTransactionCommitTimestampField(databaseLayout); DeleteLogs(databaseLayout); HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.Repair(); cluster.Await(allSeesAllAsAvailable()); assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.UNKNOWN_TX_COMMIT_TIMESTAMP, LastCommittedTxTimestamp(repairedSlave)); } finally { clusterManager.Stop(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureUpdatePullerGetsGoingAfterMasterSwitch() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MakeSureUpdatePullerGetsGoingAfterMasterSwitch() { ClusterManager.ManagedCluster cluster = ClusterRule.withSharedSetting(HaSettings.pull_interval, PULL_INTERVAL + "ms").startCluster(); cluster.Info("### Creating initial dataset"); long commonNodeId = CreateNodeOnMaster(cluster); HighlyAvailableGraphDatabase master = cluster.Master; SetProperty(master, commonNodeId, 1); cluster.Info("### Initial dataset created"); AwaitPropagation(1, commonNodeId, cluster); cluster.Info("### Shutting down master"); ClusterManager.RepairKit masterShutdownRK = cluster.Shutdown(master); cluster.Info("### Awaiting new master"); cluster.Await(masterAvailable(master)); cluster.Await(masterSeesSlavesAsAvailable(1)); cluster.Info("### Doing a write to master"); SetProperty(cluster.Master, commonNodeId, 2); AwaitPropagation(2, commonNodeId, cluster, master); cluster.Info("### Repairing cluster"); masterShutdownRK.Repair(); cluster.Await(masterAvailable()); cluster.Await(masterSeesSlavesAsAvailable(2)); cluster.Await(allSeesAllAsAvailable()); cluster.Info("### Awaiting change propagation"); AwaitPropagation(2, commonNodeId, cluster); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void given4instanceClusterWhenMasterGoesDownThenElectNewMaster() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Given4instanceClusterWhenMasterGoesDownThenElectNewMaster() { ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(4)).build(); try { clusterManager.Start(); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); Logging.Logger.info("STOPPING MASTER"); cluster.Shutdown(cluster.Master); Logging.Logger.info("STOPPED MASTER"); cluster.Await(ClusterManager.masterAvailable()); GraphDatabaseService master = cluster.Master; Logging.Logger.info("CREATE NODE"); using (Transaction tx = master.BeginTx()) { master.CreateNode(); Logging.Logger.info("CREATED NODE"); tx.Success(); } Logging.Logger.info("STOPPING CLUSTER"); } finally { clusterManager.SafeShutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void LastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() { ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(3)).build(); try { clusterManager.Start(); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); RunSomeTransactions(cluster.Master); cluster.Sync(); HighlyAvailableGraphDatabase slave = cluster.AnySlave; DatabaseLayout databaseLayout = slave.DatabaseLayout(); ClusterManager.RepairKit slaveRepairKit = cluster.Shutdown(slave); ClearLastTransactionCommitTimestampField(databaseLayout); HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.Repair(); cluster.Await(allSeesAllAsAvailable()); assertEquals(LastCommittedTxTimestamp(cluster.Master), LastCommittedTxTimestamp(repairedSlave)); } finally { clusterManager.Stop(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void updatePullerSwitchOnNodeModeSwitch() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UpdatePullerSwitchOnNodeModeSwitch() { ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); Label firstLabel = Label.label("firstLabel"); CreateLabeledNodeOnMaster(cluster, firstLabel); // force update puller to work PullUpdatesOnSlave(cluster); // node should exist on slave now CheckLabeledNodeExistenceOnSlave(cluster, firstLabel); // verify that puller working on slave and not working on master VerifyUpdatePullerThreads(cluster); for (int i = 1; i <= 2; i++) { // switch roles in cluster - now update puller should be stopped on old slave and start on old master. ClusterManager.RepairKit repairKit = cluster.Shutdown(cluster.Master); cluster.Await(masterAvailable()); Label currentLabel = Label.label("label_" + i); CreateLabeledNodeOnMaster(cluster, currentLabel); repairKit.Repair(); cluster.Await(allSeesAllAsAvailable(), 120); // forcing updates pulling PullUpdatesOnSlave(cluster); CheckLabeledNodeExistenceOnSlave(cluster, currentLabel); // checking pulling threads VerifyUpdatePullerThreads(cluster); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void newSlaveJoiningClusterShouldNotAcceptOperationsUntilConstraintIsOnline() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void NewSlaveJoiningClusterShouldNotAcceptOperationsUntilConstraintIsOnline() { // Given ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); string type = type(4); string key = key(4); HighlyAvailableGraphDatabase master = cluster.Master; HighlyAvailableGraphDatabase slave = cluster.AnySlave; File slaveStoreDirectory = cluster.GetDatabaseDir(slave); // Crash the slave ClusterManager.RepairKit shutdownSlave = cluster.Shutdown(slave); deleteRecursively(slaveStoreDirectory); using (Transaction tx = master.BeginTx()) { CreateConstraint(master, type, key); tx.Success(); } // When slave = shutdownSlave.Repair(); // Then using (Transaction ignored = slave.BeginTx()) { ConstraintDefinition definition = GetConstraint(slave, type, key); assertThat(definition, instanceOf(ConstraintDefinitionClass())); assertThat(single(definition.PropertyKeys), equalTo(key)); ValidateLabelOrRelationshipType(definition, type); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void allClusterNodesShouldSupportTheBuiltInProcedures() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AllClusterNodesShouldSupportTheBuiltInProcedures() { ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); try { foreach (HighlyAvailableGraphDatabase gdb in cluster.AllMembers) { { // (1) BuiltInProcedures from community Result result = gdb.Execute("CALL dbms.procedures()"); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue(result.HasNext()); result.Close(); } // (2) BuiltInProcedures from enterprise using (InternalTransaction tx = gdb.BeginTransaction(KernelTransaction.Type.@explicit, EnterpriseLoginContext.AUTH_DISABLED)) { Result result = gdb.execute(tx, "CALL dbms.listQueries()", EMPTY_MAP); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue(result.HasNext()); result.Close(); tx.Success(); } } } finally { cluster.Shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleSlaveWritingFirstAfterStoryCopy() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleSlaveWritingFirstAfterStoryCopy() { // Given ISet <long> expected = new HashSet <object>(); ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); HighlyAvailableGraphDatabase master = cluster.Master; HighlyAvailableGraphDatabase slave = cluster.AnySlave; // When expected.Add(CreateOneNode(master)); cluster.Sync(); // ... crash the slave File slaveStoreDirectory = cluster.GetDatabaseDir(slave); ClusterManager.RepairKit shutdownSlave = cluster.Shutdown(slave); deleteRecursively(slaveStoreDirectory); // ... and slave copy store from master slave = shutdownSlave.Repair(); // ... and first write after crash occurs on salve expected.Add(CreateOneNode(slave)); cluster.Sync(); // Then assertEquals(expected, CollectIds(master)); assertEquals(expected, CollectIds(slave)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") private org.neo4j.kernel.impl.ha.ClusterManager.RepairKit bringSlaveOfflineAndRemoveStoreFiles(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster cluster, org.neo4j.kernel.ha.HighlyAvailableGraphDatabase slave) throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: private ClusterManager.RepairKit BringSlaveOfflineAndRemoveStoreFiles(ClusterManager.ManagedCluster cluster, HighlyAvailableGraphDatabase slave) { ClusterManager.RepairKit slaveDown = cluster.Shutdown(slave); File databaseDir = slave.DatabaseLayout().databaseDirectory(); deleteRecursively(databaseDir); databaseDir.mkdir(); return(slaveDown); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexPopulationJobsShouldContinueThroughRoleSwitch() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndexPopulationJobsShouldContinueThroughRoleSwitch() { // GIVEN a cluster of 3 ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory(); ClusterManager.ManagedCluster cluster = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, _controlledProviderDescriptor.name()).startCluster(); HighlyAvailableGraphDatabase firstMaster = cluster.Master; // where the master gets some data created as well as an index IDictionary <object, Node> data = CreateSomeData(firstMaster); CreateIndex(firstMaster); //dbFactory.awaitPopulationStarted( firstMaster ); dbFactory.TriggerFinish(firstMaster); // Pick a slave, pull the data and the index HighlyAvailableGraphDatabase aSlave = cluster.AnySlave; aSlave.DependencyResolver.resolveDependency(typeof(UpdatePuller)).pullUpdates(); // and await the index population to start. It will actually block as long as we want it to dbFactory.AwaitPopulationStarted(aSlave); // WHEN we shut down the master cluster.Shutdown(firstMaster); dbFactory.TriggerFinish(aSlave); cluster.Await(masterAvailable(firstMaster)); // get the new master, which should be the slave we pulled from above HighlyAvailableGraphDatabase newMaster = cluster.Master; // THEN assertEquals("Unexpected new master", aSlave, newMaster); using (Transaction tx = newMaster.BeginTx()) { IndexDefinition index = single(newMaster.Schema().Indexes); AwaitIndexOnline(index, newMaster, data); tx.Success(); } // FINALLY: let all db's finish foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers) { dbFactory.TriggerFinish(db); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void givenClusterWhenMasterGoesDownAndTxIsRunningThenDontWaitToSwitch() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void GivenClusterWhenMasterGoesDownAndTxIsRunningThenDontWaitToSwitch() { ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(3)).build(); try { clusterManager.Start(); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); HighlyAvailableGraphDatabase slave = cluster.AnySlave; Transaction tx = slave.BeginTx(); // Do a little write operation so that all "write" aspects of this tx is initializes properly slave.CreateNode(); // Shut down master while we're keeping this transaction open cluster.Shutdown(cluster.Master); cluster.Await(masterAvailable()); cluster.Await(masterSeesSlavesAsAvailable(1)); // Ending up here means that we didn't wait for this transaction to complete tx.Success(); try { tx.Close(); fail("Exception expected"); } catch (Exception e) { assertThat(e, instanceOf(typeof(TransientTransactionFailureException))); Exception rootCause = rootCause(e); assertThat(rootCause, instanceOf(typeof(TransactionTerminatedException))); assertThat((( TransactionTerminatedException )rootCause).status(), Matchers.equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_General.DatabaseUnavailable)); } } finally { clusterManager.Stop(); } }