1) Add check whether a Hydrant has already been persisted before persisting. Persisting happens synchronously on the same thread, but multiple persist requests can be queued up on that thread which means that subsequent ones would fail with an NPE. Fixes #178

This commit is contained in:
cheddar 2013-07-02 11:53:53 -07:00
parent fd1d73e83a
commit 0712941825
1 changed files with 8 additions and 0 deletions

View File

@ -662,6 +662,14 @@ public class RealtimePlumberSchool implements PlumberSchool
*/
private int persistHydrant(FireHydrant indexToPersist, Schema schema, Interval interval)
{
if (indexToPersist.hasSwapped()) {
log.info(
"DataSource[%s], Interval[%s], Hydrant[%s] already swapped. Ignoring request to persist.",
schema.getDataSource(), interval, indexToPersist
);
return 0;
}
log.info("DataSource[%s], Interval[%s], persisting Hydrant[%s]", schema.getDataSource(), interval, indexToPersist);
try {
int numRows = indexToPersist.getIndex().size();