use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class CleanUp method archiveFile.
protected void archiveFile(VolumeManager fs, String dir, Table.ID tableId) throws IOException {
Path tableDirectory = new Path(dir, tableId.canonicalID());
Volume v = fs.getVolumeByPath(tableDirectory);
String basePath = v.getBasePath();
// Path component of URI
String tableDirPath = tableDirectory.toUri().getPath();
// Just the suffix of the path (after the Volume's base path)
String tableDirSuffix = tableDirPath.substring(basePath.length());
// Remove a leading path separator char because Path will treat the "child" as an absolute path with it
if (Path.SEPARATOR_CHAR == tableDirSuffix.charAt(0)) {
if (tableDirSuffix.length() > 1) {
tableDirSuffix = tableDirSuffix.substring(1);
} else {
tableDirSuffix = "";
}
}
// Get the file archive directory on this volume
final Path fileArchiveDir = new Path(basePath, ServerConstants.FILE_ARCHIVE_DIR);
// Make sure it exists just to be safe
fs.mkdirs(fileArchiveDir);
// The destination to archive this table to
final Path destTableDir = new Path(fileArchiveDir, tableDirSuffix);
log.debug("Archiving " + tableDirectory + " to " + tableDirectory);
if (fs.exists(destTableDir)) {
merge(fs, tableDirectory, destTableDir);
} else {
fs.rename(tableDirectory, destTableDir);
}
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method createNewFile.
@Override
public boolean createNewFile(Path path) throws IOException {
requireNonNull(path);
Volume v = getVolumeByPath(path);
return v.getFileSystem().createNewFile(path);
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class VolumeManagerImpl method isReady.
@Override
public boolean isReady() throws IOException {
for (Volume volume : getFileSystems().values()) {
final FileSystem fs = volume.getFileSystem();
if (!(fs instanceof DistributedFileSystem))
continue;
final DistributedFileSystem dfs = (DistributedFileSystem) fs;
// Returns true when safemode is on
if (dfs.setSafeMode(SafeModeAction.SAFEMODE_GET)) {
return false;
}
}
return true;
}
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, int bufferSize, short replication, long blockSize) throws IOException {
requireNonNull(path);
Volume v = getVolumeByPath(path);
FileSystem fs = v.getFileSystem();
blockSize = correctBlockSize(fs.getConf(), blockSize);
bufferSize = correctBufferSize(fs.getConf(), bufferSize);
return fs.create(path, overwrite, bufferSize, replication, blockSize);
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class ChangeSecret method verifyHdfsWritePermission.
private static void verifyHdfsWritePermission(VolumeManager fs) throws Exception {
for (Volume v : fs.getVolumes()) {
final Path instanceId = ServerConstants.getInstanceIdLocation(v);
FileStatus fileStatus = v.getFileSystem().getFileStatus(instanceId);
checkHdfsAccessPermissions(fileStatus, FsAction.WRITE);
}
}
Aggregations