//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleBeingAbortedWhileMerging() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleBeingAbortedWhileMerging() { // given TrappingMonitor monitor = new TrappingMonitor(numberOfBlocks => numberOfBlocks == 2); BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(monitor); bool closed = false; try { populator.Add(BatchOfUpdates()); // when starting to merge (in a separate thread) Future <object> mergeFuture = T2.execute(command(() => populator.scanCompleted(nullInstance))); // and waiting for merge to get going monitor.Barrier.await(); monitor.Barrier.release(); monitor.MergeFinishedBarrier.awaitUninterruptibly(); // calling close here should wait for the merge future, so that checking the merge future for "done" immediately afterwards must say true Future <object> closeFuture = T3.execute(command(() => populator.close(false))); T3.get().waitUntilWaiting(); monitor.MergeFinishedBarrier.release(); closeFuture.get(); closed = true; // then let's make sure scanComplete was cancelled, not throwing exception or anything. mergeFuture.get(); } finally { if (!closed) { populator.Close(false); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportAccurateProgressThroughoutThePhases() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportAccurateProgressThroughoutThePhases() { // given TrappingMonitor monitor = new TrappingMonitor(numberOfBlocks => numberOfBlocks == 1); BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(monitor); try { populator.Add(BatchOfUpdates()); // when starting to merge (in a separate thread) Future <object> mergeFuture = T2.execute(command(() => populator.scanCompleted(nullInstance))); // and waiting for merge to get going monitor.Barrier.awaitUninterruptibly(); // this is a bit fuzzy, but what we want is to assert that the scan doesn't represent 100% of the work assertEquals(0.5f, populator.Progress(Org.Neo4j.Storageengine.Api.schema.PopulationProgress_Fields.Done).Progress, 0.1f); monitor.Barrier.release(); monitor.MergeFinishedBarrier.awaitUninterruptibly(); assertEquals(0.7f, populator.Progress(Org.Neo4j.Storageengine.Api.schema.PopulationProgress_Fields.Done).Progress, 0.1f); monitor.MergeFinishedBarrier.release(); mergeFuture.get(); assertEquals(1f, populator.Progress(Org.Neo4j.Storageengine.Api.schema.PopulationProgress_Fields.Done).Progress, 0f); } finally { populator.Close(true); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAwaitMergeToBeFullyAbortedBeforeLeavingCloseMethod() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAwaitMergeToBeFullyAbortedBeforeLeavingCloseMethod() { // given TrappingMonitor monitor = new TrappingMonitor(ignore => false); BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(monitor); bool closed = false; try { populator.Add(BatchOfUpdates()); // when starting to merge (in a separate thread) Future <object> mergeFuture = T2.execute(command(() => populator.scanCompleted(nullInstance))); // and waiting for merge to get going monitor.Barrier.awaitUninterruptibly(); // calling close here should wait for the merge future, so that checking the merge future for "done" immediately afterwards must say true Future <object> closeFuture = T3.execute(command(() => populator.close(false))); T3.get().waitUntilWaiting(); monitor.Barrier.release(); closeFuture.get(); closed = true; // then assertTrue(mergeFuture.Done); } finally { if (!closed) { populator.Close(true); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDeleteDirectoryOnDrop() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDeleteDirectoryOnDrop() { // given TrappingMonitor monitor = new TrappingMonitor(ignore => false); BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(monitor); bool closed = false; try { populator.Add(BatchOfUpdates()); // when starting to merge (in a separate thread) Future <object> mergeFuture = T2.execute(command(() => populator.scanCompleted(nullInstance))); // and waiting for merge to get going monitor.Barrier.awaitUninterruptibly(); // calling drop here should wait for the merge future and then delete index directory assertTrue(_fs.fileExists(_indexDir)); assertTrue(_fs.isDirectory(_indexDir)); assertTrue(_fs.listFiles(_indexDir).Length > 0); Future <object> dropFuture = T3.execute(command(populator.drop)); T3.get().waitUntilWaiting(); monitor.Barrier.release(); dropFuture.get(); closed = true; // then assertTrue(mergeFuture.Done); assertFalse(_fs.fileExists(_indexDir)); } finally { if (!closed) { populator.Close(true); } } }