コード例 #1
0
 public virtual void TestFinalize()
 {
     UpgradeUtilities.Initialize();
     for (int numDirs = 1; numDirs <= 2; numDirs++)
     {
         /* This test requires that "current" directory not change after
          * the upgrade. Actually it is ok for those contents to change.
          * For now disabling block verification so that the contents are
          * not changed.
          * Disable duplicate replica deletion as the test intentionally
          * mirrors the contents of storage directories.
          */
         conf = new HdfsConfiguration();
         conf.SetInt(DFSConfigKeys.DfsDatanodeScanPeriodHoursKey, -1);
         conf.SetBoolean(DFSConfigKeys.DfsDatanodeDuplicateReplicaDeletion, false);
         conf = UpgradeUtilities.InitializeStorageStateConf(numDirs, conf);
         string[] nameNodeDirs = conf.GetStrings(DFSConfigKeys.DfsNamenodeNameDirKey);
         string[] dataNodeDirs = conf.GetStrings(DFSConfigKeys.DfsDatanodeDataDirKey);
         Log("Finalize NN & DN with existing previous dir", numDirs);
         UpgradeUtilities.CreateNameNodeStorageDirs(nameNodeDirs, "current");
         UpgradeUtilities.CreateNameNodeStorageDirs(nameNodeDirs, "previous");
         UpgradeUtilities.CreateDataNodeStorageDirs(dataNodeDirs, "current");
         UpgradeUtilities.CreateDataNodeStorageDirs(dataNodeDirs, "previous");
         cluster = new MiniDFSCluster.Builder(conf).Format(false).ManageDataDfsDirs(false)
                   .ManageNameDfsDirs(false).StartupOption(HdfsServerConstants.StartupOption.Regular
                                                           ).Build();
         cluster.FinalizeCluster(conf);
         cluster.TriggerBlockReports();
         // 1 second should be enough for asynchronous DN finalize
         Sharpen.Thread.Sleep(1000);
         CheckResult(nameNodeDirs, dataNodeDirs, null);
         Log("Finalize NN & DN without existing previous dir", numDirs);
         cluster.FinalizeCluster(conf);
         cluster.TriggerBlockReports();
         // 1 second should be enough for asynchronous DN finalize
         Sharpen.Thread.Sleep(1000);
         CheckResult(nameNodeDirs, dataNodeDirs, null);
         cluster.Shutdown();
         UpgradeUtilities.CreateEmptyDirs(nameNodeDirs);
         UpgradeUtilities.CreateEmptyDirs(dataNodeDirs);
         Log("Finalize NN & BP with existing previous dir", numDirs);
         string bpid = UpgradeUtilities.GetCurrentBlockPoolID(cluster);
         UpgradeUtilities.CreateNameNodeStorageDirs(nameNodeDirs, "current");
         UpgradeUtilities.CreateNameNodeStorageDirs(nameNodeDirs, "previous");
         UpgradeUtilities.CreateDataNodeStorageDirs(dataNodeDirs, "current");
         UpgradeUtilities.CreateBlockPoolStorageDirs(dataNodeDirs, "current", bpid);
         UpgradeUtilities.CreateBlockPoolStorageDirs(dataNodeDirs, "previous", bpid);
         cluster = new MiniDFSCluster.Builder(conf).Format(false).ManageDataDfsDirs(false)
                   .ManageNameDfsDirs(false).StartupOption(HdfsServerConstants.StartupOption.Regular
                                                           ).Build();
         cluster.FinalizeCluster(conf);
         cluster.TriggerBlockReports();
         // 1 second should be enough for asynchronous BP finalize
         Sharpen.Thread.Sleep(1000);
         CheckResult(nameNodeDirs, dataNodeDirs, bpid);
         Log("Finalize NN & BP without existing previous dir", numDirs);
         cluster.FinalizeCluster(conf);
         cluster.TriggerBlockReports();
         // 1 second should be enough for asynchronous BP finalize
         Sharpen.Thread.Sleep(1000);
         CheckResult(nameNodeDirs, dataNodeDirs, bpid);
         cluster.Shutdown();
         UpgradeUtilities.CreateEmptyDirs(nameNodeDirs);
         UpgradeUtilities.CreateEmptyDirs(dataNodeDirs);
     }
 }