use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testTrySplit.
@Test
public void testTrySplit() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
tracker.tryClaim(100L);
SplitResult splitRes = tracker.trySplit(0.509);
assertEquals(new OffsetRange(100, 150), splitRes.getPrimary());
assertEquals(new OffsetRange(150, 200), splitRes.getResidual());
splitRes = tracker.trySplit(1);
assertNull(splitRes);
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testCheckpointAfterFailedClaim.
@Test
public void testCheckpointAfterFailedClaim() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
assertTrue(tracker.tryClaim(105L));
assertTrue(tracker.tryClaim(110L));
assertTrue(tracker.tryClaim(160L));
assertFalse(tracker.tryClaim(240L));
assertNull(tracker.trySplit(0));
tracker.checkDone();
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testBacklogPartiallyCompleted.
@Test
public void testBacklogPartiallyCompleted() {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(0, 200));
tracker.tryClaim(150L);
Progress progress = tracker.getProgress();
assertEquals(150, progress.getWorkCompleted(), 0.001);
assertEquals(50, progress.getWorkRemaining(), 0.001);
tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
tracker.tryClaim(150L);
progress = tracker.getProgress();
assertEquals(50, progress.getWorkCompleted(), 0.001);
assertEquals(50, progress.getWorkRemaining(), 0.001);
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testClaimBeforeStartOfRange.
@Test
public void testClaimBeforeStartOfRange() throws Exception {
expected.expectMessage("Trying to claim offset 90 before start of the range [100, 200)");
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
tracker.tryClaim(90L);
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testCheckDoneAfterTryClaimAtEndOfRange.
@Test
public void testCheckDoneAfterTryClaimAtEndOfRange() {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
assertTrue(tracker.tryClaim(150L));
assertTrue(tracker.tryClaim(175L));
assertFalse(tracker.tryClaim(200L));
tracker.checkDone();
}
Aggregations