// TODO analyzer setting must be replicates to all cluster members // TODO eventually_consistent setting must be replicated to all cluster members. //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void awaitCatchup() throws InterruptedException private void AwaitCatchup() { MutableLongSet appliedTransactions = new LongHashSet(); System.Action <ClusterMember> awaitPopulationAndCollectionAppliedTransactionId = member => { GraphDatabaseAPI db = member.database(); try { using (Transaction ignore = Db.beginTx()) { Db.schema().awaitIndexesOnline(20, TimeUnit.SECONDS); Db.execute(AWAIT_REFRESH).close(); DependencyResolver dependencyResolver = Db.DependencyResolver; TransactionIdStore transactionIdStore = dependencyResolver.resolveDependency(typeof(TransactionIdStore)); appliedTransactions.add(transactionIdStore.LastClosedTransactionId); } } catch (Exception e) when(e is QueryExecutionException || e is System.ArgumentException) { if (e.Message.Equals("No index was found")) { // Looks like the index creation hasn't been replicated yet, so we force a retry by making sure that // the 'appliedTransactions' set will definitely contain more than one element. appliedTransactions.add(-1L); appliedTransactions.add(-2L); } } catch (NotFoundException) { // This can happen due to a race inside `db.schema().awaitIndexesOnline`, where the list of indexes are provided by the SchemaCache, which is // updated during command application in commit, but the index status is then fetched from the IndexMap, which is updated when the applier is // closed during commit (which comes later in the commit process than command application). So we are told by the SchemaCache that an index // exists, but we are then also told by the IndexMap that the index does not exist, hence this NotFoundException. Normally, these two are // protected by the schema locks that are taken on index create and index status check. However, those locks are 1) incorrectly managed around // index population, and 2) those locks are NOT TAKEN in Causal Cluster command replication! // So we need to anticipate this, and if the race happens, we simply have to try again. But yeah, it needs to be fixed properly at some point. appliedTransactions.add(-1L); appliedTransactions.add(-2L); } }; do { appliedTransactions.clear(); Thread.Sleep(25); ICollection <CoreClusterMember> cores = _cluster.coreMembers(); ICollection <ReadReplica> readReplicas = _cluster.readReplicas(); cores.forEach(awaitPopulationAndCollectionAppliedTransactionId); readReplicas.forEach(awaitPopulationAndCollectionAppliedTransactionId); } while (appliedTransactions.size() != 1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldVisitChangedNodes() public virtual void ShouldVisitChangedNodes() { // GIVEN int nodes = 10; int typeId = 10; _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 2, 100, Base); _cache.NodeCount = nodes; for (long nodeId = 0; nodeId < nodes; nodeId++) { _cache.incrementCount(nodeId); if (Random.nextBoolean()) { _cache.incrementCount(nodeId); } } MutableLongSet keySparseChanged = new LongHashSet(); MutableLongSet keyDenseChanged = new LongHashSet(); for (int i = 0; i < nodes / 2; i++) { long nodeId = Random.nextLong(nodes); _cache.getAndPutRelationship(nodeId, typeId, Direction.OUTGOING, Random.nextLong(1_000_000), false); bool dense = _cache.isDense(nodeId); (dense ? keyDenseChanged : keySparseChanged).add(nodeId); } { // WHEN (sparse) NodeChangeVisitor visitor = (nodeId, array) => { // THEN (sparse) assertTrue("Unexpected sparse change reported for " + nodeId, keySparseChanged.remove(nodeId)); }; _cache.visitChangedNodes(visitor, NodeType.NODE_TYPE_SPARSE); assertTrue("There was " + keySparseChanged.size() + " expected sparse changes that weren't reported", keySparseChanged.Empty); } { // WHEN (dense) NodeChangeVisitor visitor = (nodeId, array) => { // THEN (dense) assertTrue("Unexpected dense change reported for " + nodeId, keyDenseChanged.remove(nodeId)); }; _cache.visitChangedNodes(visitor, NodeType.NODE_TYPE_DENSE); assertTrue("There was " + keyDenseChanged.size() + " expected dense changes that weren reported", keyDenseChanged.Empty); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldVisitFreelistPageIds() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldVisitFreelistPageIds() { // GIVEN a couple of released ids MutableLongSet expected = new LongHashSet(); // Add the already allocated free-list page id expected.add(BASE_ID + 1); _monitor.set(new MonitorAnonymousInnerClass(this, expected)); for (int i = 0; i < 100; i++) { long id = _freelist.acquireNewId(GENERATION_ONE, _generationTwo); _freelist.releaseId(GENERATION_ONE, _generationTwo, id); } assertTrue(expected.size() > 0); // WHEN/THEN _freelist.visitFreelist(new IdProvider_IdProviderVisitor_AdaptorAnonymousInnerClass2(this, expected)); assertTrue(expected.Empty); }