Search in sources :

Example 6 with HDFSIOException

use of water.api.HDFSIOException in project h2o-3 by h2oai.

the class PersistHdfs method length.

@Override
public long length(String path) {
    Path p = new Path(path);
    URI uri = p.toUri();
    try {
        FileSystem fs = FileSystem.get(uri, CONF);
        return fs.getFileStatus(p).getLen();
    } catch (IOException e) {
        throw new HDFSIOException(path, CONF.toString(), e);
    }
}
Also used : HDFSIOException(water.api.HDFSIOException) IOException(java.io.IOException) URI(java.net.URI) HDFSIOException(water.api.HDFSIOException)

Example 7 with HDFSIOException

use of water.api.HDFSIOException in project h2o-3 by h2oai.

the class PersistHdfs method create.

@Override
public OutputStream create(String path, boolean overwrite) {
    Path p = new Path(path);
    URI uri = p.toUri();
    try {
        FileSystem fs = FileSystem.get(uri, CONF);
        return fs.create(p, overwrite);
    } catch (IOException e) {
        throw new HDFSIOException(path, CONF.toString(), e);
    }
}
Also used : HDFSIOException(water.api.HDFSIOException) IOException(java.io.IOException) URI(java.net.URI) HDFSIOException(water.api.HDFSIOException)

Example 8 with HDFSIOException

use of water.api.HDFSIOException in project h2o-3 by h2oai.

the class PersistHdfs method exists.

@Override
public boolean exists(String path) {
    Path p = new Path(path);
    URI uri = p.toUri();
    try {
        FileSystem fs = FileSystem.get(uri, CONF);
        return fs.exists(p);
    } catch (IOException e) {
        throw new HDFSIOException(path, CONF.toString(), e);
    }
}
Also used : HDFSIOException(water.api.HDFSIOException) IOException(java.io.IOException) URI(java.net.URI) HDFSIOException(water.api.HDFSIOException)

Example 9 with HDFSIOException

use of water.api.HDFSIOException in project h2o-3 by h2oai.

the class PersistHdfs method list.

@Override
public PersistEntry[] list(String path) {
    try {
        Path p = new Path(path);
        URI uri = p.toUri();
        FileSystem fs = FileSystem.get(uri, CONF);
        FileStatus[] arr1 = fs.listStatus(p);
        PersistEntry[] arr2 = new PersistEntry[arr1.length];
        for (int i = 0; i < arr1.length; i++) {
            arr2[i] = new PersistEntry(arr1[i].getPath().getName(), arr1[i].getLen(), arr1[i].getModificationTime());
        }
        return arr2;
    } catch (IOException e) {
        throw new HDFSIOException(path, CONF.toString(), e);
    }
}
Also used : HDFSIOException(water.api.HDFSIOException) IOException(java.io.IOException) URI(java.net.URI) HDFSIOException(water.api.HDFSIOException)

Example 10 with HDFSIOException

use of water.api.HDFSIOException in project h2o-3 by h2oai.

the class PersistHdfs method mkdirs.

@Override
public boolean mkdirs(String path) {
    Path p = new Path(path);
    URI uri = p.toUri();
    try {
        FileSystem fs = FileSystem.get(uri, CONF);
        // Be consistent with Java API and File#mkdirs
        if (fs.exists(p)) {
            return false;
        } else {
            return fs.mkdirs(p);
        }
    } catch (IOException e) {
        throw new HDFSIOException(path, CONF.toString(), e);
    }
}
Also used : HDFSIOException(water.api.HDFSIOException) IOException(java.io.IOException) URI(java.net.URI) HDFSIOException(water.api.HDFSIOException)

Aggregations

IOException (java.io.IOException)10 HDFSIOException (water.api.HDFSIOException)10 URI (java.net.URI)9