Class TransformingProducerAdapter
java.lang.Object
com.linkedin.venice.unit.kafka.producer.TransformingProducerAdapter
- All Implemented Interfaces:
PubSubProducerAdapter
This
PubSubProducerAdapter
implementation allows tests to perform
arbitrary transformations on the messages that are about to be written to
Kafka.
This can be used in unit tests to inject corrupt data.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
-
Constructor Summary
ConstructorDescriptionTransformingProducerAdapter
(PubSubProducerAdapter baseProducer, TransformingProducerAdapter.SendMessageParametersTransformer transformer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(long closeTimeOutMs) void
flush()
it.unimi.dsi.fastutil.objects.Object2DoubleMap<String>
int
getNumberOfPartitions
(String topic) The support for the following two getNumberOfPartitions APIs will be removed.sendMessage
(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders headers, PubSubProducerCallback callback) Sends a message to a PubSub topic asynchronously and returns aFuture
representing the result of the produce operation.
-
Constructor Details
-
TransformingProducerAdapter
public TransformingProducerAdapter(PubSubProducerAdapter baseProducer, TransformingProducerAdapter.SendMessageParametersTransformer transformer)
-
-
Method Details
-
getNumberOfPartitions
Description copied from interface:PubSubProducerAdapter
The support for the following two getNumberOfPartitions APIs will be removed.- Specified by:
getNumberOfPartitions
in interfacePubSubProducerAdapter
-
sendMessage
public CompletableFuture<PubSubProduceResult> sendMessage(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders headers, PubSubProducerCallback callback) Description copied from interface:PubSubProducerAdapter
Sends a message to a PubSub topic asynchronously and returns aFuture
representing the result of the produce operation.- Specified by:
sendMessage
in interfacePubSubProducerAdapter
- Parameters:
topic
- The name of the Kafka topic to which the message will be sent.partition
- The partition to which the message should be sent.key
- The key associated with the message, used for partitioning and message retrieval.value
- The message payload to be sent to the PubSubTopic topic.headers
- Additional headers to be included with the message.callback
- An optional callback to handle the result of the produce operation.- Returns:
- A
Future
representing the result of the produce operation.
-
flush
public void flush()- Specified by:
flush
in interfacePubSubProducerAdapter
-
close
public void close(long closeTimeOutMs) - Specified by:
close
in interfacePubSubProducerAdapter
-
getMeasurableProducerMetrics
- Specified by:
getMeasurableProducerMetrics
in interfacePubSubProducerAdapter
-
getBrokerAddress
- Specified by:
getBrokerAddress
in interfacePubSubProducerAdapter
-