Search in sources :

Example 1 with Volume

use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.

the class Accumulo method updateAccumuloVersion.

public static synchronized void updateAccumuloVersion(VolumeManager fs, int oldVersion) {
    for (Volume volume : fs.getVolumes()) {
        try {
            if (getAccumuloPersistentVersion(volume) == oldVersion) {
                log.debug("Attempting to upgrade {}", volume);
                Path dataVersionLocation = ServerConstants.getDataVersionLocation(volume);
                fs.create(new Path(dataVersionLocation, Integer.toString(ServerConstants.DATA_VERSION))).close();
                // TODO document failure mode & recovery if FS permissions cause above to work and below to fail ACCUMULO-2596
                Path prevDataVersionLoc = new Path(dataVersionLocation, Integer.toString(oldVersion));
                if (!fs.delete(prevDataVersionLoc)) {
                    throw new RuntimeException("Could not delete previous data version location (" + prevDataVersionLoc + ") for " + volume);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to set accumulo version: an error occurred.", e);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Volume(org.apache.accumulo.core.volume.Volume) IOException(java.io.IOException)

Example 2 with Volume

use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.

the class SimpleGarbageCollector method archiveFile.

/**
 * Move a file, that would otherwise be deleted, to the archive directory for files
 *
 * @param fileToArchive
 *          Path to file that is to be archived
 * @return True if the file was successfully moved to the file archive directory, false otherwise
 */
boolean archiveFile(Path fileToArchive) throws IOException {
    // Figure out what the base path this volume uses on this FileSystem
    Volume sourceVolume = fs.getVolumeByPath(fileToArchive);
    String sourceVolumeBasePath = sourceVolume.getBasePath();
    log.debug("Base path for volume: {}", sourceVolumeBasePath);
    // Get the path for the file we want to archive
    String sourcePathBasePath = fileToArchive.toUri().getPath();
    // Strip off the common base path for the file to archive
    String relativeVolumePath = sourcePathBasePath.substring(sourceVolumeBasePath.length());
    if (Path.SEPARATOR_CHAR == relativeVolumePath.charAt(0)) {
        if (relativeVolumePath.length() > 1) {
            relativeVolumePath = relativeVolumePath.substring(1);
        } else {
            relativeVolumePath = "";
        }
    }
    log.debug("Computed relative path for file to archive: {}", relativeVolumePath);
    // The file archive path on this volume (we can't archive this file to a different volume)
    Path archivePath = new Path(sourceVolumeBasePath, ServerConstants.FILE_ARCHIVE_DIR);
    log.debug("File archive path: {}", archivePath);
    fs.mkdirs(archivePath);
    // Preserve the path beneath the Volume's base directory (e.g. tables/1/A_0000001.rf)
    Path fileArchivePath = new Path(archivePath, relativeVolumePath);
    log.debug("Create full path of {} from {} and {}", fileArchivePath, archivePath, relativeVolumePath);
    // Make sure that it doesn't already exist, something is wrong.
    if (fs.exists(fileArchivePath)) {
        log.warn("Tried to archive file, but it already exists: {}", fileArchivePath);
        return false;
    }
    log.debug("Moving {} to {}", fileToArchive, fileArchivePath);
    return fs.rename(fileToArchive, fileArchivePath);
}
Also used : Path(org.apache.hadoop.fs.Path) Volume(org.apache.accumulo.core.volume.Volume)

Example 3 with Volume

use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.

the class VolumeManagerImpl method ensureSyncIsEnabled.

protected void ensureSyncIsEnabled() {
    for (Entry<String, Volume> entry : getFileSystems().entrySet()) {
        FileSystem fs = entry.getValue().getFileSystem();
        if (fs instanceof DistributedFileSystem) {
            // Avoid use of DFSConfigKeys since it's private
            final String DFS_SUPPORT_APPEND = "dfs.support.append", DFS_DATANODE_SYNCONCLOSE = "dfs.datanode.synconclose";
            final String ticketMessage = "See ACCUMULO-623 and ACCUMULO-1637 for more details.";
            // This is a sign that someone is writing bad configuration.
            if (!fs.getConf().getBoolean(DFS_SUPPORT_APPEND, true)) {
                String msg = "Accumulo requires that " + DFS_SUPPORT_APPEND + " not be configured as false. " + ticketMessage;
                // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility
                log.error("FATAL {}", msg);
                throw new RuntimeException(msg);
            }
            // Warn if synconclose isn't set
            if (!fs.getConf().getBoolean(DFS_DATANODE_SYNCONCLOSE, false)) {
                // Only warn once per process per volume URI
                synchronized (WARNED_ABOUT_SYNCONCLOSE) {
                    if (!WARNED_ABOUT_SYNCONCLOSE.contains(entry.getKey())) {
                        WARNED_ABOUT_SYNCONCLOSE.add(entry.getKey());
                        log.warn("{} set to false in hdfs-site.xml: data loss is possible on hard system reset or power loss", DFS_DATANODE_SYNCONCLOSE);
                    }
                }
            }
        }
    }
}
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 4 with Volume

use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.

the class VolumeManagerImpl method getLocal.

public static org.apache.accumulo.server.fs.VolumeManager getLocal(String localBasePath) throws IOException {
    AccumuloConfiguration accConf = DefaultConfiguration.getInstance();
    Volume defaultLocalVolume = VolumeConfiguration.create(FileSystem.getLocal(CachedConfiguration.getInstance()), localBasePath);
    // The default volume gets placed in the map, but local filesystem is only used for testing purposes
    return new VolumeManagerImpl(Collections.singletonMap(DEFAULT, defaultLocalVolume), defaultLocalVolume, accConf);
}
Also used : Volume(org.apache.accumulo.core.volume.Volume) NonConfiguredVolume(org.apache.accumulo.core.volume.NonConfiguredVolume) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

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

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