Beispiel #1
0
        public virtual void TestFailoverWithBK()
        {
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
                conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/hotfailover"
                                                                                               ).ToString());
                BKJMUtil.AddJournalManagerDefinition(conf);
                cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                          ()).NumDataNodes(0).ManageNameDfsSharedDirs(false).Build();
                NameNode nn1 = cluster.GetNameNode(0);
                NameNode nn2 = cluster.GetNameNode(1);
                cluster.WaitActive();
                cluster.TransitionToActive(0);
                Path       p  = new Path("/testBKJMfailover");
                FileSystem fs = HATestUtil.ConfigureFailoverFs(cluster, conf);
                fs.Mkdirs(p);
                cluster.ShutdownNameNode(0);
                cluster.TransitionToActive(1);
                NUnit.Framework.Assert.IsTrue(fs.Exists(p));
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Beispiel #2
0
        public virtual void TestInitializeBKSharedEdits()
        {
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                HAUtil.SetAllowStandbyReads(conf, true);
                conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
                MiniDFSNNTopology topology = MiniDFSNNTopology.SimpleHATopology();
                cluster = new MiniDFSCluster.Builder(conf).NnTopology(topology).NumDataNodes(0).Build
                              ();
                cluster.WaitActive();
                // Shutdown and clear the current filebased shared dir.
                cluster.ShutdownNameNodes();
                FilePath shareddir = new FilePath(cluster.GetSharedEditsDir(0, 1));
                NUnit.Framework.Assert.IsTrue("Initial Shared edits dir not fully deleted", FileUtil
                                              .FullyDelete(shareddir));
                // Check namenodes should not start without shared dir.
                AssertCanNotStartNamenode(cluster, 0);
                AssertCanNotStartNamenode(cluster, 1);
                // Configure bkjm as new shared edits dir in both namenodes
                Configuration nn1Conf = cluster.GetConfiguration(0);
                Configuration nn2Conf = cluster.GetConfiguration(1);
                nn1Conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI
                                ("/initializeSharedEdits").ToString());
                nn2Conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI
                                ("/initializeSharedEdits").ToString());
                BKJMUtil.AddJournalManagerDefinition(nn1Conf);
                BKJMUtil.AddJournalManagerDefinition(nn2Conf);
                // Initialize the BKJM shared edits.
                NUnit.Framework.Assert.IsFalse(NameNode.InitializeSharedEdits(nn1Conf));
                // NameNode should be able to start and should be in sync with BKJM as
                // shared dir
                AssertCanStartHANameNodes(cluster, conf, "/testBKJMInitialize");
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
        public override void SetupCluster()
        {
            Configuration conf = SetupCommonConfig();

            conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/checkpointing"
                                                                                           + journalCount++).ToString());
            BKJMUtil.AddJournalManagerDefinition(conf);
            MiniDFSNNTopology topology = new MiniDFSNNTopology().AddNameservice(new MiniDFSNNTopology.NSConf
                                                                                    ("ns1").AddNN(new MiniDFSNNTopology.NNConf("nn1").SetHttpPort(10001)).AddNN(new
                                                                                                                                                                MiniDFSNNTopology.NNConf("nn2").SetHttpPort(10002)));

            cluster = new MiniDFSCluster.Builder(conf).NnTopology(topology).NumDataNodes(1).ManageNameDfsSharedDirs
                          (false).Build();
            cluster.WaitActive();
            nn0 = cluster.GetNameNode(0);
            nn1 = cluster.GetNameNode(1);
            fs  = HATestUtil.ConfigureFailoverFs(cluster, conf);
            cluster.TransitionToActive(0);
        }
Beispiel #4
0
        public virtual void TestMultiplePrimariesStarted()
        {
            Path           p1      = new Path("/testBKJMMultiplePrimary");
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
                conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/hotfailoverMultiple"
                                                                                               ).ToString());
                BKJMUtil.AddJournalManagerDefinition(conf);
                cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                          ()).NumDataNodes(0).ManageNameDfsSharedDirs(false).CheckExitOnShutdown(false).Build
                              ();
                NameNode nn1 = cluster.GetNameNode(0);
                NameNode nn2 = cluster.GetNameNode(1);
                cluster.WaitActive();
                cluster.TransitionToActive(0);
                FileSystem fs = HATestUtil.ConfigureFailoverFs(cluster, conf);
                fs.Mkdirs(p1);
                nn1.GetRpcServer().RollEditLog();
                cluster.TransitionToActive(1);
                fs = cluster.GetFileSystem(0);
                // get the older active server.
                try
                {
                    fs.Delete(p1, true);
                    NUnit.Framework.Assert.Fail("Log update on older active should cause it to exit");
                }
                catch (RemoteException re)
                {
                    NUnit.Framework.Assert.IsTrue(re.GetClassName().Contains("ExitException"));
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
        public virtual void SetUp()
        {
            Configuration conf = new Configuration();

            conf.SetInt(DFSConfigKeys.DfsNamenodeCheckpointCheckPeriodKey, 1);
            conf.SetInt(DFSConfigKeys.DfsNamenodeCheckpointTxnsKey, 5);
            conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
            conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/bootstrapStandby"
                                                                                           ).ToString());
            BKJMUtil.AddJournalManagerDefinition(conf);
            conf.SetBoolean(DFSConfigKeys.DfsImageCompressKey, true);
            conf.Set(DFSConfigKeys.DfsImageCompressionCodecKey, typeof(TestStandbyCheckpoints.SlowCodec
                                                                       ).GetCanonicalName());
            CompressionCodecFactory.SetCodecClasses(conf, ImmutableList.Of <Type>(typeof(TestStandbyCheckpoints.SlowCodec
                                                                                         )));
            MiniDFSNNTopology topology = new MiniDFSNNTopology().AddNameservice(new MiniDFSNNTopology.NSConf
                                                                                    ("ns1").AddNN(new MiniDFSNNTopology.NNConf("nn1").SetHttpPort(10001)).AddNN(new
                                                                                                                                                                MiniDFSNNTopology.NNConf("nn2").SetHttpPort(10002)));

            cluster = new MiniDFSCluster.Builder(conf).NnTopology(topology).NumDataNodes(1).ManageNameDfsSharedDirs
                          (false).Build();
            cluster.WaitActive();
        }
Beispiel #6
0
        public virtual void TestNameNodeMultipleSwitchesUsingBKJM()
        {
            MiniDFSCluster cluster = null;

            try
            {
                Configuration conf = new Configuration();
                conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
                conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/correctEditLogSelection"
                                                                                               ).ToString());
                BKJMUtil.AddJournalManagerDefinition(conf);
                cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                          ()).NumDataNodes(0).ManageNameDfsSharedDirs(false).Build();
                NameNode nn1 = cluster.GetNameNode(0);
                NameNode nn2 = cluster.GetNameNode(1);
                cluster.WaitActive();
                cluster.TransitionToActive(0);
                nn1.GetRpcServer().RollEditLog();
                // Roll Edits from current Active.
                // Transition to standby current active gracefully.
                cluster.TransitionToStandby(0);
                // Make the other Active and Roll edits multiple times
                cluster.TransitionToActive(1);
                nn2.GetRpcServer().RollEditLog();
                nn2.GetRpcServer().RollEditLog();
                // Now One more failover. So NN1 should be able to failover successfully.
                cluster.TransitionToStandby(1);
                cluster.TransitionToActive(0);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Beispiel #7
0
        public virtual void TestFailoverWithFailingBKCluster()
        {
            int          ensembleSize = numBookies + 1;
            BookieServer newBookie    = bkutil.NewBookie();

            NUnit.Framework.Assert.AreEqual("New bookie didn't start", ensembleSize, bkutil.CheckBookiesUp
                                                (ensembleSize, 10));
            BookieServer   replacementBookie = null;
            MiniDFSCluster cluster           = null;

            try
            {
                Configuration conf = new Configuration();
                conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
                conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, BKJMUtil.CreateJournalURI("/hotfailoverWithFail"
                                                                                               ).ToString());
                conf.SetInt(BookKeeperJournalManager.BkjmBookkeeperEnsembleSize, ensembleSize);
                conf.SetInt(BookKeeperJournalManager.BkjmBookkeeperQuorumSize, ensembleSize);
                BKJMUtil.AddJournalManagerDefinition(conf);
                cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                          ()).NumDataNodes(0).ManageNameDfsSharedDirs(false).CheckExitOnShutdown(false).Build
                              ();
                NameNode nn1 = cluster.GetNameNode(0);
                NameNode nn2 = cluster.GetNameNode(1);
                cluster.WaitActive();
                cluster.TransitionToActive(0);
                Path       p1 = new Path("/testBKJMFailingBKCluster1");
                Path       p2 = new Path("/testBKJMFailingBKCluster2");
                FileSystem fs = HATestUtil.ConfigureFailoverFs(cluster, conf);
                fs.Mkdirs(p1);
                newBookie.Shutdown();
                // will take down shared storage
                NUnit.Framework.Assert.AreEqual("New bookie didn't stop", numBookies, bkutil.CheckBookiesUp
                                                    (numBookies, 10));
                try
                {
                    fs.Mkdirs(p2);
                    NUnit.Framework.Assert.Fail("mkdirs should result in the NN exiting");
                }
                catch (RemoteException re)
                {
                    NUnit.Framework.Assert.IsTrue(re.GetClassName().Contains("ExitException"));
                }
                cluster.ShutdownNameNode(0);
                try
                {
                    cluster.TransitionToActive(1);
                    NUnit.Framework.Assert.Fail("Shouldn't have been able to transition with bookies down"
                                                );
                }
                catch (ExitUtil.ExitException ee)
                {
                    NUnit.Framework.Assert.IsTrue("Should shutdown due to required journal failure",
                                                  ee.Message.Contains("starting log segment 3 failed for required journal"));
                }
                replacementBookie = bkutil.NewBookie();
                NUnit.Framework.Assert.AreEqual("Replacement bookie didn't start", ensembleSize,
                                                bkutil.CheckBookiesUp(ensembleSize, 10));
                cluster.TransitionToActive(1);
                // should work fine now
                NUnit.Framework.Assert.IsTrue(fs.Exists(p1));
                NUnit.Framework.Assert.IsFalse(fs.Exists(p2));
            }
            finally
            {
                newBookie.Shutdown();
                if (replacementBookie != null)
                {
                    replacementBookie.Shutdown();
                }
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }