dlg99 commented on a change in pull request #9825:
URL: https://github.com/apache/pulsar/pull/9825#discussion_r591916401
##########
File path:
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/KafkaAbstractSink.java
##########
@@ -78,32 +89,80 @@ protected Properties beforeCreateProducer(Properties props)
{
@Override
public void open(Map<String, Object> config, SinkContext sinkContext)
throws Exception {
kafkaSinkConfig = KafkaSinkConfig.load(config);
+ //
kafkaSinkConfig.setKafkaConnectorSinkClass("org.apache.kafka.connect.file.FileStreamSinkConnector");
Objects.requireNonNull(kafkaSinkConfig.getTopic(), "Kafka topic is not
set");
- Objects.requireNonNull(kafkaSinkConfig.getBootstrapServers(), "Kafka
bootstrapServers is not set");
- Objects.requireNonNull(kafkaSinkConfig.getAcks(), "Kafka acks mode is
not set");
- if (kafkaSinkConfig.getBatchSize() <= 0) {
- throw new IllegalArgumentException("Invalid Kafka Producer
batchSize : "
- + kafkaSinkConfig.getBatchSize());
- }
- if (kafkaSinkConfig.getMaxRequestSize() <= 0) {
- throw new IllegalArgumentException("Invalid Kafka Producer
maxRequestSize : "
- + kafkaSinkConfig.getMaxRequestSize());
- }
- if (kafkaSinkConfig.getProducerConfigProperties() != null) {
- props.putAll(kafkaSinkConfig.getProducerConfigProperties());
- }
- props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
kafkaSinkConfig.getBootstrapServers());
- props.put(ProducerConfig.ACKS_CONFIG, kafkaSinkConfig.getAcks());
- props.put(ProducerConfig.BATCH_SIZE_CONFIG,
String.valueOf(kafkaSinkConfig.getBatchSize()));
- props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG,
String.valueOf(kafkaSinkConfig.getMaxRequestSize()));
- props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
kafkaSinkConfig.getKeySerializerClass());
- props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
kafkaSinkConfig.getValueSerializerClass());
+ String kafkaConnectorName =
kafkaSinkConfig.getKafkaConnectorSinkClass();
+ if (Strings.isNullOrEmpty(kafkaConnectorName)) {
+ Objects.requireNonNull(kafkaSinkConfig.getBootstrapServers(),
"Kafka bootstrapServers is not set");
+ Objects.requireNonNull(kafkaSinkConfig.getAcks(), "Kafka acks mode
is not set");
+ if (kafkaSinkConfig.getBatchSize() <= 0) {
+ throw new IllegalArgumentException("Invalid Kafka Producer
batchSize : "
+ + kafkaSinkConfig.getBatchSize());
+ }
+ if (kafkaSinkConfig.getMaxRequestSize() <= 0) {
+ throw new IllegalArgumentException("Invalid Kafka Producer
maxRequestSize : "
+ + kafkaSinkConfig.getMaxRequestSize());
+ }
+ if (kafkaSinkConfig.getProducerConfigProperties() != null) {
+ props.putAll(kafkaSinkConfig.getProducerConfigProperties());
+ }
+
+ props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
kafkaSinkConfig.getBootstrapServers());
+ props.put(ProducerConfig.ACKS_CONFIG, kafkaSinkConfig.getAcks());
+ props.put(ProducerConfig.BATCH_SIZE_CONFIG,
String.valueOf(kafkaSinkConfig.getBatchSize()));
+ props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG,
String.valueOf(kafkaSinkConfig.getMaxRequestSize()));
+ props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
kafkaSinkConfig.getKeySerializerClass());
+ props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
kafkaSinkConfig.getValueSerializerClass());
+
+ producer = new KafkaProducer<>(beforeCreateProducer(props));
+ } else {
+
kafkaSinkConfig.getKafkaConnectorConfigProperties().entrySet().stream()
+ .forEach(kv -> props.put(kv.getKey(), kv.getValue()));
- producer = new KafkaProducer<>(beforeCreateProducer(props));
+ // todo: schemas from config
Review comment:
fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]