iter.close();
if(count == expectedKeys + 1) {
out.println("Epoch " + currentEpoch + " is complete.");
int nextEpoch = Integer.parseInt(currentEpoch) + 1;
for(int i = 0; i < numPartitions; i++)
collector.send(new OutgoingMessageEnvelope(new SystemStream("kafka", "epoch"), i, Integer.toString(nextEpoch)));
} else if(count > expectedKeys + 1) {
throw new IllegalStateException("Got " + count + " keys, which is more than the expected " + (expectedKeys + 1));
} else {
out.println("Only found " + count + " valid keys, try again later.");
}