示例#1
0
 /**
  * Verify that the current and previous directories exist. Verify that previous hasn't been
  * modified by comparing the checksum of all it's containing files with their original checksum.
  * It is assumed that the server has recovered and upgraded. nsLevelUpgrade specify if the upgrade
  * is at top level or ns level nsLevelUpgrade=true, we search basedir/current/NS-id/previous
  * =false, we search basedir/previous
  */
 void checkResult(NodeType nodeType, String[] baseDirs, int nnIndex, boolean simulatedPrevious)
     throws IOException {
   switch (nodeType) {
     case NAME_NODE:
       for (int i = 0; i < baseDirs.length; i++) {
         assertTrue(new File(baseDirs[i], "current").isDirectory());
         assertTrue(new File(baseDirs[i], "current/VERSION").isFile());
         assertTrue(new File(baseDirs[i], "current/edits").isFile());
         assertTrue(new File(baseDirs[i], "current/fsimage").isFile());
         assertTrue(new File(baseDirs[i], "current/fstime").isFile());
       }
       break;
     case DATA_NODE:
       for (int i = 0; i < baseDirs.length; i++) {
         assertEquals(
             UpgradeUtilities.checksumContents(nodeType, new File(baseDirs[i], "current")),
             UpgradeUtilities.checksumMasterContents(nodeType));
         File nsBaseDir =
             NameSpaceSliceStorage.getNsRoot(
                 cluster.getNameNode(nnIndex).getNamespaceID(), new File(baseDirs[i], "current"));
         assertEquals(
             UpgradeUtilities.checksumContents(
                 nodeType, new File(nsBaseDir, MiniDFSCluster.FINALIZED_DIR_NAME)),
             UpgradeUtilities.checksumDatanodeNSStorageContents(nnIndex));
       }
       break;
   }
   for (int i = 0; i < baseDirs.length; i++) {
     switch (nodeType) {
       case NAME_NODE:
         assertTrue(new File(baseDirs[i], "previous").isDirectory());
         assertEquals(
             UpgradeUtilities.checksumContents(nodeType, new File(baseDirs[i], "previous")),
             UpgradeUtilities.checksumMasterContents(nodeType));
         break;
       case DATA_NODE:
         File nsBaseDir = null;
         nsBaseDir =
             NameSpaceSliceStorage.getNsRoot(
                 cluster.getNameNode(nnIndex).getNamespaceID(), new File(baseDirs[i], "current"));
         // Top level upgrade should not exist.
         assertFalse(new File(baseDirs[i], "previous").isDirectory() && !simulatedPrevious);
         assertTrue(new File(nsBaseDir, "previous").isDirectory());
         assertEquals(
             UpgradeUtilities.checksumContents(
                 nodeType, new File(nsBaseDir, "previous/finalized")),
             UpgradeUtilities.checksumDatanodeNSStorageContents(nnIndex));
     }
   }
 }
示例#2
0
 /**
  * Verify that the current directory exists and that the previous directory does not exist. Verify
  * that current hasn't been modified by comparing the checksum of all it's containing files with
  * their original checksum. Note that we do not check that previous is removed on the DataNode
  * because its removal is asynchronous therefore we have no reliable way to know when it will
  * happen.
  */
 void checkResult(String[] nameNodeDirs, String[] dataNodeDirs) throws IOException {
   for (int i = 0; i < nameNodeDirs.length; i++) {
     assertTrue(new File(nameNodeDirs[i], "current").isDirectory());
     assertTrue(new File(nameNodeDirs[i], "current/VERSION").isFile());
     assertTrue(new File(nameNodeDirs[i], "current/edits").isFile());
     assertTrue(new File(nameNodeDirs[i], "current/fsimage").isFile());
     assertTrue(new File(nameNodeDirs[i], "current/fstime").isFile());
   }
   for (int i = 0; i < dataNodeDirs.length; i++) {
     assertEquals(
         UpgradeUtilities.checksumContents(DATA_NODE, new File(dataNodeDirs[i], "current")),
         UpgradeUtilities.checksumMasterContents(DATA_NODE));
   }
   for (int i = 0; i < nameNodeDirs.length; i++) {
     assertFalse(new File(nameNodeDirs[i], "previous").isDirectory());
   }
 }