Example #1
0
 private void ProceedAsNormalWithIndexPopulationOnAllSlavesExcept(ControlledGraphDatabaseFactory dbFactory, ClusterManager.ManagedCluster cluster, HighlyAvailableGraphDatabase slaveToIgnore)
 {
     foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers)
     {
         if (db != slaveToIgnore && Db.InstanceState == HighAvailabilityMemberState.SLAVE)
         {
             dbFactory.TriggerFinish(db);
         }
     }
 }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlineSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OnlineSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy()
        {
            /*
             * The master has an index that is online.
             * Then a slave comes online and contacts the master to get copies of the store files.
             * Because the index is online, it should be copied, and the slave should successfully bring the index online.
             */

            // GIVEN
            ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory();

            ClusterManager.ManagedCluster cluster = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, _controlledProviderDescriptor.name()).startCluster();
            cluster.Await(allSeesAllAsAvailable(), 120);

            HighlyAvailableGraphDatabase slave = cluster.AnySlave;

            // All slaves in the cluster, except the one I care about, proceed as normal
            ProceedAsNormalWithIndexPopulationOnAllSlavesExcept(dbFactory, cluster, slave);

            // A slave is offline, and has no store files
            ClusterManager.RepairKit slaveDown = BringSlaveOfflineAndRemoveStoreFiles(cluster, slave);

            // And I create an index on the master, and wait for population to start
            HighlyAvailableGraphDatabase master = cluster.Master;
            IDictionary <object, Node>   data   = CreateSomeData(master);

            CreateIndex(master);
            dbFactory.AwaitPopulationStarted(master);

            // And the population finishes
            dbFactory.TriggerFinish(master);
            IndexDefinition index;

            using (Transaction tx = master.BeginTx())
            {
                index = single(master.Schema().Indexes);
                AwaitIndexOnline(index, master, data);
                tx.Success();
            }

            // WHEN the slave comes online after population has finished on the master
            slave = slaveDown.Repair();
            cluster.Await(allSeesAllAsAvailable());
            cluster.Sync();

            // THEN the index should work on the slave
            dbFactory.TriggerFinish(slave);
            using (Transaction tx = slave.BeginTx())
            {
                AwaitIndexOnline(index, slave, data);
                tx.Success();
            }
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexPopulationJobsShouldContinueThroughRoleSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexPopulationJobsShouldContinueThroughRoleSwitch()
        {
            // GIVEN a cluster of 3
            ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory();

            ClusterManager.ManagedCluster cluster     = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, _controlledProviderDescriptor.name()).startCluster();
            HighlyAvailableGraphDatabase  firstMaster = cluster.Master;

            // where the master gets some data created as well as an index
            IDictionary <object, Node> data = CreateSomeData(firstMaster);

            CreateIndex(firstMaster);
            //dbFactory.awaitPopulationStarted( firstMaster );
            dbFactory.TriggerFinish(firstMaster);

            // Pick a slave, pull the data and the index
            HighlyAvailableGraphDatabase aSlave = cluster.AnySlave;

            aSlave.DependencyResolver.resolveDependency(typeof(UpdatePuller)).pullUpdates();

            // and await the index population to start. It will actually block as long as we want it to
            dbFactory.AwaitPopulationStarted(aSlave);

            // WHEN we shut down the master
            cluster.Shutdown(firstMaster);

            dbFactory.TriggerFinish(aSlave);
            cluster.Await(masterAvailable(firstMaster));
            // get the new master, which should be the slave we pulled from above
            HighlyAvailableGraphDatabase newMaster = cluster.Master;

            // THEN
            assertEquals("Unexpected new master", aSlave, newMaster);
            using (Transaction tx = newMaster.BeginTx())
            {
                IndexDefinition index = single(newMaster.Schema().Indexes);
                AwaitIndexOnline(index, newMaster, data);
                tx.Success();
            }
            // FINALLY: let all db's finish
            foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers)
            {
                dbFactory.TriggerFinish(db);
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populatingSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulatingSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy()
        {
            /*
             * The master has an index that is currently populating.
             * Then a slave comes online and contacts the master to get copies of the store files.
             * Because the index is still populating, it won't be copied. Instead the slave will build its own.
             * We want to observe that the slave builds an index that eventually comes online.
             */

            // GIVEN
            ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory(_isMaster);

            ClusterManager.ManagedCluster cluster = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, NativeLuceneFusionIndexProviderFactory20.DESCRIPTOR.name()).startCluster();

            try
            {
                cluster.Await(allSeesAllAsAvailable());

                HighlyAvailableGraphDatabase slave = cluster.AnySlave;

                // A slave is offline, and has no store files
                ClusterManager.RepairKit slaveDown = BringSlaveOfflineAndRemoveStoreFiles(cluster, slave);

                // And I create an index on the master, and wait for population to start
                HighlyAvailableGraphDatabase master = cluster.Master;
                IDictionary <object, Node>   data   = CreateSomeData(master);
                CreateIndex(master);
                dbFactory.AwaitPopulationStarted(master);

                // WHEN the slave comes online before population has finished on the master
                slave = slaveDown.Repair();
                cluster.Await(allSeesAllAsAvailable(), 180);
                cluster.Sync();

                // THEN, population should finish successfully on both master and slave
                dbFactory.TriggerFinish(master);

                // Check master
                IndexDefinition index;
                using (Transaction tx = master.BeginTx())
                {
                    index = single(master.Schema().Indexes);
                    AwaitIndexOnline(index, master, data);
                    tx.Success();
                }

                // Check slave
                using (Transaction tx = slave.BeginTx())
                {
                    AwaitIndexOnline(index, slave, data);
                    tx.Success();
                }
            }
            finally
            {
                foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers)
                {
                    dbFactory.TriggerFinish(db);
                }
            }
        }