HDFS-17471. Correct the percentage of sample range. (#6742). Contributed by fuchaohong.

Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
fuchaohong 2024-04-30 12:18:47 +08:00 committed by GitHub
parent 78987a71a6
commit ddb805951e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ public BlockReaderIoProvider(@Nullable ShortCircuitConf conf,
public int read(FileChannel dataIn, ByteBuffer dst, long position) public int read(FileChannel dataIn, ByteBuffer dst, long position)
throws IOException{ throws IOException{
final int nRead; final int nRead;
if (isEnabled && (ThreadLocalRandom.current().nextInt() < sampleRangeMax)) { if (isEnabled && (ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE) < sampleRangeMax)) {
long begin = timer.monotonicNow(); long begin = timer.monotonicNow();
nRead = dataIn.read(dst, position); nRead = dataIn.read(dst, position);
long latency = timer.monotonicNow() - begin; long latency = timer.monotonicNow() - begin;

View File

@ -80,7 +80,7 @@ public void afterMetadataOp(@Nullable FsVolumeSpi volume,
public long beforeFileIo(@Nullable FsVolumeSpi volume, public long beforeFileIo(@Nullable FsVolumeSpi volume,
FileIoProvider.OPERATION op, long len) { FileIoProvider.OPERATION op, long len) {
if (isEnabled && ThreadLocalRandom.current().nextInt() < sampleRangeMax) { if (isEnabled && ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE) < sampleRangeMax) {
DataNodeVolumeMetrics metrics = getVolumeMetrics(volume); DataNodeVolumeMetrics metrics = getVolumeMetrics(volume);
if (metrics != null) { if (metrics != null) {
return Time.monotonicNow(); return Time.monotonicNow();