コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 10_000) public void shouldWaitForCompletionInHalt() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWaitForCompletionInHalt()
        {
            // GIVEN
            PageCache pageCache = mock(typeof(PageCache));

            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
            doAnswer(invocation =>
            {
                barrier.Reached();
                return(null);
            }).when(pageCache).flushAndForce();
            PageCacheFlusher flusher = new PageCacheFlusher(pageCache);

            flusher.Start();

            // WHEN
            barrier.Await();
            Future <object> halt = T2.execute(state =>
            {
                flusher.Halt();
                return(null);
            });

            T2.get().waitUntilWaiting(details => details.isAt(typeof(PageCacheFlusher), "halt"));
            barrier.Release();

            // THEN halt call exits normally after (confirmed) ongoing flushAndForce call completed.
            halt.get();
        }
コード例 #2
0
 public AbstractHandlerAnonymousInnerClass(DoubleLatch latch, Org.Neo4j.Test.Barrier_Control innerBarrier, int firstBatchSize, int otherBatchSize)
 {
     this._latch          = latch;
     this._innerBarrier   = innerBarrier;
     this._firstBatchSize = firstBatchSize;
     this._otherBatchSize = otherBatchSize;
 }
コード例 #3
0
        public static Server CreateHttpServer(DoubleLatch latch, Org.Neo4j.Test.Barrier_Control innerBarrier, int firstBatchSize, int otherBatchSize)
        {
            Server server = new Server(0);

            server.Handler = new AbstractHandlerAnonymousInnerClass(latch, innerBarrier, firstBatchSize, otherBatchSize);
            return(server);
        }
コード例 #4
0
 internal virtual void Initialize(int numberOfUpdateTrackers)
 {
     UpdateTrackerCompletionLatch = new System.Threading.CountdownEvent(numberOfUpdateTrackers);
     if (numberOfUpdateTrackers > 0)
     {
         Barrier = new Org.Neo4j.Test.Barrier_Control();
     }
 }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void recoverFromConstraintAppliedBeforeCrash(System.Action<org.neo4j.kernel.internal.GraphDatabaseAPI> constraintCreator) throws Exception
        private void RecoverFromConstraintAppliedBeforeCrash(System.Action <GraphDatabaseAPI> constraintCreator)
        {
            IList <TransactionRepresentation> transactions = CreateTransactionsForCreatingConstraint(constraintCreator);
            EphemeralFileSystemAbstraction    crashSnapshot;
            {
                GraphDatabaseAPI db = NewDb();
                Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
                _monitors.addMonitorListener(new MonitorAdapterAnonymousInnerClass(this, barrier));
                try
                {
                    // Create two nodes that have duplicate property values
                    string value = "v";
                    using (Transaction tx = Db.beginTx())
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            Db.createNode(LABEL).setProperty(KEY, value);
                        }
                        tx.Success();
                    }
                    T2.execute(state =>
                    {
                        Apply(db, transactions.subList(0, transactions.Count - 1));
                        return(null);
                    });
                    barrier.Await();
                    FlushStores(db);
                    // Crash before index population have discovered that there are duplicates
                    // (nowadays happens in between index population and creating the constraint)
                    crashSnapshot = Fs.snapshot();
                    barrier.Release();
                }
                finally
                {
                    Db.shutdown();
                }
            }

            {
                // WHEN
                GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestEnterpriseGraphDatabaseFactory()).setFileSystem(crashSnapshot).newImpermanentDatabase();
                try
                {
                    Recreate(constraintCreator).accept(db, transactions);
                    fail("Should not be able to create constraint on non-unique data");
                }
                catch (Exception e) when(e is ConstraintViolationException || e is QueryExecutionException)
                {
                    // THEN good
                }
                finally
                {
                    Db.shutdown();
                }
            }
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToReadUpToDateValueWhileAnotherThreadIsPerformingRotation()
        {
            // given
            CountsOracle oracle            = SomeData();
            const int    firstTransaction  = 2;
            int          secondTransaction = 3;

            using (Lifespan life = new Lifespan())
            {
                CountsTracker tracker = life.Add(NewTracker());
                oracle.Update(tracker, firstTransaction);
                tracker.Rotate(firstTransaction);
            }

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.CountsOracle delta = new org.neo4j.kernel.impl.store.CountsOracle();
            CountsOracle delta = new CountsOracle();

            {
                CountsOracle.Node n1 = delta.Node(1);
                CountsOracle.Node n2 = delta.Node(1, 4);                 // Label 4 has not been used before...
                delta.Relationship(n1, 1, n2);
                delta.Relationship(n2, 2, n1);                           // relationshipType 2 has not been used before...
            }
            delta.Update(oracle);

            using (Lifespan life = new Lifespan())
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
                Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
                CountsTracker tracker = life.Add(new CountsTrackerAnonymousInnerClass(this, ResourceManager.logProvider(), ResourceManager.fileSystem(), ResourceManager.pageCache(), Config.defaults(), EmptyVersionContextSupplier.EMPTY, barrier));
                Future <Void> task    = Threading.execute(t =>
                {
                    try
                    {
                        delta.Update(t, secondTransaction);
                        t.rotate(secondTransaction);
                    }
                    catch (IOException e)
                    {
                        throw new AssertionError(e);
                    }
                    return(null);
                }, tracker);

                // then
                barrier.Await();
                oracle.Verify(tracker);
                barrier.Release();
                task.get();
                oracle.Verify(tracker);
            }
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAwaitCompletionOfAllTasks() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldAwaitCompletionOfAllTasks()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TaskCoordinator coordinator = new TaskCoordinator(1, java.util.concurrent.TimeUnit.MILLISECONDS);
            TaskCoordinator coordinator = new TaskCoordinator(1, TimeUnit.MILLISECONDS);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> state = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <string> state = new AtomicReference <string>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<String> states = new java.util.ArrayList<>();
            IList <string> states = new List <string>();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseA = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control phaseA = new Org.Neo4j.Test.Barrier_Control();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseB = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control phaseB = new Org.Neo4j.Test.Barrier_Control();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseC = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control phaseC = new Org.Neo4j.Test.Barrier_Control();

            state.set("A");
            new Thread("awaitCompletion" () =>
            {
                try
                {
                    states.Add(state.get());                         // expects A
                    phaseA.Reached();
                    states.Add(state.get());                         // expects B
                    phaseB.Await();
                    phaseB.Release();
                    coordinator.AwaitCompletion();
                    states.Add(state.get());                         // expects C
                    phaseC.Reached();
                }
                catch (InterruptedException e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }
            });
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenDatabaseAndStartedTxWhenShutdownThenWaitForTxToFinish() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenDatabaseAndStartedTxWhenShutdownThenWaitForTxToFinish()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final GraphDatabaseService db = getTemporaryDatabase();
            GraphDatabaseService db = TemporaryDatabase;

            // When
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
            Future <object> txFuture = _t2.execute(state =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    barrier.Reached();
                    Db.createNode();
                    tx.Success();
                }
                return(null);
            });

            // i.e. wait for transaction to start
            barrier.Await();

            // now there's a transaction open, blocked on continueTxSignal
            Future <object> shutdownFuture = _t3.execute(state =>
            {
                Db.shutdown();
                return(null);
            });

            _t3.get().waitUntilWaiting(location => location.isAt(typeof(DatabaseAvailability), "stop"));
            barrier.Release();
            try
            {
                txFuture.get();
            }
            catch (ExecutionException)
            {
                // expected
            }
            shutdownFuture.get();
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenDatabaseAndStartedTxWhenShutdownAndStartNewTxThenBeginTxTimesOut() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenDatabaseAndStartedTxWhenShutdownAndStartNewTxThenBeginTxTimesOut()
        {
            // Given
            GraphDatabaseService db = TemporaryDatabase;

            // When
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
            _t2.execute(state =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    barrier.Reached();                      // <-- this triggers t3 to start a db.shutdown()
                }
                return(null);
            });

            barrier.Await();
            Future <object> shutdownFuture = _t3.execute(state =>
            {
                Db.shutdown();
                return(null);
            });

            _t3.get().waitUntilWaiting(location => location.isAt(typeof(DatabaseAvailability), "stop"));
            barrier.Release();               // <-- this triggers t2 to continue its transaction
            shutdownFuture.get();

            try
            {
                Db.beginTx();
                fail("Should fail");
            }
            catch (DatabaseShutdownException)
            {
                //THEN good
            }
        }
コード例 #10
0
ファイル: RecoveryCleanupIT.cs プロジェクト: Neo4Net/Neo4Net
//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;
                }
            }
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotSeeFreedIdsCrossRoleSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotSeeFreedIdsCrossRoleSwitch()
        {
            // GIVEN
            ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase firstMaster = cluster.Master;

            // WHEN
            // a node with a property
            Node node = CreateNodeWithProperties(firstMaster, 1);

            // sync cluster
            cluster.Sync();
            // a transaction on master which deletes the property
            DeleteNode(node, firstMaster);
            TriggerIdMaintenance(firstMaster);
            CreateNodeWithProperties(firstMaster, 1);                 // <-- this one reuses the same property id 0
            // a transaction T on slave which will be kept open using a barrier
            GraphDatabaseAPI slave = cluster.AnySlave;

            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();
            Future <Void> t = T2.execute(BarrierControlledReadTransaction(slave, barrier));

            // pull updates on slave
            barrier.Await();
            slave.DependencyResolver.resolveDependency(typeof(UpdatePuller)).pullUpdates();
            // a role switch
            cluster.Shutdown(firstMaster);
            cluster.Await(masterAvailable(firstMaster));
            // close T
            barrier.Release();
            t.get();
            TriggerIdMaintenance(slave);

            // THEN the deleted property record should now not be in freelist on new master
            CreateNodeWithProperties(slave, 10); // <-- this transaction should introduce inconsistencies
            cluster.Stop();                      // <-- CC will be run here since that's configured above ^^^
        }
コード例 #12
0
ファイル: RecoveryCleanupIT.cs プロジェクト: Neo4Net/Neo4Net
 internal RecoveryBarrierMonitor(RecoveryCleanupIT outerInstance, Org.Neo4j.Test.Barrier_Control barrier)
 {
     this._outerInstance = outerInstance;
     this.Barrier        = barrier;
 }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDeadlock() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotDeadlock()
        {
            IList <TransactionRepresentation> transactions = CreateConstraintCreatingTransactions();
            Monitors         monitors = new Monitors();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).setMonitors(monitors).newImpermanentDatabase();

            Org.Neo4j.Test.Barrier_Control controller = new Org.Neo4j.Test.Barrier_Control();
            bool success = false;

            try
            {
                IndexingService.Monitor monitor = new MonitorAdapterAnonymousInnerClass(this, controller);
                monitors.AddMonitorListener(monitor);
                Future <object> applier = ApplyInT2(db, transactions);

                controller.Await();

                // At this point the index population has completed and the population thread is ready to
                // acquire the counts store read lock for initializing some samples there. We're starting the
                // check pointer, which will eventually put itself in queue for acquiring the write lock

                Future <object> checkPointer = T3.execute(state => Db.DependencyResolver.resolveDependency(typeof(CheckPointer)).forceCheckPoint(new SimpleTriggerInfo("MANUAL")));
                try
                {
                    T3.get().waitUntilWaiting(details => details.isAt(typeof(LockWrapper), "writeLock"));
                }
                catch (System.InvalidOperationException)
                {
                    // Thrown when the fix is in, basically it's thrown if the check pointer didn't get blocked
                    checkPointer.get();                              // to assert that no exception was thrown during in check point thread
                }

                // Alright the trap is set. Let the population thread move on and seal the deal
                controller.Release();

                // THEN these should complete
                applier.get(10, SECONDS);
                checkPointer.get(10, SECONDS);
                success = true;

                using (Transaction tx = Db.beginTx())
                {
                    ConstraintDefinition constraint = single(Db.schema().getConstraints(LABEL));
                    assertEquals(KEY, single(constraint.PropertyKeys));
                    tx.Success();
                }

                CreateNode(db, "A");
                try
                {
                    CreateNode(db, "A");
                    fail("Should have failed");
                }
                catch (ConstraintViolationException)
                {
                    // THEN good
                }
            }
            finally
            {
                if (!success)
                {
                    T2.interrupt();
                    T3.interrupt();
                    // so that shutdown won't hang too
                }
                Db.shutdown();
            }
        }
コード例 #14
0
 public CountsTrackerAnonymousInnerClass(CountsTrackerTest outerInstance, Org.Neo4j.Logging.LogProvider logProvider, Org.Neo4j.Io.fs.FileSystemAbstraction fileSystem, Org.Neo4j.Io.pagecache.PageCache pageCache, Config defaults, VersionContextSupplier empty, Org.Neo4j.Test.Barrier_Control barrier) : base(logProvider, fileSystem, pageCache, defaults, outerInstance.ResourceManager.testDirectory().databaseLayout(), empty)
 {
     this.outerInstance = outerInstance;
     this._barrier      = barrier;
 }
コード例 #15
0
//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());
            }
        }
コード例 #16
0
 public MonitorAdapterAnonymousInnerClass(HalfAppliedConstraintRecoveryIT outerInstance, Org.Neo4j.Test.Barrier_Control barrier)
 {
     this.outerInstance = outerInstance;
     this._barrier      = barrier;
 }
コード例 #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTerminateQueriesEvenIfUsingPeriodicCommit() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTerminateQueriesEvenIfUsingPeriodicCommit()
        {
            // Spawns a throttled HTTP server, runs a PERIODIC COMMIT that fetches data from this server,
            // and checks that the query able to be terminated

            // We start with 3, because that is how many actors we have -
            // 1. the http server
            // 2. the running query
            // 3. the one terminating 2
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.DoubleLatch latch = new org.neo4j.test.DoubleLatch(3, true);
            DoubleLatch latch = new DoubleLatch(3, true);

            // This is used to block the http server between the first and second batch
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.Barrier_Control barrier = new org.neo4j.test.Barrier_Control();
            Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control();

            // Serve CSV via local web server, let Jetty find a random port for us
            Server server = CreateHttpServer(latch, barrier, 20, 30);

            server.start();
            int localPort = GetLocalPort(server);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.bolt.runtime.BoltStateMachine[] machine = {null};
            BoltStateMachine[] machine = new BoltStateMachine[] { null };

            Thread thread = new Thread(() =>
            {
                try
                {
                    using (BoltStateMachine stateMachine = Env.newMachine(_boltChannel))
                    {
                        machine[0] = stateMachine;
                        stateMachine.process(new InitMessage(USER_AGENT, emptyMap()), nullResponseHandler());
                        string query = format("USING PERIODIC COMMIT 10 LOAD CSV FROM 'http://localhost:%d' AS line " + "CREATE (n:A {id: line[0], square: line[1]}) " + "WITH count(*) as number " + "CREATE (n:ShouldNotExist)", localPort);
                        try
                        {
                            latch.Start();
                            stateMachine.process(new RunMessage(query, EMPTY_MAP), nullResponseHandler());
                            stateMachine.process(PullAllMessage.INSTANCE, nullResponseHandler());
                        }
                        finally
                        {
                            latch.Finish();
                        }
                    }
                }
                catch (BoltConnectionFatality connectionFatality)
                {
                    throw new Exception(connectionFatality);
                }
            });

            thread.Name = "query runner";
            thread.Start();

            // We block this thread here, waiting for the http server to spin up and the running query to get started
            latch.StartAndWaitForAllToStart();
            Thread.Sleep(1000);

            // This is the call that RESETs the Bolt connection and will terminate the running query
            machine[0].Process(ResetMessage.INSTANCE, nullResponseHandler());

            barrier.Release();

            // We block again here, waiting for the running query to have been terminated, and for the server to have
            // wrapped up and finished streaming http results
            latch.FinishAndWaitForAllToFinish();

            // And now we check that the last node did not get created
            using (Transaction ignored = Env.graph().beginTx())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse("Query was not terminated in time - nodes were created!", Env.graph().findNodes(Label.label("ShouldNotExist")).hasNext());
            }
        }
コード例 #18
0
 public MonitorAdapterAnonymousInnerClass(CheckPointerConstraintCreationDeadlockIT outerInstance, Org.Neo4j.Test.Barrier_Control controller)
 {
     this.outerInstance = outerInstance;
     this._controller   = controller;
 }
コード例 #19
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.test.OtherThreadExecutor.WorkerCommand<Void,Void> barrierControlledReadTransaction(final org.neo4j.graphdb.GraphDatabaseService slave, final org.neo4j.test.Barrier_Control barrier)
        private WorkerCommand <Void, Void> BarrierControlledReadTransaction(GraphDatabaseService slave, Org.Neo4j.Test.Barrier_Control barrier)
        {
            return(state =>
            {
                try
                {
                    using (Transaction tx = slave.BeginTx())
                    {
                        barrier.Reached();
                        tx.success();
                    }
                }
                catch (Exception)
                {
                    // This is OK, we expect this transaction to fail after role switch
                }
                finally
                {
                    barrier.Release();
                }
                return null;
            });
        }