/**
  * Simulate the <code>dfs.name.dir</code> or <code>dfs.data.dir</code> of a populated DFS
  * filesystem.
  *
  * <p>This method creates and populates the directory specified by <code>parent/dirName</code>,
  * for each parent directory. The contents of the new directories will be appropriate for the
  * given node type. If the directory does not exist, it will be created. If the directory already
  * exists, it will first be deleted.
  *
  * <p>By default, a singleton master populated storage directory is created for a Namenode
  * (contains edits, fsimage, version, and time files) and a Datanode (contains version and block
  * files). These directories are then copied by this method to create new storage directories of
  * the appropriate type (Namenode or Datanode).
  *
  * @return the array of created directories
  */
 public static File[] createStorageDirs(NodeType nodeType, String[] parents, String dirName)
     throws Exception {
   File[] retVal = new File[parents.length];
   for (int i = 0; i < parents.length; i++) {
     File newDir = new File(parents[i], dirName);
     createEmptyDirs(new String[] {newDir.toString()});
     LocalFileSystem localFS = FileSystem.getLocal(new Configuration());
     switch (nodeType) {
       case NAME_NODE:
         localFS.copyToLocalFile(
             new Path(namenodeStorage.toString(), "current"), new Path(newDir.toString()), false);
         Path newImgDir = new Path(newDir.getParent(), "image");
         if (!localFS.exists(newImgDir))
           localFS.copyToLocalFile(
               new Path(namenodeStorage.toString(), "image"), newImgDir, false);
         break;
       case DATA_NODE:
         localFS.copyToLocalFile(
             new Path(datanodeStorage.toString(), "current"), new Path(newDir.toString()), false);
         Path newStorageFile = new Path(newDir.getParent(), "storage");
         if (!localFS.exists(newStorageFile))
           localFS.copyToLocalFile(
               new Path(datanodeStorage.toString(), "storage"), newStorageFile, false);
         break;
     }
     retVal[i] = newDir;
   }
   return retVal;
 }