public virtual void TestCheckPointDirsAreTrimmed()
        {
            MiniDFSCluster    cluster             = null;
            SecondaryNameNode secondary           = null;
            FilePath          checkpointNameDir1  = new FilePath(base_dir, "chkptName1");
            FilePath          checkpointEditsDir1 = new FilePath(base_dir, "chkptEdits1");
            FilePath          checkpointNameDir2  = new FilePath(base_dir, "chkptName2");
            FilePath          checkpointEditsDir2 = new FilePath(base_dir, "chkptEdits2");
            FilePath          nameDir             = new FilePath(base_dir, "name1");
            string            whiteSpace          = "  \n   \n  ";
            Configuration     conf = new HdfsConfiguration();

            conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, nameDir.GetPath());
            conf.SetStrings(DFSConfigKeys.DfsNamenodeCheckpointDirKey, whiteSpace + checkpointNameDir1
                            .GetPath() + whiteSpace, whiteSpace + checkpointNameDir2.GetPath() + whiteSpace);
            conf.SetStrings(DFSConfigKeys.DfsNamenodeCheckpointEditsDirKey, whiteSpace + checkpointEditsDir1
                            .GetPath() + whiteSpace, whiteSpace + checkpointEditsDir2.GetPath() + whiteSpace
                            );
            cluster = new MiniDFSCluster.Builder(conf).ManageNameDfsDirs(false).NumDataNodes(
                3).Build();
            try
            {
                cluster.WaitActive();
                secondary = StartSecondaryNameNode(conf);
                secondary.DoCheckpoint();
                NUnit.Framework.Assert.IsTrue(DFSConfigKeys.DfsNamenodeNameDirKey + " must be trimmed "
                                              , checkpointNameDir1.Exists());
                NUnit.Framework.Assert.IsTrue(DFSConfigKeys.DfsNamenodeNameDirKey + " must be trimmed "
                                              , checkpointNameDir2.Exists());
                NUnit.Framework.Assert.IsTrue(DFSConfigKeys.DfsNamenodeCheckpointEditsDirKey + " must be trimmed "
                                              , checkpointEditsDir1.Exists());
                NUnit.Framework.Assert.IsTrue(DFSConfigKeys.DfsNamenodeCheckpointEditsDirKey + " must be trimmed "
                                              , checkpointEditsDir2.Exists());
            }
            finally
            {
                secondary.Shutdown();
                cluster.Shutdown();
            }
        }
        public virtual void TestNameEditsRequiredConfigs()
        {
            MiniDFSCluster cluster          = null;
            FilePath       nameAndEditsDir  = new FilePath(base_dir, "name_and_edits");
            FilePath       nameAndEditsDir2 = new FilePath(base_dir, "name_and_edits2");
            FilePath       nameDir          = new FilePath(base_dir, "name");

            // 1
            // Bad configuration. Add a directory to dfs.namenode.edits.dir.required
            // without adding it to dfs.namenode.edits.dir.
            try
            {
                Configuration conf = new HdfsConfiguration();
                conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, nameDir.GetAbsolutePath());
                conf.Set(DFSConfigKeys.DfsNamenodeEditsDirRequiredKey, nameAndEditsDir2.ToURI().ToString
                             ());
                conf.Set(DFSConfigKeys.DfsNamenodeEditsDirKey, nameAndEditsDir.ToURI().ToString()
                         );
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(NumDataNodes).ManageNameDfsDirs
                              (false).Build();
                NUnit.Framework.Assert.Fail("Successfully started cluster but should not have been able to."
                                            );
            }
            catch (ArgumentException iae)
            {
                // expect to fail
                Log.Info("EXPECTED: cluster start failed due to bad configuration" + iae);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
                cluster = null;
            }
            // 2
            // Good configuration. Add a directory to both dfs.namenode.edits.dir.required
            // and dfs.namenode.edits.dir.
            try
            {
                Configuration conf = new HdfsConfiguration();
                conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, nameDir.GetAbsolutePath());
                conf.SetStrings(DFSConfigKeys.DfsNamenodeEditsDirKey, nameAndEditsDir.ToURI().ToString
                                    (), nameAndEditsDir2.ToURI().ToString());
                conf.Set(DFSConfigKeys.DfsNamenodeEditsDirRequiredKey, nameAndEditsDir2.ToURI().ToString
                             ());
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(NumDataNodes).ManageNameDfsDirs
                              (false).Build();
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
            // 3
            // Good configuration. Adds a directory to dfs.namenode.edits.dir but not to
            // dfs.namenode.edits.dir.required.
            try
            {
                Configuration conf = new HdfsConfiguration();
                conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, nameDir.GetAbsolutePath());
                conf.SetStrings(DFSConfigKeys.DfsNamenodeEditsDirKey, nameAndEditsDir.ToURI().ToString
                                    (), nameAndEditsDir2.ToURI().ToString());
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(NumDataNodes).ManageNameDfsDirs
                              (false).Build();
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }