Search in sources :

Example 11 with Volume

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Volume(org.apache.accumulo.core.volume.Volume)

Example 12 with Volume

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);
}
Also used : Volume(org.apache.accumulo.core.volume.Volume) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume)

Example 13 with Volume

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;
}
Also used : Volume(org.apache.accumulo.core.volume.Volume) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem)

Example 14 with Volume

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);
}
Also used : Volume(org.apache.accumulo.core.volume.Volume) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem)

Example 15 with Volume

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) Volume(org.apache.accumulo.core.volume.Volume)

Aggregations

Volume (org.apache.accumulo.core.volume.Volume)17 NonConfiguredVolume (org.apache.accumulo.core.volume.NonConfiguredVolume)10 FileSystem (org.apache.hadoop.fs.FileSystem)7 Path (org.apache.hadoop.fs.Path)6 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)6 IOException (java.io.IOException)5 NotImplementedException (org.apache.commons.lang.NotImplementedException)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 URI (java.net.URI)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 FileSKVIterator (org.apache.accumulo.core.file.FileSKVIterator)1 VolumeChooserException (org.apache.accumulo.server.fs.VolumeChooser.VolumeChooserException)1 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)1 CreateFlag (org.apache.hadoop.fs.CreateFlag)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 Test (org.junit.Test)1