Ejemplo n.º 1
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.º 2
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.º 3
0
 private void CheckNodeOnSlave(long nodeId, HighlyAvailableGraphDatabase slave2)
 {
     using (Transaction tx = slave2.BeginTx())
     {
         string value = slave2.GetNodeById(nodeId).getProperty("Hello").ToString();
         Logger.Logger.info("Hello=" + value);
         assertEquals("World", value);
         tx.Success();
     }
 }
Ejemplo n.º 4
0
        /*
         * This method must be called on an instance that has had addSomeData() called on it.
         */
        private void EnsureInstanceIsReadOnlyInPendingState(HighlyAvailableGraphDatabase instance)
        {
            assertEquals(PENDING, instance.InstanceState);

            tx(instance, retryACoupleOfTimesOn(TRANSIENT_ERRORS), db => assertEquals(_testPropValue, instance.GetNodeById(_testNodeId).getProperty(_testPropKey)));

            try
            {
                using (Transaction ignored = instance.BeginTx())
                {
                    instance.GetNodeById(_testNodeId).delete();
                    fail("Should not be able to do write transactions when detached");
                }
            }
            catch (Exception expected) when(expected is TransientDatabaseFailureException || expected is TransactionFailureException)
            {
                // expected
            }
        }
Ejemplo n.º 5
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();
            }
        }