Package com.linkedin.venice.writer
Interface VeniceWriterHook
public interface VeniceWriterHook
Callback hook invoked by
VeniceWriter after size validation and before producing a record
to the pub-sub system. Not invoked for records rejected by size checks (RecordTooLargeException).
Set via VeniceWriterOptions.Builder.setWriterHook(VeniceWriterHook) at construction time.
Threading: Called on the caller's thread (the thread invoking VeniceWriter.put(K, V, int, com.linkedin.venice.pubsub.api.PubSubProducerCallback),
VeniceWriter.delete(K, com.linkedin.venice.pubsub.api.PubSubProducerCallback), or VeniceWriter.update(K, U, int, int, com.linkedin.venice.pubsub.api.PubSubProducerCallback)) without holding partition locks.
Implementations must be thread-safe (multiple threads may call concurrently).
Exception handling: Exceptions thrown from onBeforeProduce(com.linkedin.venice.writer.VeniceWriterHook.OperationType, int, int) will propagate up and
fail the write. Implementations should handle their own errors if they do not want to break
the write path.
Chunking: For large records that get chunked, the hook fires once with the original
pre-chunking sizes, not per-chunk.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidonBeforeProduce(VeniceWriterHook.OperationType operationType, int keySizeBytes, int valueSizeBytes) Called with serialized byte sizes before producing to the pub-sub system.
-
Method Details
-
onBeforeProduce
void onBeforeProduce(VeniceWriterHook.OperationType operationType, int keySizeBytes, int valueSizeBytes) Called with serialized byte sizes before producing to the pub-sub system. May block to apply backpressure (e.g., quota throttling).- Parameters:
operationType- the type of write operation (PUT, DELETE, or UPDATE)keySizeBytes- serialized key size in bytesvalueSizeBytes- serialized value/update-payload size in bytes (0 for deletes)
-