HADOOP-16585. [Tool:NNloadGeneratorMR] Multiple threads are using same id for creating file LoadGenerator#write. Contributed by Ranith Sardar.

This commit is contained in:
Surendra Singh Lilhore 2019-11-14 01:45:46 +05:30
parent 586defe711
commit 73a386ab76
1 changed files with 3 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Random;
import java.util.UUID;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
@ -295,7 +296,8 @@ public class LoadGenerator extends Configured implements Tool {
*/
private void write() throws IOException {
String dirName = dirs.get(r.nextInt(dirs.size()));
Path file = new Path(dirName, hostname+id);
Path file =
new Path(dirName, hostname + id + UUID.randomUUID().toString());
double fileSize = 0;
while ((fileSize = r.nextGaussian()+2)<=0) {}
genFile(file, (long)(fileSize*BLOCK_SIZE));