Search in sources :

Example 1 with Section

use of org.apache.kafka.controller.SnapshotGenerator.Section in project kafka by apache.

the class SnapshotGeneratorTest method testGenerateBatches.

@Test
public void testGenerateBatches() throws Exception {
    SnapshotWriter<ApiMessageAndVersion> writer = createSnapshotWriter(123, 0);
    List<Section> sections = Arrays.asList(new Section("replication", Arrays.asList(BATCHES.get(0), BATCHES.get(1), BATCHES.get(2)).iterator()), new Section("configuration", Arrays.asList(BATCHES.get(3), BATCHES.get(4)).iterator()));
    SnapshotGenerator generator = new SnapshotGenerator(new LogContext(), writer, 2, sections);
    assertFalse(writer.isFrozen());
    assertEquals(123L, generator.lastContainedLogOffset());
    assertEquals(writer, generator.writer());
    assertEquals(OptionalLong.of(0L), generator.generateBatches());
    assertEquals(OptionalLong.of(0L), generator.generateBatches());
    assertFalse(writer.isFrozen());
    assertEquals(OptionalLong.empty(), generator.generateBatches());
    assertTrue(writer.isFrozen());
}
Also used : ApiMessageAndVersion(org.apache.kafka.server.common.ApiMessageAndVersion) LogContext(org.apache.kafka.common.utils.LogContext) Section(org.apache.kafka.controller.SnapshotGenerator.Section) Test(org.junit.jupiter.api.Test)

Aggregations

LogContext (org.apache.kafka.common.utils.LogContext)1 Section (org.apache.kafka.controller.SnapshotGenerator.Section)1 ApiMessageAndVersion (org.apache.kafka.server.common.ApiMessageAndVersion)1 Test (org.junit.jupiter.api.Test)1