Search in sources :

Example 6 with ProducerIdsRecord

use of org.apache.kafka.common.metadata.ProducerIdsRecord in project kafka by apache.

the class MetadataNodeManagerTest method testProducerIdsRecord.

@Test
public void testProducerIdsRecord() {
    // generate a producerId record
    ProducerIdsRecord record1 = new ProducerIdsRecord().setBrokerId(0).setBrokerEpoch(1).setNextProducerId(10000);
    metadataNodeManager.handleMessage(record1);
    assertEquals("0", metadataNodeManager.getData().root().directory("producerIds").file("lastBlockBrokerId").contents());
    assertEquals("1", metadataNodeManager.getData().root().directory("producerIds").file("lastBlockBrokerEpoch").contents());
    assertEquals(10000 + "", metadataNodeManager.getData().root().directory("producerIds").file("nextBlockStartId").contents());
    // generate another producerId record
    ProducerIdsRecord record2 = new ProducerIdsRecord().setBrokerId(1).setBrokerEpoch(2).setNextProducerId(11000);
    metadataNodeManager.handleMessage(record2);
    assertEquals("1", metadataNodeManager.getData().root().directory("producerIds").file("lastBlockBrokerId").contents());
    assertEquals("2", metadataNodeManager.getData().root().directory("producerIds").file("lastBlockBrokerEpoch").contents());
    assertEquals(11000 + "", metadataNodeManager.getData().root().directory("producerIds").file("nextBlockStartId").contents());
}
Also used : ProducerIdsRecord(org.apache.kafka.common.metadata.ProducerIdsRecord) Test(org.junit.jupiter.api.Test)

Aggregations

ProducerIdsRecord (org.apache.kafka.common.metadata.ProducerIdsRecord)6 ProducerIdsBlock (org.apache.kafka.server.common.ProducerIdsBlock)4 Test (org.junit.jupiter.api.Test)4 ApiMessageAndVersion (org.apache.kafka.server.common.ApiMessageAndVersion)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UnknownServerException (org.apache.kafka.common.errors.UnknownServerException)1