Ejemplo n.º 1
0
        /// <summary>
        /// The problem would manifest even if the transaction was performed on the Master, it would then occur when the
        /// Slave pulls updates and tries to apply the transaction. The reason for the test to run transactions against the
        /// Slave is because it makes guarantees for when the master has to apply the transaction.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDeleteRecords()
        public virtual void ShouldDeleteRecords()
        {
            // given
            ManagedCluster cluster = ClusterRule.startCluster();

            HighlyAvailableGraphDatabase master = cluster.Master;
            HighlyAvailableGraphDatabase slave  = cluster.AnySlave;

            Relationship rel;

            using (Transaction tx = slave.BeginTx())
            {
                rel = slave.CreateNode().createRelationshipTo(slave.CreateNode(), withName("FOO"));
                tx.Success();
            }

            using (Transaction transaction = master.BeginTx())
            {
                assertNotNull(master.GetRelationshipById(rel.Id));
            }

            // when
            using (Transaction tx = slave.BeginTx())
            {
                rel.Delete();
                tx.Success();
            }

            // then - there should have been no exceptions
            slave.Shutdown();
            master.Shutdown();
        }
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 slaveShouldMoveToPendingAndThenRecoverIfMasterDiesAndThenRecovers() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SlaveShouldMoveToPendingAndThenRecoverIfMasterDiesAndThenRecovers()
        {
            HighlyAvailableGraphDatabase master   = _cluster.Master;
            HighlyAvailableGraphDatabase theSlave = _cluster.AnySlave;

            string propertyName  = "prop";
            string propertyValue = "value1";
            long   slaveNodeId;

            ClusterManager.RepairKit repairKit = _cluster.fail(master);
            _cluster.await(memberSeesOtherMemberAsFailed(theSlave, master));

            assertEquals(HighAvailabilityMemberState.PENDING, theSlave.InstanceState);

            repairKit.Repair();

            _cluster.await(allSeesAllAsAvailable());

            using (Transaction tx = theSlave.BeginTx())
            {
                Node node = theSlave.CreateNode();
                slaveNodeId = node.Id;
                node.SetProperty(propertyName, propertyValue);
                tx.Success();
            }

            using (Transaction tx = master.BeginTx())
            {
                assertEquals(propertyValue, master.GetNodeById(slaveNodeId).getProperty(propertyName));
                tx.Success();
            }
        }
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 testBasicPropagationFromSlaveToMaster()
        public virtual void TestBasicPropagationFromSlaveToMaster()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  master  = cluster.Master;
            HighlyAvailableGraphDatabase  slave   = cluster.AnySlave;
            long nodeId;

            // a node with a property
            using (Transaction tx = master.BeginTx())
            {
                Node node = master.CreateNode();
                nodeId = node.Id;
                node.SetProperty("foo", "bar");
                tx.Success();
            }

            cluster.Sync();

            // when
            // the slave does a change
            using (Transaction tx = slave.BeginTx())
            {
                slave.GetNodeById(nodeId).setProperty("foo", "bar2");
                tx.Success();
            }

            // then
            // the master must pick up the change
            using (Transaction tx = master.BeginTx())
            {
                assertEquals("bar2", master.GetNodeById(nodeId).getProperty("foo"));
                tx.Success();
            }
        }
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 testBasicPropagationFromMasterToSlave()
        public virtual void TestBasicPropagationFromMasterToSlave()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            long nodeId = 4;
            HighlyAvailableGraphDatabase master = cluster.Master;

            using (Transaction tx = master.BeginTx())
            {
                Node node = master.CreateNode();
                node.SetProperty("Hello", "World");
                nodeId = node.Id;

                tx.Success();
            }

            cluster.Sync();

            // No need to wait, the push factor is 2
            HighlyAvailableGraphDatabase slave1 = cluster.AnySlave;

            CheckNodeOnSlave(nodeId, slave1);

            HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1);

            CheckNodeOnSlave(nodeId, slave2);
        }
Ejemplo n.º 5
0
 private void AddSomeData(HighlyAvailableGraphDatabase instance)
 {
     using (Transaction tx = instance.BeginTx())
     {
         Node testNode = instance.CreateNode();
         _testNodeId = testNode.Id;
         testNode.SetProperty(_testPropKey, _testPropValue);
         tx.Success();
     }
 }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void Setup()
		 {
			  CustomGraphDatabaseFactory customGraphDatabaseFactory = new CustomGraphDatabaseFactory( this );
			  _cluster = ClusterRule.withSharedSetting( GraphDatabaseSettings.snapshot_query, TRUE ).withDbFactory( customGraphDatabaseFactory ).startCluster();
			  HighlyAvailableGraphDatabase master = _cluster.Master;
			  for ( int i = 0; i < 3; i++ )
			  {
					using ( Transaction tx = master.BeginTx() )
					{
						 master.CreateNode( _nodeLabel );
						 tx.Success();
					}
			  }
			  _cluster.sync();
		 }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void masterShouldRemainAvailableIfTheSlaveDiesAndRecovers() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MasterShouldRemainAvailableIfTheSlaveDiesAndRecovers()
        {
            HighlyAvailableGraphDatabase master   = _cluster.Master;
            HighlyAvailableGraphDatabase theSlave = _cluster.AnySlave;

            string propertyName   = "prop";
            string propertyValue1 = "value1";
            string propertyValue2 = "value2";
            long   masterNodeId;
            long   slaveNodeId;

            ClusterManager.RepairKit repairKit = _cluster.fail(theSlave);
            _cluster.await(memberSeesOtherMemberAsFailed(master, theSlave));

            using (Transaction tx = master.BeginTx())
            {
                Node node = master.CreateNode();
                node.SetProperty(propertyName, propertyValue1);
                masterNodeId = node.Id;
                tx.Success();
            }

            repairKit.Repair();

            _cluster.await(allSeesAllAsAvailable());

            using (Transaction tx = theSlave.BeginTx())
            {
                Node node = theSlave.CreateNode();
                node.SetProperty(propertyName, propertyValue2);
                assertEquals(propertyValue1, theSlave.GetNodeById(masterNodeId).getProperty(propertyName));
                slaveNodeId = node.Id;
                tx.Success();
            }

            using (Transaction tx = master.BeginTx())
            {
                assertEquals(propertyValue2, master.GetNodeById(slaveNodeId).getProperty(propertyName));
                tx.Success();
            }
        }