use of org.apache.cassandra.io.FSDiskFullWriteError in project cassandra by apache.
the class Directories method getWriteableLocation.
/**
* Returns a non-blacklisted data directory that _currently_ has {@code writeSize} bytes as usable space, null if
* there is not enough space left in all directories.
*
* @throws FSWriteError if all directories are blacklisted.
*/
public DataDirectory getWriteableLocation(long writeSize) {
List<DataDirectoryCandidate> candidates = new ArrayList<>();
long totalAvailable = 0L;
// pick directories with enough space and so that resulting sstable dirs aren't blacklisted for writes.
boolean tooBig = false;
for (DataDirectory dataDir : paths) {
if (BlacklistedDirectories.isUnwritable(getLocationForDisk(dataDir))) {
logger.trace("removing blacklisted candidate {}", dataDir.location);
continue;
}
DataDirectoryCandidate candidate = new DataDirectoryCandidate(dataDir);
// exclude directory if its total writeSize does not fit to data directory
if (candidate.availableSpace < writeSize) {
logger.trace("removing candidate {}, usable={}, requested={}", candidate.dataDirectory.location, candidate.availableSpace, writeSize);
tooBig = true;
continue;
}
candidates.add(candidate);
totalAvailable += candidate.availableSpace;
}
if (candidates.isEmpty())
if (tooBig)
throw new FSDiskFullWriteError(new IOException("Insufficient disk space to write " + writeSize + " bytes"), "");
else
throw new FSWriteError(new IOException("All configured data directories have been blacklisted as unwritable for erroring out"), "");
// shortcut for single data directory systems
if (candidates.size() == 1)
return candidates.get(0).dataDirectory;
sortWriteableCandidates(candidates, totalAvailable);
return pickWriteableDirectory(candidates);
}
Aggregations