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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations