Exemple #1
0
        /// <summary>Check whether the BackupNode can be started.</summary>
        /// <exception cref="System.IO.IOException"/>
        private bool CanStartBackupNode(Configuration conf)
        {
            BackupNode bn = null;

            try
            {
                bn = StartBackupNode(conf);
            }
            catch (IOException e)
            {
                if (e is BindException)
                {
                    return(false);
                }
                throw;
            }
            finally
            {
                if (bn != null)
                {
                    bn.Stop();
                }
            }
            return(true);
        }
Exemple #2
0
        /// <summary>Start the BackupNode</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual BackupNode StartBackupNode(Configuration conf)
        {
            // Set up testing environment directories
            hdfsDir = new FilePath(TestDataDir, "backupNode");
            if (hdfsDir.Exists() && !FileUtil.FullyDelete(hdfsDir))
            {
                throw new IOException("Could not delete hdfs directory '" + hdfsDir + "'");
            }
            FilePath currDir  = new FilePath(hdfsDir, "name2");
            FilePath currDir2 = new FilePath(currDir, "current");
            FilePath currDir3 = new FilePath(currDir, "image");

            NUnit.Framework.Assert.IsTrue(currDir.Mkdirs());
            NUnit.Framework.Assert.IsTrue(currDir2.Mkdirs());
            NUnit.Framework.Assert.IsTrue(currDir3.Mkdirs());
            conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, Util.FileAsURI(new FilePath(hdfsDir
                                                                                      , "name2")).ToString());
            conf.Set(DFSConfigKeys.DfsNamenodeEditsDirKey, "${" + DFSConfigKeys.DfsNamenodeNameDirKey
                     + "}");
            // Start BackupNode
            string[]   args = new string[] { HdfsServerConstants.StartupOption.Backup.GetName() };
            BackupNode bu   = (BackupNode)NameNode.CreateNameNode(args, conf);

            return(bu);
        }