Skip to content

Commit

Permalink
Bug fix from #57: Read operation return values are not respected for …
Browse files Browse the repository at this point in the history
…cache hit and cache miss after merging #57 (Bulk request support) (#136)

Bug fix: read operation return values are not respected for cache hit and cache miss after merging #57 (Bulk request support)
  • Loading branch information
vinaykumarchella authored Apr 9, 2018
1 parent f6ded7e commit 7dc08a2
Showing 1 changed file with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,44 @@ public boolean process(NdBenchDriver driver,
AtomicReference<RateLimiter> ignoredForNow,
boolean isAutoTuneEnabled) {
try {
Long startTime = System.nanoTime();
List<String> value = new ArrayList<>(keys.size());

if (keys.size() > 1) {
// bulk
value.addAll(client.readBulk(keys));
} else {
// single
value.add(client.readSingle(keys.get(0)));
}
monitor.recordReadLatency((System.nanoTime() - startTime)/1000);
if (value != null) {
monitor.incCacheHit();
//Bulk requests
List<String> values = new ArrayList<>(keys.size());

Long startTime = System.nanoTime();
values.addAll(client.readBulk(keys));
monitor.recordReadLatency((System.nanoTime() - startTime) / 1000);

for (String value : values) {
processCacheStats(value, monitor);
}
} else {
Logger.debug("Miss for key: {}", keys);
monitor.incCacheMiss();
//Single requests

Long startTime = System.nanoTime();
String value = client.readSingle(keys.get(0));
monitor.recordReadLatency((System.nanoTime() - startTime) / 1000);

processCacheStats(value, monitor);
}

monitor.incReadSuccess();
return true;

} catch (Exception e) {
monitor.incReadFailure();
Logger.error("Failed to process NdBench read operation", e);
return false;
} finally {
}
}

private void processCacheStats(String value, NdBenchMonitor monitor)
{
if (value != null) {
monitor.incCacheHit();
} else {
monitor.incCacheMiss();
}
}

Expand Down

0 comments on commit 7dc08a2

Please sign in to comment.