Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recoveryCleanupShouldBlockRecoveryWritingToCleanedIndexes() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RecoveryCleanupShouldBlockRecoveryWritingToCleanedIndexes()
        {
            // GIVEN
            AtomicReference <Exception> error = new AtomicReference <Exception>();

            try
            {
                DirtyDatabase();

                // WHEN
                Org.Neo4j.Test.Barrier_Control recoveryCompleteBarrier = new Org.Neo4j.Test.Barrier_Control();
                Org.Neo4j.Kernel.api.labelscan.LabelScanStore_Monitor recoveryBarrierMonitor = new RecoveryBarrierMonitor(this, recoveryCompleteBarrier);
                Monitor = recoveryBarrierMonitor;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> recovery = executor.submit(() ->
                Future <object> recovery = _executor.submit(() =>
                {
                    _db = StartDatabase();
                });
                recoveryCompleteBarrier.AwaitUninterruptibly();                         // Ensure we are mid recovery cleanup

                // THEN
                ShouldWait(recovery);
                recoveryCompleteBarrier.Release();
                Recovery.get();

                _db.shutdown();
            }
            finally
            {
                Exception throwable = error.get();
                if (throwable != null)
                {
                    throw throwable;
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPropagateStoreCopyActionFailureToOtherStoreCopyRequests() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPropagateStoreCopyActionFailureToOtherStoreCopyRequests()
        {
            // GIVEN
            Org.Neo4j.Test.Barrier_Control barrier           = new Org.Neo4j.Test.Barrier_Control();
            IOException controlledFailure                    = new IOException("My own fault");
            AtomicReference <Future <object> > secondRequest = new AtomicReference <Future <object> >();
            ThrowingAction <IOException>       controllableAndFailingAction = () =>
            {
                // Now that we know we're first, start the second request...
                secondRequest.set(T3.execute(state => _mutex.storeCopy(_assertNotCalled)));
                // ...and wait for it to reach its destination
                barrier.AwaitUninterruptibly();
                try
                {
                    // OK, second request has made progress into the request, so we can now produce our failure
                    throw controlledFailure;
                }
                finally
                {
                    barrier.Release();
                }
            };

            Future <object> firstRequest = T2.execute(state => _mutex.storeCopy(controllableAndFailingAction));

            while (secondRequest.get() == null)
            {
                ParkARandomWhile();
            }
            T3.get().waitUntilWaiting(details => details.isAt(typeof(StoreCopyCheckPointMutex), "waitForFirstStoreCopyActionToComplete"));

            // WHEN
            barrier.Reached();

            // THEN
            try
            {
                firstRequest.get();
            }
            catch (ExecutionException e)
            {
                assertSame(controlledFailure, e.InnerException);
            }
            try
            {
                secondRequest.get().get();
            }
            catch (ExecutionException e)
            {
                Exception cooperativeActionFailure = e.InnerException;
                assertThat(cooperativeActionFailure.Message, containsString("Co-operative"));
                assertSame(controlledFailure, cooperativeActionFailure.InnerException);
            }

            // WHEN afterwards trying another store-copy
            CountingAction action = new CountingAction();

            using (Resource @lock = _mutex.storeCopy(action))
            {
                // THEN
                assertEquals(1, action.Count());
            }
        }