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:
parent
78987a71a6
commit
ddb805951e
@ -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;
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user