Commit 854a0962 authored by Costin Grigoras's avatar Costin Grigoras
Browse files

More places where ThreadLocalRandom can be used

parent 04fdc3c8
......@@ -7,10 +7,10 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
......@@ -118,10 +118,6 @@ public class CatalogueTestWhereisGenerated {
* Suffix for column family name
*/
static String lfntable = "_auto";
/**
* Random number generator
*/
static final Random rdm = new Random();
/**
* Monitoring component
*/
......@@ -274,7 +270,7 @@ public class CatalogueTestWhereisGenerated {
}
else {
type_last_op = "read";
final long newValue = ((long) (rdm.nextGaussian() * stddev)) + (limit_minus_base / 2);
final long newValue = ((long) (ThreadLocalRandom.current().nextGaussian() * stddev)) + (limit_minus_base / 2);
if (newValue < base || newValue > limit)
continue;
last_value = newValue;
......@@ -447,8 +443,8 @@ public class CatalogueTestWhereisGenerated {
}
final LFN_CSD lfnc = new LFN_CSD(lfnparent + lfn, false, lfntable, null, null);
lfnc.size = rdm.nextInt(100000);
lfnc.jobid = rdm.nextInt(1000000);
lfnc.size = ThreadLocalRandom.current().nextInt(100000);
lfnc.jobid = ThreadLocalRandom.current().nextInt(1000000);
lfnc.checksum = "ee31e454013aa515f0bc806aa907ba51";
lfnc.perm = "755";
lfnc.ctime = ctime_fixed;
......@@ -459,8 +455,8 @@ public class CatalogueTestWhereisGenerated {
final HashMap<Integer, String> pfns = new HashMap<>();
if (i % 2 == 0) {
lfnc.type = 'f';
pfns.put(Integer.valueOf(rdm.nextInt(30)), "");
pfns.put(Integer.valueOf(rdm.nextInt(30)), "");
pfns.put(Integer.valueOf(ThreadLocalRandom.current().nextInt(30)), "");
pfns.put(Integer.valueOf(ThreadLocalRandom.current().nextInt(30)), "");
}
else {
lfnc.type = 'l';
......@@ -510,8 +506,6 @@ public class CatalogueTestWhereisGenerated {
}
System.out.println("Ready to accept HTTP calls on " + tomcat.getAddress() + ":" + tomcat.getPort());
return;
}
}
......@@ -13,11 +13,11 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -127,10 +127,7 @@ public class CatalogueToCassandraThreads {
* Counter stuck threads
*/
static int count_thread_stuck = 0;
/**
* Random generator
*/
static final Random rdm = new Random();
/**
* Default Cassandra consistency
*/
......@@ -154,9 +151,9 @@ public class CatalogueToCassandraThreads {
for (int i = 1; i < args.length; i++)
newargs[i - 1] = args[i];
if (args[0].equals("real"))
if ("real".equals(args[0]))
main_real(newargs);
else if (args[0].equals("auto"))
else if ("auto".equals(args[0]))
main_auto(newargs);
else {
System.err.println("Usage: CatalogueToCassandraThreads real|auto ");
......@@ -476,8 +473,8 @@ public class CatalogueToCassandraThreads {
}
final LFN_CSD lfnc = new LFN_CSD(lfnparent + lfn, false, "_auto", null, null);
lfnc.size = rdm.nextInt(100000);
lfnc.jobid = rdm.nextInt(1000000);
lfnc.size = ThreadLocalRandom.current().nextInt(100000);
lfnc.jobid = ThreadLocalRandom.current().nextInt(1000000);
lfnc.checksum = "ee31e454013aa515f0bc806aa907ba51";
lfnc.perm = "755";
lfnc.ctime = ctime_fixed;
......@@ -488,8 +485,8 @@ public class CatalogueToCassandraThreads {
final HashMap<Integer, String> pfns = new HashMap<>();
if (i % 2 == 0) {
lfnc.type = 'f';
pfns.put(Integer.valueOf(rdm.nextInt(30)), "");
pfns.put(Integer.valueOf(rdm.nextInt(30)), "");
pfns.put(Integer.valueOf(ThreadLocalRandom.current().nextInt(30)), "");
pfns.put(Integer.valueOf(ThreadLocalRandom.current().nextInt(30)), "");
}
else {
lfnc.type = 'l';
......
......@@ -5,8 +5,8 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -88,11 +88,6 @@ public class CatalogueToCatalogueThreads {
*/
static String logs_suffix = "";
/**
* Random number generator
*/
static Random rdm = new Random();
/**
* One SE
*/
......@@ -249,9 +244,9 @@ public class CatalogueToCatalogueThreads {
final LFN lfnc = LFNUtils.getLFN(lfn, true);
final GUID guid = GUIDUtils.createGuid();
lfnc.size = rdm.nextInt(100000);
lfnc.size = ThreadLocalRandom.current().nextInt(100000);
lfnc.guid = guid.guid;
lfnc.jobid = rdm.nextInt(1000000);
lfnc.jobid = ThreadLocalRandom.current().nextInt(1000000);
lfnc.md5 = "ee31e454013aa515f0bc806aa907ba51";
lfnc.type = 'f';
lfnc.perm = "755";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment