Search in sources :

Example 1 with CheckpointManagerFactory

use of co.cask.cdap.logging.meta.CheckpointManagerFactory 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)));
}
Also used : Checkpoint(co.cask.cdap.logging.meta.Checkpoint) LogEvent(co.cask.cdap.logging.read.LogEvent) CheckpointManager(co.cask.cdap.logging.meta.CheckpointManager) CheckpointManagerFactory(co.cask.cdap.logging.meta.CheckpointManagerFactory) FileLogReader(co.cask.cdap.logging.read.FileLogReader)

Aggregations

Checkpoint (co.cask.cdap.logging.meta.Checkpoint)1 CheckpointManager (co.cask.cdap.logging.meta.CheckpointManager)1 CheckpointManagerFactory (co.cask.cdap.logging.meta.CheckpointManagerFactory)1 FileLogReader (co.cask.cdap.logging.read.FileLogReader)1 LogEvent (co.cask.cdap.logging.read.LogEvent)1