Search in sources :

Example 1 with KafkaProtocolHandler

use of io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler in project starlight-for-kafka by datastax.

the class GroupMetadataManagerTest method testOffsetTopicNumPartitionsModify.

@Test
public void testOffsetTopicNumPartitionsModify() {
    int consumerGroupPartitionId = GroupMetadataManager.getPartitionId(groupId, conf.getOffsetsTopicNumPartitions());
    conf.setOffsetsTopicNumPartitions(100);
    KafkaProtocolHandler handler = (KafkaProtocolHandler) pulsar.getProtocolHandlers().protocol("kafka");
    // remove here to trigger a new creating for GroupCoordinator
    handler.getGroupCoordinators().remove(conf.getKafkaMetadataTenant());
    GroupMetadataManager newMetaManager = handler.getGroupCoordinator(conf.getKafkaMetadataTenant()).getGroupManager();
    int newPartitionsId = GroupMetadataManager.getPartitionId(groupId, newMetaManager.offsetConfig().offsetsTopicNumPartitions());
    assertEquals(consumerGroupPartitionId, newPartitionsId);
}
Also used : KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) Test(org.testng.annotations.Test)

Example 2 with KafkaProtocolHandler

use of io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler in project starlight-for-kafka by datastax.

the class TransactionCoordinatorTest method initializeState.

@BeforeMethod
protected void initializeState() {
    ProtocolHandler handler = pulsar.getProtocolHandlers().protocol("kafka");
    KafkaProtocolHandler kafkaProtocolHandler = (KafkaProtocolHandler) handler;
    OrderedScheduler scheduler = OrderedScheduler.newSchedulerBuilder().name("test-txn-coordinator-scheduler").numThreads(1).build();
    initMockPidManager();
    initTransactionManager();
    initTransactionMarkerChannelManager();
    transactionCoordinator = new TransactionCoordinator(TransactionConfig.builder().abortTimedOutTransactionsIntervalMs(DefaultAbortTimedOutTransactionsIntervalMs).build(), transactionMarkerChannelManager, scheduler, producerIdManager, transactionManager, time, METADATA_NAMESPACE_PREFIX, NAMESPACE_PREFIX);
    result = null;
    error = Errors.NONE;
    capturedTxn = ArgumentCaptor.forClass(TransactionMetadata.class);
    capturedErrorsCallback = ArgumentCaptor.forClass(TransactionStateManager.ResponseCallback.class);
    capturedTxnTransitMetadata = ArgumentCaptor.forClass(TransactionMetadata.TxnTransitMetadata.class);
}
Also used : KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) ProtocolHandler(org.apache.pulsar.broker.protocol.ProtocolHandler) KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) OrderedScheduler(org.apache.bookkeeper.common.util.OrderedScheduler) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with KafkaProtocolHandler

use of io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler in project kop by streamnative.

the class GroupMetadataManagerTest method testOffsetTopicNumPartitionsModify.

@Test
public void testOffsetTopicNumPartitionsModify() {
    int consumerGroupPartitionId = GroupMetadataManager.getPartitionId(groupId, conf.getOffsetsTopicNumPartitions());
    conf.setOffsetsTopicNumPartitions(100);
    KafkaProtocolHandler handler = (KafkaProtocolHandler) pulsar.getProtocolHandlers().protocol("kafka");
    // remove here to trigger a new creating for GroupCoordinator
    handler.getGroupCoordinators().remove(conf.getKafkaMetadataTenant());
    GroupMetadataManager newMetaManager = handler.getGroupCoordinator(conf.getKafkaMetadataTenant()).getGroupManager();
    int newPartitionsId = GroupMetadataManager.getPartitionId(groupId, newMetaManager.offsetConfig().offsetsTopicNumPartitions());
    assertEquals(consumerGroupPartitionId, newPartitionsId);
}
Also used : KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) Test(org.testng.annotations.Test)

Example 4 with KafkaProtocolHandler

use of io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler in project kop by streamnative.

the class TransactionCoordinatorTest method initializeState.

@BeforeMethod
protected void initializeState() {
    ProtocolHandler handler = pulsar.getProtocolHandlers().protocol("kafka");
    KafkaProtocolHandler kafkaProtocolHandler = (KafkaProtocolHandler) handler;
    OrderedScheduler scheduler = OrderedScheduler.newSchedulerBuilder().name("test-txn-coordinator-scheduler").numThreads(1).build();
    initMockPidManager();
    initTransactionManager();
    initTransactionMarkerChannelManager();
    transactionCoordinator = new TransactionCoordinator(TransactionConfig.builder().abortTimedOutTransactionsIntervalMs(DefaultAbortTimedOutTransactionsIntervalMs).build(), transactionMarkerChannelManager, scheduler, producerIdManager, transactionManager, time, METADATA_NAMESPACE_PREFIX, NAMESPACE_PREFIX);
    result = null;
    error = Errors.NONE;
    capturedTxn = ArgumentCaptor.forClass(TransactionMetadata.class);
    capturedErrorsCallback = ArgumentCaptor.forClass(TransactionStateManager.ResponseCallback.class);
    capturedTxnTransitMetadata = ArgumentCaptor.forClass(TransactionMetadata.TxnTransitMetadata.class);
}
Also used : KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) ProtocolHandler(org.apache.pulsar.broker.protocol.ProtocolHandler) KafkaProtocolHandler(io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler) OrderedScheduler(org.apache.bookkeeper.common.util.OrderedScheduler) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

KafkaProtocolHandler (io.streamnative.pulsar.handlers.kop.KafkaProtocolHandler)4 OrderedScheduler (org.apache.bookkeeper.common.util.OrderedScheduler)2 ProtocolHandler (org.apache.pulsar.broker.protocol.ProtocolHandler)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Test (org.testng.annotations.Test)2