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);
}
}
}
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);
}
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);
}
}
}
}
}
}
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);
}
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);
}
Aggregations