final AtomicInteger obsoletes = new AtomicInteger(0);
final AtomicInteger nullResults = new AtomicInteger(0);
final AtomicInteger totalResults = new AtomicInteger(0);
final BlockingQueue<String> requestIds = new ArrayBlockingQueue<String>(20000);
final Executor executor = Executors.newFixedThreadPool(1);
// if they have given us a file make a request generator that reads from
// it, otherwise just generate random values
final int numVals = numValues;
Runnable requestGenerator;
if(inputFile == null) {
requestGenerator = new Runnable() {
public void run() {
System.out.println("Generating random requests.");
Random random = new Random();
try {
while(true)
requestIds.put(Integer.toString(random.nextInt(numRequests) % numVals));
} catch(InterruptedException e) {
e.printStackTrace();
}
}
};
} else {
requestGenerator = new Runnable() {
public void run() {
try {
System.out.println("Using request file to generate requests.");
BufferedReader reader = new BufferedReader(new FileReader(inputFile),
1000000);
while(true) {
String line = reader.readLine();
if(line == null)
return;
requestIds.put(line.trim());
}
} catch(Exception e) {
e.printStackTrace();
}
}
};
}
executor.execute(requestGenerator);
final Serializer<Object> keySerializer = new JsonTypeSerializer(JsonTypeDefinition.fromJson("'string'"),
true);
final AtomicInteger current = new AtomicInteger();
final int progressIncrement = numRequests / 5;