Class TransformingProducerAdapter
- java.lang.Object
-
- com.linkedin.venice.unit.kafka.producer.TransformingProducerAdapter
-
- All Implemented Interfaces:
PubSubProducerAdapter
public class TransformingProducerAdapter extends java.lang.Object implements PubSubProducerAdapter
ThisPubSubProducerAdapter
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
Nested Classes Modifier and Type Class Description static class
TransformingProducerAdapter.SendMessageParameters
static interface
TransformingProducerAdapter.SendMessageParametersTransformer
-
Constructor Summary
Constructors Constructor Description TransformingProducerAdapter(PubSubProducerAdapter baseProducer, TransformingProducerAdapter.SendMessageParametersTransformer transformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(long closeTimeOutMs)
void
flush()
java.lang.String
getBrokerAddress()
it.unimi.dsi.fastutil.objects.Object2DoubleMap<java.lang.String>
getMeasurableProducerMetrics()
int
getNumberOfPartitions(java.lang.String topic)
The support for the following two getNumberOfPartitions APIs will be removed.java.util.concurrent.CompletableFuture<PubSubProduceResult>
sendMessage(java.lang.String topic, java.lang.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 Detail
-
TransformingProducerAdapter
public TransformingProducerAdapter(PubSubProducerAdapter baseProducer, TransformingProducerAdapter.SendMessageParametersTransformer transformer)
-
-
Method Detail
-
getNumberOfPartitions
public int getNumberOfPartitions(java.lang.String topic)
Description copied from interface:PubSubProducerAdapter
The support for the following two getNumberOfPartitions APIs will be removed.- Specified by:
getNumberOfPartitions
in interfacePubSubProducerAdapter
-
sendMessage
public java.util.concurrent.CompletableFuture<PubSubProduceResult> sendMessage(java.lang.String topic, java.lang.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
public it.unimi.dsi.fastutil.objects.Object2DoubleMap<java.lang.String> getMeasurableProducerMetrics()
- Specified by:
getMeasurableProducerMetrics
in interfacePubSubProducerAdapter
-
getBrokerAddress
public java.lang.String getBrokerAddress()
- Specified by:
getBrokerAddress
in interfacePubSubProducerAdapter
-
-