use of co.cask.cdap.logging.meta.CheckpointManager in project cdap by caskdata.
the class TestDistributedLogReader method generateCheckpointTime.
private static void generateCheckpointTime(LoggingContext loggingContext, int numExpectedEvents, String kafkaTopic) throws Exception {
FileLogReader logReader = injector.getInstance(FileLogReader.class);
List<LogEvent> events = Lists.newArrayList(logReader.getLog(loggingContext, 0, Long.MAX_VALUE, Filter.EMPTY_FILTER));
Assert.assertEquals(numExpectedEvents, events.size());
// Save checkpoint (time of last event)
CheckpointManagerFactory checkpointManagerFactory = injector.getInstance(CheckpointManagerFactory.class);
CheckpointManager checkpointManager = checkpointManagerFactory.create(kafkaTopic, Constants.Logging.SYSTEM_PIPELINE_CHECKPOINT_PREFIX);
long checkpointTime = events.get(numExpectedEvents - 1).getLoggingEvent().getTimeStamp();
checkpointManager.saveCheckpoints(ImmutableMap.of(stringPartitioner.partition(loggingContext.getLogPartition(), -1), new Checkpoint(numExpectedEvents, checkpointTime, checkpointTime)));
}
Aggregations