Source:
<code><START> public void testLateData() throws Exception <END> { expectPublishedSegments(1); final AppenderatorDriverRealtimeIndexTask task = makeRealtimeTask(null); final TaskToolbox taskToolbox = makeToolbox(task, tempFolder.newFolder()); final ListenableFuture<TaskStatus> statusFuture = runTask(task, taskToolbox); while (task.getFirehose() == null) { Thread.sleep(50); } final TestFirehose firehose = (TestFirehose) task.getFirehose(); firehose.addRows( ImmutableList.of( ImmutableMap.of("t", now.getMillis(), "dim1", "foo", "met1", "1"), ImmutableMap.of("t", now.minus(new Period("P2D")).getMillis(), "dim2", "bar", "met1", 2.0) ) ); firehose.close(); Collection<DataSegment> publishedSegments = awaitSegments(); Assert.assertEquals(2, task.getMetrics().processed()); Assert.assertEquals(0, task.getMetrics().thrownAway()); Assert.assertEquals(0, task.getMetrics().unparseable()); Assert.assertEquals(2, sumMetric(task, null, "rows")); Assert.assertEquals(3, sumMetric(task, null, "met1")); awaitHandoffs(); for (DataSegment publishedSegment : publishedSegments) { Optional<Map.Entry<SegmentDescriptor, Pair<Executor, Runnable>>> optional = handOffCallbacks.entrySet().stream() .filter(e -> e.getKey().equals(new SegmentDescriptor( publishedSegment.getInterval(), publishedSegment.getVersion(), publishedSegment.getShardSpec().getPartitionNum() ))) .findFirst(); Assert.assertTrue( publishedSegment + " missing from handoff callbacks: " + handOffCallbacks, optional.isPresent() ); Pair<Executor, Runnable> executorRunnablePair = optional.get().getValue(); executorRunnablePair.lhs.execute(executorRunnablePair.rhs); } handOffCallbacks.clear(); final TaskStatus taskStatus = statusFuture.get(); Assert.assertEquals(TaskState.SUCCESS, taskStatus.getStatusCode()); }</code><technical_language>explain this tests late arrivals</technical_language>

Target:
public void testLateData() throws Exception { expectPublishedSegments(1); final AppenderatorDriverRealtimeIndexTask task = makeRealtimeTask(null); final ListenableFuture<TaskStatus> statusFuture = runTask(task); while (task.getFirehose() == null) { Thread.sleep(50); } final TestFirehose firehose = (TestFirehose) task.getFirehose(); firehose.addRows( ImmutableList.of( ImmutableMap.of("t", now.getMillis(), "dim1", "foo", "met1", "1"), ImmutableMap.of("t", now.minus(new Period("P2D")).getMillis(), "dim2", "bar", "met1", 2.0) ) ); firehose.close(); Collection<DataSegment> publishedSegments = awaitSegments(); Assert.assertEquals(2, task.getMetrics().processed()); Assert.assertEquals(0, task.getMetrics().thrownAway()); Assert.assertEquals(0, task.getMetrics().unparseable()); Assert.assertEquals(2, sumMetric(task, null, "rows")); Assert.assertEquals(3, sumMetric(task, null, "met1")); awaitHandoffs(); for (DataSegment publishedSegment : publishedSegments) { Optional<Map.Entry<SegmentDescriptor, Pair<Executor, Runnable>>> optional = handOffCallbacks.entrySet().stream() .filter(e -> e.getKey().equals(new SegmentDescriptor( publishedSegment.getInterval(), publishedSegment.getVersion(), publishedSegment.getShardSpec().getPartitionNum() ))) .findFirst(); Assert.assertTrue( publishedSegment + " missing from handoff callbacks: " + handOffCallbacks, optional.isPresent() ); Pair<Executor, Runnable> executorRunnablePair = optional.get().getValue(); executorRunnablePair.lhs.execute(executorRunnablePair.rhs); } handOffCallbacks.clear(); final TaskStatus taskStatus = statusFuture.get(); Assert.assertEquals(TaskState.SUCCESS, taskStatus.getStatusCode()); }