balesh2 commented on a change in pull request #25: GEODE-6148: improve 
performance of Prepopulate
URL: https://github.com/apache/geode-benchmarks/pull/25#discussion_r240843250
 
 

 ##########
 File path: 
geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java
 ##########
 @@ -50,14 +56,36 @@ public PrePopulateRegion(long keyRangeToPrepopulate) {
   public void run(TestContext context) {
     Cache serverCache = (Cache) context.getAttribute("SERVER_CACHE");
     Region region = serverCache.getRegion("region");
+
+    int numLocators = context.getHostsForRole(LOCATOR).size();
+    int numServers = context.getHostsForRole(SERVER).size();
+    int serverIndex = context.getJvmID() - numLocators;
+    int numPutsPerServer = (int) this.keyRangeToPrepopulate / numServers;
+
+    AtomicInteger lowBound = new AtomicInteger();
+    AtomicInteger highBound = new AtomicInteger();
+
+    // calculate non-overlapping key ranges for each server
+    lowBound.set(numPutsPerServer * serverIndex);
+    highBound.set(numPutsPerServer * (serverIndex + 1));
+    if (serverIndex == (numServers - 1)) {
+      highBound.getAndAdd((int) this.keyRangeToPrepopulate % (serverIndex + 
1));
+    }
+
+    // build a map of to put to the server
+    Map<Long, PortfolioPdx> valueMap = new HashMap<>();
+    LongStream.range(lowBound.get(), highBound.get()).forEach(i -> {
+      long value = ThreadLocalRandom.current().nextLong(lowBound.get(), 
highBound.get());
 
 Review comment:
   This was just being used as the value, not the key, so I'll just change the 
value to be the same as the key. Or a string of "value"+key. Any opinions on 
which one is better?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to