//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUnMapThePrestateFileWhenTimingOutOnRotationAndAllowForShutdownInTheFailedRotationState() { // Given _dbBuilder.newGraphDatabase().shutdown(); CountsTracker store = CreateCountsTracker(_pageCache, Config.defaults(GraphDatabaseSettings.counts_store_rotation_timeout, "100ms")); using (Lifespan lifespan = new Lifespan(store)) { using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = store.Apply(2).get()) { updater.IncrementNodeCount(0, 1); } try { // when store.Rotate(3); fail("should have thrown"); } catch (RotationTimeoutException) { // good } } // and also no exceptions closing the page cache _pageCache.close(); }
public virtual void Update(CountsTracker target, long txId) { using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = target.Apply(txId).get(), Org.Neo4j.Kernel.Impl.Api.CountsAccessor_IndexStatsUpdater stats = target.UpdateIndexCounts()) { _state.accept(new Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Initializer(updater, stats)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldSupportTransactionsAppliedOutOfOrderOnRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSupportTransactionsAppliedOutOfOrderOnRotation() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CountsTracker tracker = resourceManager.managed(newTracker()); CountsTracker tracker = ResourceManager.managed(NewTracker()); using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(2).get()) { tx.IncrementNodeCount(1, 1); } using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(4).get()) { tx.IncrementNodeCount(1, 1); } // when Future <long> rotated = Threading.executeAndAwait(new Rotation(2), tracker, thread => { switch (thread.State) { case BLOCKED: case WAITING: case TIMED_WAITING: case TERMINATED: return(true); default: return(false); } }, 10, SECONDS); using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(5).get()) { tx.IncrementNodeCount(1, 1); } using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(3).get()) { tx.IncrementNodeCount(1, 1); } // then assertEquals("rotated transaction", 4, rotated.get().longValue()); assertEquals("stored transaction", 4, tracker.TxId()); // the value in memory assertEquals("count", 4, tracker.NodeCount(1, Registers.newDoubleLongRegister()).readSecond()); // the value in the store CountsVisitor visitor = mock(typeof(CountsVisitor)); tracker.VisitFile(tracker.CurrentFile(), visitor); verify(visitor).visitNodeCount(1, 3); verifyNoMoreInteractions(visitor); assertEquals("final rotation", 5, tracker.Rotate(5)); }
public ProcessRelationshipCountsDataStep(StageControl control, NodeLabelsCache cache, Configuration config, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory, ProgressReporter progressReporter) : base(control, "COUNT", config, NumberOfProcessors(config, cache, highLabelId, highRelationshipTypeId)) { this._cache = cache; this._highLabelId = highLabelId; this._highRelationshipTypeId = highRelationshipTypeId; this._countsUpdater = countsUpdater; this._cacheFactory = cacheFactory; this._progressMonitor = progressReporter; }
internal NodeCountsProcessor(NodeStore nodeStore, NodeLabelsCache cache, int highLabelId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater counts, ProgressReporter progressReporter) { this._nodeStore = nodeStore; this._cache = cache; this._anyLabel = highLabelId; this._counts = counts; // Instantiate with high id + 1 since we need that extra slot for the ANY count this._labelCounts = new long[highLabelId + 1]; this._progressReporter = progressReporter; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldNotEndUpInBrokenStateAfterRotationFailure() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotEndUpInBrokenStateAfterRotationFailure() { // GIVEN FakeClock clock = Clocks.fakeClock(); CallTrackingClock callTrackingClock = new CallTrackingClock(clock); CountsTracker tracker = ResourceManager.managed(NewTracker(callTrackingClock, EmptyVersionContextSupplier.EMPTY)); int labelId = 1; using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(2).get()) { tx.IncrementNodeCount(labelId, 1); // now at 1 } // WHEN System.Predicate <Thread> arrived = thread => stackTraceContains(thread, all(classNameContains("Rotation"), methodIs("rotate"))); Future <object> rotation = Threading.executeAndAwait(t => t.rotate(4), tracker, arrived, 1, SECONDS); using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(3).get()) { tx.IncrementNodeCount(labelId, 1); // now at 2 } while (callTrackingClock.CallsToNanos() == 0) { Thread.Sleep(10); } clock.Forward(Config.defaults().get(GraphDatabaseSettings.counts_store_rotation_timeout).toMillis() * 2, MILLISECONDS); try { rotation.get(); fail("Should've failed rotation due to timeout"); } catch (ExecutionException e) { // good assertTrue(e.InnerException is RotationTimeoutException); } // THEN Org.Neo4j.Register.Register_DoubleLongRegister register = Registers.newDoubleLongRegister(); tracker.Get(CountsKeyFactory.nodeKey(labelId), register); assertEquals(2, register.ReadSecond()); // and WHEN later attempting rotation again using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(4).get()) { tx.IncrementNodeCount(labelId, 1); // now at 3 } tracker.Rotate(4); // THEN tracker.Get(CountsKeyFactory.nodeKey(labelId), register); assertEquals(3, register.ReadSecond()); }
public RelationshipCountsProcessor(NodeLabelsCache nodeLabelCache, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory) { this._nodeLabelCache = nodeLabelCache; this._client = nodeLabelCache.NewClient(); this._countsUpdater = countsUpdater; // Make room for high id + 1 since we need that extra slot for the ANY counts this._anyLabel = highLabelId; this._anyRelationshipType = highRelationshipTypeId; this._itemsPerType = _anyLabel + 1; this._itemsPerLabel = _anyRelationshipType + 1; this._labelsCounts = cacheFactory.NewLongArray(SideSize() * SIDES, 0); this._wildcardCounts = cacheFactory.NewLongArray(_anyRelationshipType + 1, 0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 30_000) public void obtainCountsStoreResetterAfterFailedTransaction() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ObtainCountsStoreResetterAfterFailedTransaction() { RecordStorageEngine engine = BuildRecordStorageEngine(); Exception applicationError = ExecuteFailingTransaction(engine); assertNotNull(applicationError); CountsTracker countsStore = engine.TestAccessNeoStores().Counts; // possible to obtain a resetting updater that internally has a write lock on the counts store using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = countsStore.Reset(0)) { assertNotNull(updater); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void allowNonDirtyInMemoryDirtyVersionRead() public virtual void AllowNonDirtyInMemoryDirtyVersionRead() { int labelId = 1; long lastClosedTransactionId = 15L; long writeTransactionId = 13L; TransactionVersionContextSupplier versionContextSupplier = new TransactionVersionContextSupplier(); versionContextSupplier.Init(() => lastClosedTransactionId); VersionContext versionContext = versionContextSupplier.VersionContext; using (Lifespan life = new Lifespan()) { CountsTracker tracker = life.Add(NewTracker(versionContextSupplier)); using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = tracker.Apply(writeTransactionId).get()) { updater.IncrementNodeCount(labelId, 1); } versionContext.InitRead(); tracker.NodeCount(labelId, Registers.newDoubleLongRegister()); assertFalse(versionContext.Dirty); } }
public RelationshipCountsStage(Configuration config, NodeLabelsCache cache, RelationshipStore relationshipStore, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory, ProgressReporter progressReporter) : base(NAME, null, config, RECYCLE_BATCHES) { Add(new BatchFeedStep(Control(), config, allIn(relationshipStore, config), relationshipStore.RecordSize)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, false, relationshipStore)); Add(new ReadRecordsStep <object>(Control(), config, false, relationshipStore)); Add(new ProcessRelationshipCountsDataStep(Control(), cache, config, highLabelId, highRelationshipTypeId, countsUpdater, cacheFactory, progressReporter)); }
public NodeCountsAndLabelIndexBuildStage(Configuration config, NodeLabelsCache cache, NodeStore nodeStore, int highLabelId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, ProgressReporter progressReporter, LabelScanStore labelIndex, params StatsProvider[] additionalStatsProviders) : base(NAME, null, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES) { Add(new BatchFeedStep(Control(), config, allIn(nodeStore, config), nodeStore.RecordSize)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, false, nodeStore)); Add(new ReadRecordsStep <object>(Control(), config, false, nodeStore)); Add(new LabelIndexWriterStep(Control(), config, labelIndex, nodeStore)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: add(new RecordProcessorStep<>(control(), "COUNT", config, new NodeCountsProcessor(nodeStore, cache, highLabelId, countsUpdater, progressReporter), true, additionalStatsProviders)); Add(new RecordProcessorStep <object>(Control(), "COUNT", config, new NodeCountsProcessor(nodeStore, cache, highLabelId, countsUpdater, progressReporter), true, additionalStatsProviders)); }