Search in sources :

Example 1 with TransactionConfig

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

the class KafkaProtocolHandler method initTransactionCoordinator.

public TransactionCoordinator initTransactionCoordinator(String tenant, PulsarAdmin pulsarAdmin, ClusterData clusterData) throws Exception {
    TransactionConfig transactionConfig = TransactionConfig.builder().transactionLogNumPartitions(kafkaConfig.getKafkaTxnLogTopicNumPartitions()).transactionMetadataTopicName(MetadataUtils.constructTxnLogTopicBaseName(tenant, kafkaConfig)).transactionProducerIdTopicName(MetadataUtils.constructTxnProducerIdTopicBaseName(tenant, kafkaConfig)).abortTimedOutTransactionsIntervalMs(kafkaConfig.getKafkaTxnAbortTimedOutTransactionCleanupIntervalMs()).transactionalIdExpirationMs(kafkaConfig.getKafkaTransactionalIdExpirationMs()).removeExpiredTransactionalIdsIntervalMs(kafkaConfig.getKafkaTransactionsRemoveExpiredTransactionalIdCleanupIntervalMs()).brokerId(kafkaConfig.getKafkaBrokerId()).build();
    MetadataUtils.createTxnMetadataIfMissing(tenant, pulsarAdmin, clusterData, kafkaConfig);
    TransactionCoordinator transactionCoordinator = TransactionCoordinator.of(tenant, kafkaConfig, transactionConfig, txnTopicClient, brokerService.getPulsar().getLocalMetadataStore(), kopBrokerLookupManager, OrderedScheduler.newSchedulerBuilder().name("transaction-log-manager-" + tenant).numThreads(1).build(), Time.SYSTEM);
    transactionCoordinator.startup(kafkaConfig.isKafkaTransactionalIdExpirationEnable()).get();
    return transactionCoordinator;
}
Also used : TransactionCoordinator(io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionCoordinator) TransactionConfig(io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionConfig)

Example 2 with TransactionConfig

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

the class KafkaProxyRequestHandler method computePulsarTopicName.

private String computePulsarTopicName(FindCoordinatorRequest.CoordinatorType type, String key) {
    String pulsarTopicName;
    int partition;
    String tenant = getCurrentTenant();
    if (type == FindCoordinatorRequest.CoordinatorType.TRANSACTION) {
        TransactionConfig transactionConfig = TransactionConfig.builder().transactionLogNumPartitions(kafkaConfig.getKafkaTxnLogTopicNumPartitions()).transactionMetadataTopicName(MetadataUtils.constructTxnLogTopicBaseName(tenant, kafkaConfig)).build();
        partition = TransactionCoordinator.partitionFor(key, kafkaConfig.getKafkaTxnLogTopicNumPartitions());
        pulsarTopicName = TransactionCoordinator.getTopicPartitionName(transactionConfig.getTransactionMetadataTopicName(), partition);
    } else if (type == FindCoordinatorRequest.CoordinatorType.GROUP) {
        partition = GroupMetadataManager.getPartitionId(key, kafkaConfig.getOffsetsTopicNumPartitions());
        pulsarTopicName = GroupMetadataManager.getTopicPartitionName(tenant + "/" + kafkaConfig.getKafkaMetadataNamespace() + "/" + Topic.GROUP_METADATA_TOPIC_NAME, partition);
    } else {
        throw new NotImplementedException("FindCoordinatorRequest not support TRANSACTION type " + type);
    }
    return pulsarTopicName;
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) TransactionConfig(io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionConfig)

Example 3 with TransactionConfig

use of io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionConfig in project kop by streamnative.

the class KafkaProtocolHandler method initTransactionCoordinator.

public TransactionCoordinator initTransactionCoordinator(String tenant, PulsarAdmin pulsarAdmin, ClusterData clusterData) throws Exception {
    TransactionConfig transactionConfig = TransactionConfig.builder().transactionLogNumPartitions(kafkaConfig.getKafkaTxnLogTopicNumPartitions()).transactionMetadataTopicName(MetadataUtils.constructTxnLogTopicBaseName(tenant, kafkaConfig)).abortTimedOutTransactionsIntervalMs(kafkaConfig.getKafkaTxnAbortTimedOutTransactionCleanupIntervalMs()).transactionalIdExpirationMs(kafkaConfig.getKafkaTransactionalIdExpirationMs()).removeExpiredTransactionalIdsIntervalMs(kafkaConfig.getKafkaTransactionsRemoveExpiredTransactionalIdCleanupIntervalMs()).brokerId(kafkaConfig.getKafkaBrokerId()).build();
    MetadataUtils.createTxnMetadataIfMissing(tenant, pulsarAdmin, clusterData, kafkaConfig);
    TransactionCoordinator transactionCoordinator = TransactionCoordinator.of(tenant, kafkaConfig, transactionConfig, txnTopicClient, brokerService.getPulsar().getLocalMetadataStore(), kopBrokerLookupManager, OrderedScheduler.newSchedulerBuilder().name("transaction-log-manager-" + tenant).numThreads(1).build(), Time.SYSTEM);
    transactionCoordinator.startup(kafkaConfig.isKafkaTransactionalIdExpirationEnable()).get();
    return transactionCoordinator;
}
Also used : TransactionCoordinator(io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionCoordinator) TransactionConfig(io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionConfig)

Aggregations

TransactionConfig (io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionConfig)3 TransactionCoordinator (io.streamnative.pulsar.handlers.kop.coordinator.transaction.TransactionCoordinator)2 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1