diff --git a/src/LoadData/LoadData.java b/src/LoadData/LoadData.java index 01da0a29b88402e9b23032368848d81204409613..bed929aa8b60886eaa97db927cb29509234e45d9 100644 --- a/src/LoadData/LoadData.java +++ b/src/LoadData/LoadData.java @@ -68,11 +68,12 @@ public class LoadData } argv = args; + long randomSeed = Long.parseLong(ini.getProperty("jTPCCRandomSeed", System.nanoTime() + "")); /* * Initialize the global Random generator that picks the * C values for the load. */ - rnd = new jTPCCRandom(); + rnd = new jTPCCRandom(randomSeed); /* * Load the JDBC driver and prepare the db and dbProps. diff --git a/src/client/jTPCC.java b/src/client/jTPCC.java index 1efdfbba9523b9f6eaf76d87511685201acf58d9..71af4bb476cc0cd5e8df52b487a8fa623425a432 100644 --- a/src/client/jTPCC.java +++ b/src/client/jTPCC.java @@ -353,9 +353,11 @@ public class jTPCC implements jTPCCConfig errorMessage(e.getMessage()); throw e; } - this.rnd = new jTPCCRandom(CLoad); + long randomSeed = Long.parseLong(ini.getProperty("jTPCCRandomSeed", System.nanoTime() + "")); + this.rnd = new jTPCCRandom(CLoad, randomSeed); log.info("Term-00, C value for C_LAST during load: " + CLoad); log.info("Term-00, C value for C_LAST this run: " + rnd.getNURandCLast()); + log.info("Term-00, jTPCCRandom seed: " + randomSeed); log.info("Term-00, "); ShardingNumber.init(rnd.getNURandCI_ID()); diff --git a/src/client/jTPCCRandom.java b/src/client/jTPCCRandom.java index 0bd70fe88e7a544aaede535f27b44f0776d88c13..de7554b825566efe39c0a083d4d561232d3f1b63 100644 --- a/src/client/jTPCCRandom.java +++ b/src/client/jTPCCRandom.java @@ -9,7 +9,7 @@ */ -import java.util.concurrent.ThreadLocalRandom; +import java.util.Random; public class jTPCCRandom { @@ -22,13 +22,15 @@ public class jTPCCRandom private static final String[] cLastTokens = { "BAR", "OUGHT", "ABLE", "PRI", "PRES", "ESE", "ANTI", "CALLY", "ATION", "EING"}; + + private static long seed; private static long nURandCLast; private static long nURandCC_ID; private static long nURandCI_ID; private static boolean initialized = false; - private ThreadLocalRandom random; + private Random random; /* * jTPCCRandom() @@ -36,12 +38,13 @@ public class jTPCCRandom * Used to create the master jTPCCRandom() instance for loading * the database. See below. */ - jTPCCRandom() + jTPCCRandom(long seed) { if (initialized) throw new IllegalStateException("Global instance exists"); - this.random = ThreadLocalRandom.current(); + jTPCCRandom.seed = seed; + this.random = new Random(seed); jTPCCRandom.nURandCLast = nextLong(0, 255); jTPCCRandom.nURandCC_ID = nextLong(0, 1023); jTPCCRandom.nURandCI_ID = nextLong(0, 8191); @@ -61,14 +64,15 @@ public class jTPCCRandom * C_LAST must be excluded from the possible range during run * time, based on the number used during the load. */ - jTPCCRandom(long CLoad) + jTPCCRandom(long CLoad, long seed) { long delta; if (initialized) throw new IllegalStateException("Global instance exists"); - - this.random = ThreadLocalRandom.current(); + + jTPCCRandom.seed = seed; + this.random = new Random(seed); jTPCCRandom.nURandCC_ID = nextLong(0, 1023); jTPCCRandom.nURandCI_ID = nextLong(0, 8191); @@ -89,7 +93,7 @@ public class jTPCCRandom private jTPCCRandom(jTPCCRandom parent) { - this.random = ThreadLocalRandom.current(); + this.random = new Random(seed); } /*