use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testCheckpointUnstarted.
@Test
public void testCheckpointUnstarted() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
SplitResult res = tracker.trySplit(0);
assertEquals(new OffsetRange(100, 100), res.getPrimary());
assertEquals(new OffsetRange(100, 200), res.getResidual());
tracker.checkDone();
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testNonMonotonicClaim.
@Test
public void testNonMonotonicClaim() throws Exception {
expected.expectMessage("Trying to claim offset 103 while last attempted was 110");
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
assertTrue(tracker.tryClaim(105L));
assertTrue(tracker.tryClaim(110L));
tracker.tryClaim(103L);
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testBacklogUnstarted.
@Test
public void testBacklogUnstarted() {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(0, 200));
Progress progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(200, progress.getWorkRemaining(), 0.001);
tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(100, progress.getWorkRemaining(), 0.001);
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class GrowableOffsetRangeTrackerTest method testSplitWithMaxEstimateRangeEnd.
@Test
public void testSplitWithMaxEstimateRangeEnd() throws Exception {
SimpleEstimator simpleEstimator = new SimpleEstimator();
GrowableOffsetRangeTracker tracker = new GrowableOffsetRangeTracker(0L, simpleEstimator);
assertTrue(tracker.tryClaim(1L));
simpleEstimator.setEstimateRangeEnd(Long.MAX_VALUE);
SplitResult res = tracker.trySplit(0.5);
long expectedEnd = 1L + (Long.MAX_VALUE - 1L) / 2;
assertEquals(new OffsetRange(0L, expectedEnd), res.getPrimary());
assertEquals(new OffsetRange(expectedEnd, Long.MAX_VALUE), res.getResidual());
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class GrowableOffsetRangeTrackerTest method testCheckpointBeforeStart.
@Test
public void testCheckpointBeforeStart() throws Exception {
SimpleEstimator simpleEstimator = new SimpleEstimator();
GrowableOffsetRangeTracker tracker = new GrowableOffsetRangeTracker(0L, simpleEstimator);
simpleEstimator.setEstimateRangeEnd(10);
SplitResult res = tracker.trySplit(0);
tracker.checkDone();
assertEquals(new OffsetRange(0, 0), res.getPrimary());
assertEquals(new OffsetRange(0, 0), tracker.currentRestriction());
assertEquals(new OffsetRange(0, Long.MAX_VALUE), res.getResidual());
}
Aggregations