Search in sources :

Example 6 with Volume

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);
}
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) NotImplementedException(org.apache.commons.lang.NotImplementedException)

Example 7 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) throws IOException {
    requireNonNull(path);
    Volume v = getVolumeByPath(path);
    return v.getFileSystem().create(path, overwrite);
}
Also used : Volume(org.apache.accumulo.core.volume.Volume) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume)

Example 8 with Volume

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);
    }
}
Also used : CreateFlag(org.apache.hadoop.fs.CreateFlag) 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) VolumeChooserException(org.apache.accumulo.server.fs.VolumeChooser.VolumeChooserException) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException)

Example 9 with Volume

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;
}
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) IOException(java.io.IOException) URI(java.net.URI) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume)

Example 10 with Volume

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);
    }
}
Also used : FileSKVIterator(org.apache.accumulo.core.file.FileSKVIterator) Volume(org.apache.accumulo.core.volume.Volume) IOException(java.io.IOException)

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