//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()); }
private long Get(CountsTracker store, CountsKey key) { Org.Neo4j.Register.Register_DoubleLongRegister value = Registers.newDoubleLongRegister(); store.Get(key, value); return(value.ReadSecond()); }