@@ -1143,7 +1143,6 @@ public long getBufferSize() {
11431143 static abstract class TestBase {
11441144 private final long everyN ;
11451145
1146- protected final Random rand = ThreadLocalRandom .current ();
11471146 protected final Configuration conf ;
11481147 protected final TestOptions opts ;
11491148
@@ -1174,14 +1173,15 @@ static abstract class TestBase {
11741173 this .testName = this .getClass ().getSimpleName ();
11751174 everyN = (long ) (opts .totalRows / (opts .totalRows * opts .sampleRate ));
11761175 if (options .isValueZipf ()) {
1177- this .zipf = new RandomDistribution .Zipf (this .rand , 1 , options .getValueSize (), 1.2 );
1176+ this .zipf =
1177+ new RandomDistribution .Zipf (ThreadLocalRandom .current (), 1 , options .getValueSize (), 1.2 );
11781178 }
11791179 LOG .info ("Sampling 1 every " + everyN + " out of " + opts .perClientRunRows + " total rows." );
11801180 }
11811181
1182- int getValueLength (final Random r ) {
1182+ int getValueLength () {
11831183 if (this .opts .isValueRandom ()) {
1184- return r .nextInt (opts .valueSize );
1184+ return ThreadLocalRandom . current () .nextInt (opts .valueSize );
11851185 } else if (this .opts .isValueZipf ()) {
11861186 return Math .abs (this .zipf .nextInt ());
11871187 } else {
@@ -1715,9 +1715,9 @@ boolean testRow(final long i, final long startTime) throws IOException, Interrup
17151715 byte [] familyName = Bytes .toBytes (FAMILY_NAME_BASE + family );
17161716 for (int column = 0 ; column < opts .columns ; column ++) {
17171717 byte [] qualifier = column == 0 ? COLUMN_ZERO : Bytes .toBytes ("" + column );
1718- byte [] value = generateData (this . rand , getValueLength (this . rand ));
1718+ byte [] value = generateData (getValueLength ());
17191719 if (opts .useTags ) {
1720- byte [] tag = generateData (this . rand , TAG_LENGTH );
1720+ byte [] tag = generateData (TAG_LENGTH );
17211721 Tag [] tags = new Tag [opts .noOfTags ];
17221722 for (int n = 0 ; n < opts .noOfTags ; n ++) {
17231723 Tag t = new ArrayBackedTag ((byte ) n , tag );
@@ -2368,9 +2368,9 @@ boolean testRow(final long i, final long startTime) throws IOException {
23682368 byte familyName [] = Bytes .toBytes (FAMILY_NAME_BASE + family );
23692369 for (int column = 0 ; column < opts .columns ; column ++) {
23702370 byte [] qualifier = column == 0 ? COLUMN_ZERO : Bytes .toBytes ("" + column );
2371- byte [] value = generateData (this . rand , getValueLength (this . rand ));
2371+ byte [] value = generateData (getValueLength ());
23722372 if (opts .useTags ) {
2373- byte [] tag = generateData (this . rand , TAG_LENGTH );
2373+ byte [] tag = generateData (TAG_LENGTH );
23742374 Tag [] tags = new Tag [opts .noOfTags ];
23752375 for (int n = 0 ; n < opts .noOfTags ; n ++) {
23762376 Tag t = new ArrayBackedTag ((byte ) n , tag );
@@ -2453,7 +2453,7 @@ boolean testRow(final long i, final long startTime) throws IOException {
24532453
24542454 // write the serverName columns
24552455 MetaTableAccessor .updateRegionLocation (connection , regionInfo ,
2456- ServerName .valueOf ("localhost" , 60010 , rand .nextLong ()), i ,
2456+ ServerName .valueOf ("localhost" , 60010 , ThreadLocalRandom . current () .nextLong ()), i ,
24572457 EnvironmentEdgeManager .currentTime ());
24582458 return true ;
24592459 }
@@ -2472,7 +2472,7 @@ static class FilteredScanTest extends TableTest {
24722472
24732473 @ Override
24742474 boolean testRow (long i , final long startTime ) throws IOException {
2475- byte [] value = generateData (this . rand , getValueLength (this . rand ));
2475+ byte [] value = generateData (getValueLength ());
24762476 Scan scan = constructScan (value );
24772477 ResultScanner scanner = null ;
24782478 try {
@@ -2548,10 +2548,11 @@ public static byte[] format(final long number) {
25482548 * test, generation of the key and value consumes about 30% of CPU time.
25492549 * @return Generated random value to insert into a table cell.
25502550 */
2551- public static byte [] generateData (final Random r , int length ) {
2551+ public static byte [] generateData (int length ) {
25522552 byte [] b = new byte [length ];
25532553 int i ;
25542554
2555+ Random r = ThreadLocalRandom .current ();
25552556 for (i = 0 ; i < (length - 8 ); i += 8 ) {
25562557 b [i ] = (byte ) (65 + r .nextInt (26 ));
25572558 b [i + 1 ] = b [i ];
0 commit comments