Package com.linkedin.venice.writer
Class ComplexVeniceWriter<K,V,U>
java.lang.Object
com.linkedin.venice.writer.AbstractVeniceWriter<K,V,U>
com.linkedin.venice.writer.VeniceWriter<K,V,U>
com.linkedin.venice.writer.ComplexVeniceWriter<K,V,U>
- All Implemented Interfaces:
Closeable
,AutoCloseable
Provide more complex and sophisticated writer APIs for writing to
MaterializedView
.
Specifically when a ComplexVenicePartitioner
is involved. Otherwise, use the
VeniceWriter
APIs.-
Nested Class Summary
Nested classes/interfaces inherited from class com.linkedin.venice.writer.VeniceWriter
VeniceWriter.DefaultLeaderMetadata, VeniceWriter.KeyProvider
-
Field Summary
Fields inherited from class com.linkedin.venice.writer.VeniceWriter
APP_DEFAULT_LOGICAL_TS, CHECK_SUM_TYPE, CLOSE_TIMEOUT_MS, DEFAULT_CHECK_SUM_TYPE, DEFAULT_CLOSE_TIMEOUT_MS, DEFAULT_LEADER_METADATA_WRAPPER, DEFAULT_MAX_ATTEMPTS_WHEN_TOPIC_MISSING, DEFAULT_MAX_SIZE_FOR_USER_PAYLOAD_PER_MESSAGE_IN_BYTES, DEFAULT_UPSTREAM_KAFKA_CLUSTER_ID, DEFAULT_UPSTREAM_OFFSET, EMPTY_BYTE_ARRAY, EMPTY_BYTE_BUFFER, ENABLE_CHUNKING, ENABLE_RMD_CHUNKING, keySerializer, logger, MAX_ATTEMPTS_WHEN_TOPIC_MISSING, MAX_ELAPSED_TIME_FOR_SEGMENT_IN_MS, MAX_RECORD_SIZE_BYTES, MAX_SIZE_FOR_USER_PAYLOAD_PER_MESSAGE_IN_BYTES, numberOfPartitions, OPEN_VENICE_WRITER_COUNT, partitioner, PRODUCER_QUEUE_SIZE, PRODUCER_THREAD_COUNT, UNLIMITED_MAX_RECORD_SIZE, valueSerializer, VENICE_DEFAULT_LOGICAL_TS, VENICE_DEFAULT_TIMESTAMP_METADATA_VERSION_ID, VENICE_DEFAULT_VALUE_SCHEMA_ID, VENICE_WRITER_CLOSE_FAILED_COUNT, VENICE_WRITER_CONFIG_PREFIX
Fields inherited from class com.linkedin.venice.writer.AbstractVeniceWriter
topicName
-
Constructor Summary
ConstructorsConstructorDescriptionComplexVeniceWriter
(VeniceWriterOptions params, VeniceProperties props, PubSubProducerAdapter producerAdapter) -
Method Summary
Modifier and TypeMethodDescriptioncomplexDelete
(K key, Lazy<org.apache.avro.generic.GenericRecord> valueProvider) Perform "delete" on the given key.complexPut
(K key, V value, int valueSchemaId, Lazy<org.apache.avro.generic.GenericRecord> valueProvider) ComplexVenicePartitioner
offers a more sophisticated getPartitionId API.delete
(K key, PubSubProducerCallback callback, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, DeleteMetadata deleteMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Execute a standard "delete" on the key.put
(K key, V value, int valueSchemaId, PubSubProducerCallback callback, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, PutMetadata putMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Execute a standard "put" on the key.protected CompletableFuture<PubSubProduceResult>
putLargeValue
(byte[] serializedKey, byte[] serializedValue, int valueSchemaId, PubSubProducerCallback callback, int partition, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, PutMetadata putMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Prevent theComplexVeniceWriter
from writing any actual chunks for large values.update
(K key, U update, int valueSchemaId, int derivedSchemaId, PubSubProducerCallback callback, long logicalTs) Methods inherited from class com.linkedin.venice.writer.VeniceWriter
asyncSendControlMessage, broadcastEndOfIncrementalPush, broadcastEndOfPush, broadcastStartOfIncrementalPush, broadcastStartOfPush, broadcastStartOfPush, broadcastStartOfPush, broadcastStartOfPush, broadcastTopicSwitch, broadcastVersionSwap, close, close, closeAsync, closeAsync, closePartition, delete, delete, delete, delete, delete, delete, delete, delete, deleteDeprecatedChunk, flush, generateHeartbeatMessage, getDestination, getHeartbeatKME, getKafkaMessageEnvelope, getLeaderCompleteStateHeader, getMaxRecordSizeBytes, getMaxSizeForUserPayloadPerMessageInBytes, getPartition, getProducerAdapter, getProducerGUID, getTime, getTopicName, isChunkingNeededForRecord, isRecordTooLarge, put, put, put, put, put, put, put, put, sendControlMessage, sendControlMessageWithRetriesForNonExistentTopic, sendHeartbeat, sendHeartbeat, sendStartOfSegment, toString, update
Methods inherited from class com.linkedin.venice.writer.AbstractVeniceWriter
put
-
Constructor Details
-
ComplexVeniceWriter
public ComplexVeniceWriter(VeniceWriterOptions params, VeniceProperties props, PubSubProducerAdapter producerAdapter)
-
-
Method Details
-
complexPut
public CompletableFuture<Void> complexPut(K key, V value, int valueSchemaId, Lazy<org.apache.avro.generic.GenericRecord> valueProvider) ComplexVenicePartitioner
offers a more sophisticated getPartitionId API. It also takes value as a parameter, and could return a single, multiple or no partition(s). -
complexDelete
public CompletableFuture<Void> complexDelete(K key, Lazy<org.apache.avro.generic.GenericRecord> valueProvider) Perform "delete" on the given key. If aComplexVenicePartitioner
is involved then it will be a best effort attempt to delete the record using the valueProvider. It's best effort because: 1. Nothing we can do if value is null or not provided via valueProvider. 2. Previous writes -
putLargeValue
protected CompletableFuture<PubSubProduceResult> putLargeValue(byte[] serializedKey, byte[] serializedValue, int valueSchemaId, PubSubProducerCallback callback, int partition, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, PutMetadata putMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Prevent theComplexVeniceWriter
from writing any actual chunks for large values. This is because we are only using ComplexVeniceWriter for writing to materialized view. The consumers of materialized view do not fully support assembling the chunks correctly yet. The behavior is the same for both large values from VPJ and leader replicas.- Overrides:
putLargeValue
in classVeniceWriter<K,
V, U>
-
put
public CompletableFuture<PubSubProduceResult> put(K key, V value, int valueSchemaId, PubSubProducerCallback callback, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, PutMetadata putMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Description copied from class:VeniceWriter
Execute a standard "put" on the key. VeniceReducer and VeniceSystemProducer should call this API.- Overrides:
put
in classVeniceWriter<K,
V, U> - Parameters:
key
- - The key to put in storage.value
- - The value to be associated with the given keyvalueSchemaId
- - value schema id for the given valuecallback
- - Callback function invoked by Kafka producer after sending the messageleaderMetadataWrapper
- - The leader Metadata of this message in the source topic: -1: VeniceWriter is sending this message in a Samza app to the real-time topic; or it's sending the message in VPJ plugin to the version topic; >=0: Leader replica consumes a put message from real-time topic, VeniceWriter in leader is sending this message to version topic with extra info: offset in the real-time topic.logicalTs
- - An timestamp field to indicate when this record was produced from apps view.putMetadata
- - a PutMetadata containing replication metadata related fields (can be null).- Returns:
- a java.util.concurrent.Future Future for the RecordMetadata that will be assigned to this record. Invoking java.util.concurrent.Future's get() on this future will block until the associated request completes and then return the metadata for the record or throw any exception that occurred while sending the record.
-
delete
public CompletableFuture<PubSubProduceResult> delete(K key, PubSubProducerCallback callback, LeaderMetadataWrapper leaderMetadataWrapper, long logicalTs, DeleteMetadata deleteMetadata, ChunkedValueManifest oldValueManifest, ChunkedValueManifest oldRmdManifest) Description copied from class:VeniceWriter
Execute a standard "delete" on the key.- Overrides:
delete
in classVeniceWriter<K,
V, U> - Parameters:
key
- - The key to delete in storage.callback
- - Callback function invoked by Kafka producer after sending the message.leaderMetadataWrapper
- - The leader Metadata of this message in the source topic: -1: VeniceWriter is sending this message in a Samza app to the real-time topic; or it's sending the message in VPJ plugin to the version topic; >=0: Leader replica consumes a DELETE message from real-time topic, VeniceWriter in leader is sending this message to version topic with extra info: offset in the real-time topic.logicalTs
- - An timestamp field to indicate when this record was produced from apps point of view.deleteMetadata
- - a DeleteMetadata containing replication metadata related fields (can be null).- Returns:
- a java.util.concurrent.CompletableFuture. Future for the RecordMetadata that will be assigned to this record. Invoking java.util.concurrent.CompletableFuture's get() on this future will block until the associated request completes and then return the metadata for the record or throw any exception that occurred while sending the record.
-
update
public Future<PubSubProduceResult> update(K key, U update, int valueSchemaId, int derivedSchemaId, PubSubProducerCallback callback, long logicalTs) - Overrides:
update
in classVeniceWriter<K,
V, U>
-