Class MockInMemoryTransformingProducerAdapter
java.lang.Object
com.linkedin.venice.pubsub.mock.adapter.producer.MockInMemoryTransformingProducerAdapter
- All Implemented Interfaces:
PubSubProducerAdapter
public class MockInMemoryTransformingProducerAdapter
extends Object
implements PubSubProducerAdapter
This
PubSubProducerAdapter
implementation allows tests to perform
arbitrary transformations on the messages that are about to be written to
PubSub.
This can be used in unit tests to inject corrupt data.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
-
Constructor Summary
ConstructorsConstructorDescriptionMockInMemoryTransformingProducerAdapter
(PubSubProducerAdapter baseProducer, MockInMemoryTransformingProducerAdapter.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linkedin.venice.pubsub.api.PubSubProducerAdapter
sendMessage
-
Constructor Details
-
MockInMemoryTransformingProducerAdapter
public MockInMemoryTransformingProducerAdapter(PubSubProducerAdapter baseProducer, MockInMemoryTransformingProducerAdapter.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
-