Ejemplo n.º 1
0
        private void ClearData()
        {
            HighlyAvailableGraphDatabase db = Cluster.Master;

            GraphDatabaseServiceCleaner.cleanDatabaseContent(db);
            Cluster.sync();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster()
        {
            // Given
            HighlyAvailableGraphDatabase initialMaster = _cluster.Master;

            // When
            _cluster.shutdown(initialMaster);
            _cluster.await(masterAvailable(initialMaster));
            _cluster.await(masterSeesSlavesAsAvailable(1));

            // create node on new master to ensure that it has the greatest tx id
            CreateNodeOn(_cluster.Master);
            _cluster.sync();

            LifeSupport         life          = new LifeSupport();
            ClusterClientModule clusterClient = NewClusterClient(life, new InstanceId(1));

            Cleanup.add(life);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.cluster.InstanceId> coordinatorIdWhenReJoined = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <InstanceId> coordinatorIdWhenReJoined = new AtomicReference <InstanceId>();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);
            clusterClient.ClusterClient.addClusterListener(new ClusterListener_AdapterAnonymousInnerClass(this, coordinatorIdWhenReJoined, latch));

            life.Start();

            // Then
            assertTrue(latch.await(20, SECONDS));
            assertEquals(new InstanceId(2), coordinatorIdWhenReJoined.get());
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleSlaveCommittingLargeTx()
        public virtual void ShouldHandleSlaveCommittingLargeTx()
        {
            // GIVEN
            GraphDatabaseService slave = Cluster.AnySlave;
            long initialNodeCount      = NodeCount(slave);

            // WHEN
            Cluster.info("Before commit large");
            int nodeCount = CommitLargeTx(slave);

            Cluster.info("Before sync");
            Cluster.sync();
            Cluster.info("After sync");

            // THEN all should have that tx
            AssertAllMembersHasNodeCount(initialNodeCount + nodeCount);
            // and if then master commits something, they should all get that too
            Cluster.info("Before commit small");
            CommitSmallTx(Cluster.Master);
            Cluster.info("Before sync small");
            Cluster.sync();
            Cluster.info("After sync small");
            AssertAllMembersHasNodeCount(initialNodeCount + nodeCount + 1);
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void aPendingMemberShouldBeAbleToServeReads() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void APendingMemberShouldBeAbleToServeReads()
        {
            // given
            CreateNodeOnMaster(_testLabel, _cluster.Master);
            _cluster.sync();

            HighlyAvailableGraphDatabase slave = _cluster.AnySlave;

            _cluster.fail(slave, Enum.GetValues(typeof(ClusterManager.NetworkFlag)));
            _cluster.await(instanceEvicted(slave));

            assertEquals(PENDING, slave.InstanceState);

            // when
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    using (Transaction tx = slave.BeginTx())
                    {
                        Node  single = Iterables.single(slave.AllNodes);
                        Label label  = Iterables.single(single.Labels);
                        assertEquals(_testLabel, label);
                        tx.Success();
                        break;
                    }
                }
                catch (TransactionTerminatedException)
                {
                    // Race between going to pending and reading, try again in a little while
                    Thread.Sleep(1_000);
                }
            }

            // then no exceptions thrown
        }