//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 60_000) public void possibleToShutdownDbWhenItIsNotHealthyAndNotAllTransactionsAreApplied() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PossibleToShutdownDbWhenItIsNotHealthyAndNotAllTransactionsAreApplied() { // adversary that makes page cache throw exception when node store is used ClassGuardedAdversary adversary = new ClassGuardedAdversary(new CountingAdversary(1, true), typeof(NodeStore)); adversary.Disable(); GraphDatabaseService db = AdversarialPageCacheGraphDatabaseFactory.create(_fs, adversary).newEmbeddedDatabaseBuilder(_testDir.databaseDir()).newGraphDatabase(); System.Threading.CountdownEvent txStartLatch = new System.Threading.CountdownEvent(1); System.Threading.CountdownEvent txCommitLatch = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> result = java.util.concurrent.ForkJoinPool.commonPool().submit(() -> Future <object> result = ForkJoinPool.commonPool().submit(() => { using (Transaction tx = Db.beginTx()) { txStartLatch.Signal(); Db.createNode(); Await(txCommitLatch); tx.success(); } }); Await(txStartLatch); adversary.Enable(); txCommitLatch.Signal(); try { result.get(); fail("Exception expected"); } catch (ExecutionException ee) { // transaction is expected to fail because write through the page cache fails assertThat(ee.InnerException, instanceOf(typeof(TransactionFailureException))); } adversary.Disable(); // shutdown should complete without any problems Db.shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void concurrentlyCommittingTransactionsMustNotRotateOutLoggedCommandsOfFailingTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ConcurrentlyCommittingTransactionsMustNotRotateOutLoggedCommandsOfFailingTransaction() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.adversaries.ClassGuardedAdversary adversary = new org.neo4j.adversaries.ClassGuardedAdversary(new org.neo4j.adversaries.CountingAdversary(1, false), org.neo4j.kernel.impl.transaction.command.Command.RelationshipCommand.class); ClassGuardedAdversary adversary = new ClassGuardedAdversary(new CountingAdversary(1, false), typeof(Command.RelationshipCommand)); adversary.Disable(); File storeDir = Dir.storeDir(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,String> params = stringMap(org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory.name(), "8m"); IDictionary <string, string> @params = stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8m"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.facade.embedded.EmbeddedGraphDatabase db = new TestEmbeddedGraphDatabase(storeDir, params) EmbeddedGraphDatabase db = new TestEmbeddedGraphDatabaseAnonymousInnerClass(this, storeDir, @params, adversary); Node a; Node b; Node c; Node d; using (Transaction tx = Db.beginTx()) { a = Db.createNode(); b = Db.createNode(); c = Db.createNode(); d = Db.createNode(); tx.Success(); } adversary.Enable(); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); Thread t1 = new Thread(CreateRelationship(db, a, b, latch), "T1"); Thread t2 = new Thread(CreateRelationship(db, c, d, latch), "T2"); t1.Start(); t2.Start(); // Wait for both threads to get going t1.Join(10); t2.Join(10); latch.Signal(); // Wait for the transactions to finish t1.Join(25000); t2.Join(25000); Db.shutdown(); // We should observe the store in a consistent state EmbeddedGraphDatabase db2 = new TestEmbeddedGraphDatabase(storeDir, @params); try { using (Transaction tx = db2.BeginTx()) { Node x = db2.GetNodeById(a.Id); Node y = db2.GetNodeById(b.Id); Node z = db2.GetNodeById(c.Id); Node w = db2.GetNodeById(d.Id); IEnumerator <Relationship> itrRelX = x.Relationships.GetEnumerator(); IEnumerator <Relationship> itrRelY = y.Relationships.GetEnumerator(); IEnumerator <Relationship> itrRelZ = z.Relationships.GetEnumerator(); IEnumerator <Relationship> itrRelW = w.Relationships.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (itrRelX.hasNext() != itrRelY.hasNext()) { fail("Node x and y have inconsistent relationship counts"); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: else if (itrRelX.hasNext()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Relationship rel = itrRelX.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals(rel, itrRelY.next()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(itrRelX.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(itrRelY.hasNext()); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (itrRelZ.hasNext() != itrRelW.hasNext()) { fail("Node z and w have inconsistent relationship counts"); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: else if (itrRelZ.hasNext()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Relationship rel = itrRelZ.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals(rel, itrRelW.next()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(itrRelZ.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(itrRelW.hasNext()); } } } finally { db2.Shutdown(); } }