//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void relationshipIdReusableOnlyAfterTransactionFinish() public virtual void RelationshipIdReusableOnlyAfterTransactionFinish() { Label testLabel = Label.label("testLabel"); long relationshipId = CreateRelationship(testLabel); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController idMaintenanceController = getIdMaintenanceController(); IdController idMaintenanceController = IdMaintenanceController; using (Transaction transaction = DbRule.beginTx(), ResourceIterator <Node> nodes = DbRule.findNodes(testLabel)) { IList <Node> nodeList = Iterators.asList(nodes); foreach (Node node in nodeList) { IEnumerable <Relationship> relationships = node.GetRelationships(TestRelationshipType.Marker); foreach (Relationship relationship in relationships) { relationship.Delete(); } } idMaintenanceController.Maintenance(); Node node1 = DbRule.createNode(testLabel); Node node2 = DbRule.createNode(testLabel); Relationship relationshipTo = node1.CreateRelationshipTo(node2, TestRelationshipType.Marker); assertNotEquals("Relationships should have different ids.", relationshipId, relationshipTo.Id); transaction.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void relationshipIdReused() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RelationshipIdReused() { Label cityLabel = Label.label("city"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label bandLabel = org.neo4j.graphdb.Label.label("band"); Label bandLabel = Label.label("band"); CreateBands(bandLabel); CreateCities(cityLabel); AtomicBoolean stopFlag = new AtomicBoolean(false); RelationshipsCreator relationshipsCreator = new RelationshipsCreator(this, stopFlag, bandLabel, cityLabel); RelationshipRemover relationshipRemover = new RelationshipRemover(this, bandLabel, cityLabel, stopFlag); IdController idController = EmbeddedDatabase.DependencyResolver.resolveDependency(typeof(IdController)); assertNotNull("idController was null for some reason", idController); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<java.util.concurrent.Future<?>> futures = new java.util.ArrayList<>(); IList <Future <object> > futures = new List <Future <object> >(); futures.Add(_executorService.submit(relationshipRemover)); futures.Add(_executorService.submit(relationshipsCreator)); futures.Add(StartRelationshipTypesCalculator(bandLabel, stopFlag)); futures.Add(StartRelationshipCalculator(bandLabel, stopFlag)); long startTime = currentTimeMillis(); long currentTime; long createdRelationships; long removedRelationships; do { TimeUnit.MILLISECONDS.sleep(500); idController.Maintenance(); // just to make sure maintenance happens currentTime = currentTimeMillis(); createdRelationships = relationshipsCreator.CreatedRelationships; removedRelationships = relationshipRemover.RemovedRelationships; } while ((currentTime - startTime) < 5_000 || createdRelationships < 1_000 || removedRelationships < 100); stopFlag.set(true); _executorService.shutdown(); CompleteFutures(futures); long highestPossibleIdInUse = HighestUsedIdForRelationships; assertThat("Number of created relationships should be higher then highest possible id, since those are " + "reused.", relationshipsCreator.CreatedRelationships, Matchers.greaterThan(highestPossibleIdInUse)); }
private static void MaybeRunIdMaintenance(GraphDatabaseService db, int iteration) { if (iteration % 100 == 0 && ThreadLocalRandom.current().nextBoolean()) { DependencyResolver resolver = DependencyResolver(db); IdController idController = resolver.ResolveDependency(typeof(IdController)); if (idController != null) { idController.Maintenance(); } else { Console.WriteLine("Id controller is null. Dumping resolver content."); Console.WriteLine("Resolver: " + ReflectionToStringBuilder.ToString(resolver)); throw new System.InvalidOperationException("Id controller not found"); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sequentialOperationRelationshipIdReuse() public virtual void SequentialOperationRelationshipIdReuse() { Label marker = Label.label("marker"); long relationship1 = CreateRelationship(marker); long relationship2 = CreateRelationship(marker); long relationship3 = CreateRelationship(marker); assertEquals("Ids should be sequential", relationship1 + 1, relationship2); assertEquals("Ids should be sequential", relationship2 + 1, relationship3); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController idMaintenanceController = getIdMaintenanceController(); IdController idMaintenanceController = IdMaintenanceController; DeleteRelationshipByLabelAndRelationshipType(marker); idMaintenanceController.Maintenance(); assertEquals("Relationships have reused id", relationship1, CreateRelationship(marker)); assertEquals("Relationships have reused id", relationship2, CreateRelationship(marker)); assertEquals("Relationships have reused id", relationship3, CreateRelationship(marker)); }
private void IdMaintenanceOnLeader(CoreClusterMember leader) { IdController idController = ResolveDependency(leader, typeof(IdController)); idController.Maintenance(); }