Example usage for org.apache.hadoop.hdfs.server.namenode FSNamesystem getNamespaceEditsDirs

List of usage examples for org.apache.hadoop.hdfs.server.namenode FSNamesystem getNamespaceEditsDirs

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.namenode FSNamesystem getNamespaceEditsDirs.

Prototype

public static List<URI> getNamespaceEditsDirs(Configuration conf) throws IOException 

Source Link

Document

Return an ordered list of edits directories to write to.

Usage

From source file:com.mellanox.r4h.MiniDFSCluster.java

License:Apache License

/**
 * Get the directories where the namenode stores its edits.
 *//*from   w ww  .j av a 2  s  .c  om*/
public Collection<URI> getNameEditsDirs(int nnIndex) throws IOException {
    return FSNamesystem.getNamespaceEditsDirs(nameNodes[nnIndex].conf);
}

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  w w  w .  j a v a  2 s . c  o m
 * @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  ww.  java  2 s  .  com
        while (System.in.read() != '\n')
            ; // discard the enter-key
    }
    nsys.dir.fsImage.finalizeUpgrade();
    return false;
}