List of usage examples for org.apache.hadoop.hdfs.server.namenode FSNamesystem FSNamesystem
FSNamesystem(Configuration conf, FSImage fsImage) throws IOException
From source file:common.NameNode.java
License:Apache License
/** * Verify that configured directories exist, then * Interactively confirm that formatting is desired * for each existing directory and format them. * //from www .ja v a2s .c om * @param conf * @param isConfirmationNeeded * @return true if formatting was aborted, false otherwise * @throws IOException */ private static boolean format(Configuration conf, boolean isConfirmationNeeded) throws IOException { Collection<URI> dirsToFormat = FSNamesystem.getNamespaceDirs(conf); Collection<URI> editDirsToFormat = FSNamesystem.getNamespaceEditsDirs(conf); for (Iterator<URI> it = dirsToFormat.iterator(); it.hasNext();) { File curDir = new File(it.next().getPath()); if (!curDir.exists()) continue; if (isConfirmationNeeded) { System.err.print("Re-format filesystem in " + curDir + " ? (Y or N) "); if (!(System.in.read() == 'Y')) { System.err.println("Format aborted in " + curDir); return true; } while (System.in.read() != '\n') ; // discard the enter-key } } FSNamesystem nsys = new FSNamesystem(new FSImage(dirsToFormat, editDirsToFormat), conf); nsys.dir.fsImage.format(); return false; }
From source file:common.NameNode.java
License:Apache License
private static boolean finalize(Configuration conf, boolean isConfirmationNeeded) throws IOException { Collection<URI> dirsToFormat = FSNamesystem.getNamespaceDirs(conf); Collection<URI> editDirsToFormat = FSNamesystem.getNamespaceEditsDirs(conf); FSNamesystem nsys = new FSNamesystem(new FSImage(dirsToFormat, editDirsToFormat), conf); System.err.print("\"finalize\" will remove the previous state of the files system.\n" + "Recent upgrade will become permanent.\n" + "Rollback option will not be available anymore.\n"); if (isConfirmationNeeded) { System.err.print("Finalize filesystem state ? (Y or N) "); if (!(System.in.read() == 'Y')) { System.err.println("Finalize aborted."); return true; }/* w w w . j a v a 2s .c o m*/ while (System.in.read() != '\n') ; // discard the enter-key } nsys.dir.fsImage.finalizeUpgrade(); return false; }