boolean running = true;
while (running) {
Map<Range,ConcurrentHashMap<Locator,Points>> dataToBeRolled = BuildStore.getEligibleData();
try {
if (dataToBeRolled != null && !dataToBeRolled.isEmpty()) {
final RollupBatchWriter batchWriter = new RollupBatchWriter(batchWriterPool, null);
Set<Range> ranges = dataToBeRolled.keySet();
for (Range range : ranges) {
// Remove the range from applicable range, so that we do not merge any more data for that range.
BuildStore.rangesStillApplicable.remove(range);
log.info("Removed range {} from applicable ranges", range);
Set<Locator> locators = dataToBeRolled.get(range).keySet();
for (Locator locator : locators) {
rollupExecutors.submit(new RollupValidatorAndComputer(locator, range, dataToBeRolled.get(range).get(locator), batchWriter));
}
//This will remove the entry from the backing map in buildstore as well. This is the operation that clears memory and prevents it from blowing up!
dataToBeRolled.remove(range);
log.info("Removed range {} from buildstore", range);
// Drain the remaining rollups
batchWriter.drainBatch();
}
} else {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {