Search in sources :

Example 1 with ConnectTransactionParticipant

use of org.apache.hudi.connect.transaction.ConnectTransactionParticipant in project hudi by apache.

the class HoodieSinkTask method bootstrap.

private void bootstrap(Collection<TopicPartition> partitions) {
    LOG.info(String.format("Bootstrap task for connector %s with id %s with assignments %s part %s", connectorName, taskId, context.assignment(), partitions));
    for (TopicPartition partition : partitions) {
        try {
            // If the partition is 0, instantiate the Leader
            if (partition.partition() == ConnectTransactionCoordinator.COORDINATOR_KAFKA_PARTITION) {
                ConnectTransactionCoordinator coordinator = new ConnectTransactionCoordinator(connectConfigs, partition, controlKafkaClient);
                coordinator.start();
                transactionCoordinators.put(partition, coordinator);
            }
            ConnectTransactionParticipant worker = new ConnectTransactionParticipant(connectConfigs, partition, controlKafkaClient, context);
            transactionParticipants.put(partition, worker);
            worker.start();
        } catch (HoodieException exception) {
            LOG.error(String.format("Fatal error initializing task %s for partition %s", taskId, partition.partition()), exception);
        }
    }
}
Also used : ConnectTransactionCoordinator(org.apache.hudi.connect.transaction.ConnectTransactionCoordinator) TopicPartition(org.apache.kafka.common.TopicPartition) ConnectTransactionParticipant(org.apache.hudi.connect.transaction.ConnectTransactionParticipant) HoodieException(org.apache.hudi.exception.HoodieException)

Example 2 with ConnectTransactionParticipant

use of org.apache.hudi.connect.transaction.ConnectTransactionParticipant in project hudi by apache.

the class TestConnectTransactionParticipant method initializeParticipant.

private void initializeParticipant() {
    testHudiWriterProvider = new TestHudiWriterProvider();
    participant = new ConnectTransactionParticipant(partition, kafkaControlAgent, mockKafkaConnect, testHudiWriterProvider);
    mockKafkaConnect.setParticipant(participant);
    participant.start();
}
Also used : TestHudiWriterProvider(org.apache.hudi.helper.TestHudiWriterProvider) ConnectTransactionParticipant(org.apache.hudi.connect.transaction.ConnectTransactionParticipant)

Aggregations

ConnectTransactionParticipant (org.apache.hudi.connect.transaction.ConnectTransactionParticipant)2 ConnectTransactionCoordinator (org.apache.hudi.connect.transaction.ConnectTransactionCoordinator)1 HoodieException (org.apache.hudi.exception.HoodieException)1 TestHudiWriterProvider (org.apache.hudi.helper.TestHudiWriterProvider)1 TopicPartition (org.apache.kafka.common.TopicPartition)1