Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-6244] KafkaIO: keep KafkaIO.Write compatibility with 2.9.0 #7343

Merged
merged 2 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,14 @@ public Write<K, V> withConsumerFactoryFn(
getWriteRecordsTransform().withConsumerFactoryFn(consumerFactoryFn));
}

/**
* Adds the given producer properties, overriding old values of properties with the same key.
*/
public Write<K, V> updateProducerProperties(Map<String, Object> configUpdates) {
return withWriteRecordsTransform(
getWriteRecordsTransform().updateProducerProperties(configUpdates));
}

@Override
public PDone expand(PCollection<KV<K, V>> input) {
checkArgument(getTopic() != null, "withTopic() is required");
Expand All @@ -1293,6 +1301,11 @@ public ProducerRecord<K, V> apply(KV<K, V> element) {
.apply(getWriteRecordsTransform());
}

@Override
public void validate(PipelineOptions options) {
getWriteRecordsTransform().validate(options);
}

@Override
public void populateDisplayData(DisplayData.Builder builder) {
super.populateDisplayData(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1291,13 +1291,15 @@ public void testSinkDisplayData() {
.withBootstrapServers("myServerA:9092,myServerB:9092")
.withTopic("myTopic")
.withValueSerializer(LongSerializer.class)
.withProducerFactoryFn(new ProducerFactoryFn(producerWrapper.producerKey));
.withProducerFactoryFn(new ProducerFactoryFn(producerWrapper.producerKey))
.updateProducerProperties(ImmutableMap.of("retry.backoff.ms", 100));

DisplayData displayData = DisplayData.from(write);

assertThat(displayData, hasDisplayItem("topic", "myTopic"));
assertThat(displayData, hasDisplayItem("bootstrap.servers", "myServerA:9092,myServerB:9092"));
assertThat(displayData, hasDisplayItem("retries", 3));
assertThat(displayData, hasDisplayItem("retry.backoff.ms", 100));
}
}

Expand Down