Example usage for org.apache.hadoop.util DiskChecker checkDir

List of usage examples for org.apache.hadoop.util DiskChecker checkDir

Introduction

In this page you can find the example usage for org.apache.hadoop.util DiskChecker checkDir.

Prototype

public static void checkDir(LocalFileSystem localFS, Path dir, FsPermission expected)
        throws DiskErrorException, IOException 

Source Link

Document

Create the local directory if necessary, check permissions and also ensure it can be read from and written into.

Usage

From source file:common.DataNode.java

License:Apache License

static ArrayList<File> getDataDirsFromURIs(Collection<URI> dataDirs, LocalFileSystem localFS,
        FsPermission permission) {//w w  w.  ja  va  2 s .c o m
    ArrayList<File> dirs = new ArrayList<File>();
    for (URI dirURI : dataDirs) {
        if (!"file".equalsIgnoreCase(dirURI.getScheme())) {
            LOG.warn("Unsupported URI schema in " + dirURI + ". Ignoring ...");
            continue;
        }
        // drop any (illegal) authority in the URI for backwards compatibility
        File data = new File(dirURI.getPath());
        try {
            DiskChecker.checkDir(localFS, new Path(data.toURI()), permission);
            dirs.add(data);
        } catch (IOException e) {
            LOG.warn(
                    "Invalid directory in: " + DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY + ": " + e.getMessage());
        }
    }
    return dirs;
}