//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void writeOneIteration(TestCoordinator testCoordinator, java.util.concurrent.atomic.AtomicBoolean failHalt) throws java.io.IOException, InterruptedException private void WriteOneIteration(TestCoordinator testCoordinator, AtomicBoolean failHalt) { int batchSize = testCoordinator.WriteBatchSize(); IEnumerable <UpdateOperation> toWrite = testCoordinator.NextToWrite(); IEnumerator <UpdateOperation> toWriteIterator = toWrite.GetEnumerator(); while (toWriteIterator.MoveNext()) { using (Writer <KEY, VALUE> writer = _index.writer()) { int inBatch = 0; while (toWriteIterator.MoveNext() && inBatch < batchSize) { UpdateOperation operation = toWriteIterator.Current; operation.Apply(writer); if (failHalt.get()) { break; } inBatch++; } } // Sleep to allow checkpointer to step in MILLISECONDS.sleep(1); } }
internal RunnableReader(GBPTreeConcurrencyITBase <KEY, VALUE> outerInstance, TestCoordinator testCoordinator, System.Threading.CountdownEvent readerReadySignal, System.Threading.CountdownEvent readerStartSignal, AtomicBoolean endSignal, AtomicBoolean failHalt, AtomicReference <Exception> readerError) { this._outerInstance = outerInstance; this.ReaderReadySignal = readerReadySignal; this.ReaderStartSignal = readerStartSignal; this.EndSignal = endSignal; this.FailHalt = failHalt; this.ReaderError = readerError; this.TestCoordinator = testCoordinator; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void write(TestCoordinator testCoordinator, java.util.concurrent.CountDownLatch readerReadySignal, java.util.concurrent.CountDownLatch readerStartSignal, java.util.concurrent.atomic.AtomicBoolean endSignal, java.util.concurrent.atomic.AtomicBoolean failHalt) throws InterruptedException, java.io.IOException private void Write(TestCoordinator testCoordinator, System.Threading.CountdownEvent readerReadySignal, System.Threading.CountdownEvent readerStartSignal, AtomicBoolean endSignal, AtomicBoolean failHalt) { assertTrue(readerReadySignal.await(10, SECONDS)); // Ready, set... readerStartSignal.Signal(); // GO! while (!failHalt.get() && !endSignal.get()) { WriteOneIteration(testCoordinator, failHalt); testCoordinator.IterationFinished(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldReadCorrectlyWithConcurrentUpdates(TestCoordinator testCoordinator) throws Throwable private void ShouldReadCorrectlyWithConcurrentUpdates(TestCoordinator testCoordinator) { // Readers config int readers = max(1, Runtime.Runtime.availableProcessors() - 1); // Thread communication System.Threading.CountdownEvent readerReadySignal = new System.Threading.CountdownEvent(readers); System.Threading.CountdownEvent readerStartSignal = new System.Threading.CountdownEvent(1); AtomicBoolean endSignal = testCoordinator.EndSignal(); AtomicBoolean failHalt = new AtomicBoolean(); // Readers signal to writer that there is a failure AtomicReference <Exception> readerError = new AtomicReference <Exception>(); // GIVEN _index = CreateIndex(); testCoordinator.Prepare(_index); // WHEN starting the readers RunnableReader readerTask = new RunnableReader(this, testCoordinator, readerReadySignal, readerStartSignal, endSignal, failHalt, readerError); for (int i = 0; i < readers; i++) { _threadPool.submit(readerTask); } // and starting the checkpointer _threadPool.submit(CheckpointThread(endSignal, readerError, failHalt)); // and starting the writer try { Write(testCoordinator, readerReadySignal, readerStartSignal, endSignal, failHalt); } finally { // THEN no reader should have failed by the time we have finished all the scheduled updates. // A successful read means that all results were ordered and we saw all inserted values and // none of the removed values at the point of making the seek call. endSignal.set(true); _threadPool.shutdown(); _threadPool.awaitTermination(10, TimeUnit.SECONDS); if (readerError.get() != null) { //noinspection ThrowFromFinallyBlock throw readerError.get(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadBackwardCorrectlyWithConcurrentUpdates() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadBackwardCorrectlyWithConcurrentUpdates() { TestCoordinator testCoordinator = new TestCoordinator(this, _random.random(), false, 0.5); ShouldReadCorrectlyWithConcurrentUpdates(testCoordinator); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadForwardCorrectlyWithConcurrentRemove() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadForwardCorrectlyWithConcurrentRemove() { TestCoordinator testCoordinator = new TestCoordinator(this, _random.random(), true, 0); ShouldReadCorrectlyWithConcurrentUpdates(testCoordinator); }