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.io.PrintStream;
|
|||
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 @@ public class TestDFSIO implements Tool {
|
|||
* 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 class TestDFSIO implements Tool {
|
|||
}
|
||||
|
||||
public RandomReadMapper() {
|
||||
rnd = new Random();
|
||||
rnd = ThreadLocalRandom.current();
|
||||
}
|
||||
|
||||
@Override // IOMapperBase
|
||||
|
@ -636,7 +636,7 @@ public class TestDFSIO implements Tool {
|
|||
*/
|
||||
private long nextOffset(long current) {
|
||||
if (skipSize == 0)
|
||||
return rnd.nextInt((int)(fileSize));
|
||||
return rnd.nextLong(fileSize);
|
||||
if(skipSize > 0)
|
||||
return (current < 0) ? 0 : (current + bufferSize + skipSize);
|
||||
// skipSize < 0
|
||||
|
|
Loading…
Reference in New Issue