HADOOP-15109. TestDFSIO -read -random doesn't work on file sized 4GB. Contributed by Ajay Kumar.
This commit is contained in:
parent
811fabdebe
commit
c7a4dda3c5
@ -31,8 +31,8 @@
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
||||
@ -582,7 +582,7 @@ private long readTest(FileSystem fs) throws IOException {
|
||||
* 3) Skip-read skips skipSize bytes after every read : skipSize > 0
|
||||
*/
|
||||
public static class RandomReadMapper extends IOStatMapper {
|
||||
private Random rnd;
|
||||
private ThreadLocalRandom rnd;
|
||||
private long fileSize;
|
||||
private long skipSize;
|
||||
|
||||
@ -593,7 +593,7 @@ public void configure(JobConf conf) {
|
||||
}
|
||||
|
||||
public RandomReadMapper() {
|
||||
rnd = new Random();
|
||||
rnd = ThreadLocalRandom.current();
|
||||
}
|
||||
|
||||
@Override // IOMapperBase
|
||||
@ -635,8 +635,8 @@ public Long doIO(Reporter reporter,
|
||||
* @return
|
||||
*/
|
||||
private long nextOffset(long current) {
|
||||
if(skipSize == 0)
|
||||
return rnd.nextInt((int)(fileSize));
|
||||
if (skipSize == 0)
|
||||
return rnd.nextLong(fileSize);
|
||||
if(skipSize > 0)
|
||||
return (current < 0) ? 0 : (current + bufferSize + skipSize);
|
||||
// skipSize < 0
|
||||
|
Loading…
Reference in New Issue
Block a user