fix: event handler memory leak, buffer never be cleared

This commit is contained in:
wusheng 2016-11-25 09:28:25 +08:00
parent e750b540cc
commit b5e00fe202
2 changed files with 14 additions and 6 deletions

View File

@ -35,11 +35,15 @@ public class StoreAckSpanEventHandler implements EventHandler<AckSpanData> {
buffer.add(event);
if (endOfBatch || buffer.size() == bufferSize) {
IndexMetaCollection collection = fileWriter.write(buffer);
try {
IndexMetaCollection collection = fileWriter.write(buffer);
operator.batchUpdate(collection);
operator.batchUpdate(collection);
HealthCollector.getCurrentHeathReading("StoreAckSpanEventHandler").updateData(HeathReading.INFO, "%s messages were successful consumed .", buffer.size());
HealthCollector.getCurrentHeathReading("StoreAckSpanEventHandler").updateData(HeathReading.INFO, "%s messages were successful consumed .", buffer.size());
} finally {
buffer.clear();
}
}
}
}

View File

@ -35,11 +35,15 @@ public class StoreRequestSpanEventHandler implements EventHandler<RequestSpanDat
buffer.add(event);
if (endOfBatch || buffer.size() == bufferSize) {
IndexMetaCollection collection = fileWriter.write(buffer);
try {
IndexMetaCollection collection = fileWriter.write(buffer);
operator.batchUpdate(collection);
operator.batchUpdate(collection);
HealthCollector.getCurrentHeathReading("StoreRequestSpanEventHandler").updateData(HeathReading.INFO, "%s messages were successful consumed .", buffer.size());
HealthCollector.getCurrentHeathReading("StoreRequestSpanEventHandler").updateData(HeathReading.INFO, "%s messages were successful consumed .", buffer.size());
} finally {
buffer.clear();
}
}
}
}