HDFS-17184. Improve BlockReceiver to throws DiskOutOfSpaceException when initialize. (#6044). Contributed by Haiyang Hu.

Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
huhaiyang 2023-09-21 21:45:30 +08:00 committed by GitHub
parent 27cb551821
commit cc66683b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -57,6 +57,7 @@
import org.apache.hadoop.util.DataChecksum;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
import org.apache.hadoop.tracing.Span;
import org.apache.hadoop.tracing.Tracer;
@ -274,10 +275,9 @@ class BlockReceiver implements Closeable {
if (isCreate) {
BlockMetadataHeader.writeHeader(checksumOut, diskChecksum);
}
} catch (ReplicaAlreadyExistsException bae) {
throw bae;
} catch (ReplicaNotFoundException bne) {
throw bne;
} catch (ReplicaAlreadyExistsException | ReplicaNotFoundException
| DiskOutOfSpaceException e) {
throw e;
} catch(IOException ioe) {
if (replicaInfo != null) {
replicaInfo.releaseAllBytesReserved();

View File

@ -117,14 +117,13 @@ private V chooseVolume(final int curVolumeIndex, final List<V> volumes,
maxAvailable = availableVolumeSize;
}
LOG.warn("The volume[{}] with the available space (={} B) is "
+ "less than the block size (={} B).", volume.getBaseURI(),
availableVolumeSize, blockSize);
if (curVolume == startVolume) {
throw new DiskOutOfSpaceException("Out of space: "
+ "The volume with the most available space (=" + maxAvailable
+ " B) is less than the block size (=" + blockSize + " B).");
} else {
LOG.warn("The volume[{}] with the available space (={} B) is "
+ "less than the block size (={} B).", volume.getBaseURI(),
availableVolumeSize, blockSize);
}
}
}