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;
}
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;
}
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;
}
Aggregations