use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method rename.
@Override
public boolean rename(Path path, Path newPath) throws IOException {
Volume srcVolume = getVolumeByPath(path);
Volume destVolume = getVolumeByPath(newPath);
FileSystem source = srcVolume.getFileSystem();
FileSystem dest = destVolume.getFileSystem();
if (source != dest) {
throw new NotImplementedException("Cannot rename files across volumes: " + path + " -> " + newPath);
}
return source.rename(path, newPath);
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method create.
@Override
public FSDataOutputStream create(Path path, boolean overwrite) throws IOException {
requireNonNull(path);
Volume v = getVolumeByPath(path);
return v.getFileSystem().create(path, overwrite);
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method createSyncable.
@Override
public FSDataOutputStream createSyncable(Path logPath, int bufferSize, short replication, long blockSize) throws IOException {
Volume v = getVolumeByPath(logPath);
FileSystem fs = v.getFileSystem();
blockSize = correctBlockSize(fs.getConf(), blockSize);
bufferSize = correctBufferSize(fs.getConf(), bufferSize);
EnumSet<CreateFlag> set = EnumSet.of(CreateFlag.SYNC_BLOCK, CreateFlag.CREATE);
log.debug("creating {} with CreateFlag set: {}", logPath, set);
try {
return fs.create(logPath, FsPermission.getDefault(), set, bufferSize, replication, blockSize, null);
} catch (Exception ex) {
log.debug("Exception", ex);
return fs.create(logPath, true, bufferSize, replication, blockSize);
}
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method getVolumeByPath.
@Override
public Volume getVolumeByPath(Path path) {
if (path.toString().contains(":")) {
try {
FileSystem desiredFs = path.getFileSystem(CachedConfiguration.getInstance());
URI desiredFsUri = desiredFs.getUri();
Collection<Volume> candidateVolumes = volumesByFileSystemUri.get(desiredFsUri);
if (null != candidateVolumes) {
for (Volume candidateVolume : candidateVolumes) {
if (candidateVolume.isValidPath(path)) {
return candidateVolume;
}
}
} else {
log.debug("Could not determine volume for Path: {}", path);
}
return new NonConfiguredVolume(desiredFs);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
return defaultVolume;
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class FileUtil method cleanupIndexOp.
protected static void cleanupIndexOp(Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
// close all of the index sequence files
for (FileSKVIterator r : readers) {
try {
if (r != null)
r.close();
} catch (IOException e) {
// okay, try to close the rest anyway
log.error("{}", e.getMessage(), e);
}
}
if (tmpDir != null) {
Volume v = fs.getVolumeByPath(tmpDir);
if (v.getFileSystem().exists(tmpDir)) {
fs.deleteRecursively(tmpDir);
return;
}
log.error("Did not delete tmp dir because it wasn't a tmp dir {}", tmpDir);
}
}
Aggregations