Skip to content

Commit

Permalink
Make sure the AllNodeProgression never return a non-empty batch after
Browse files Browse the repository at this point in the history
having return an empty one

This could happen if the highId has increased in the meantime, we need
to enforce consitency and never restart streaming new batches if we
have declared the progression as done.
  • Loading branch information
davidegrohmann committed May 8, 2017
1 parent 4f436bf commit 370e810
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class AllNodeProgression implements NodeProgression
{
private final NodeStore nodeStore;
private long start;
private boolean done;

AllNodeProgression( NodeStore nodeStore )
{
Expand All @@ -35,15 +36,24 @@ public class AllNodeProgression implements NodeProgression
@Override
public boolean nextBatch( Batch batch )
{
long highId = nodeStore.getHighId();
if ( start > highId )
while ( true )
{
batch.nothing();
return false;
if ( done )
{
batch.nothing();
return false;
}

long highId = nodeStore.getHighestPossibleIdInUse();
if ( start <= highId )
{
batch.init( start, highId );
start = highId + 1;
return true;
}

done = true;
}
batch.init( start, highId );
start = highId + 1;
return true;
}

@Override
Expand Down

0 comments on commit 370e810

Please sign in to comment.