Class DelegatingAvroStoreClient<K,V>
- All Implemented Interfaces:
AvroGenericReadComputeStoreClient<K,,V> AvroGenericStoreClient<K,,V> Closeable,AutoCloseable
- Direct Known Subclasses:
DualReadAvroGenericStoreClient,LoadControlledAvroGenericStoreClient,RetriableAvroGenericStoreClient,StatsAvroGenericStoreClient
n-tier architecture => Having multiple layers where each layer wraps the next inner one. Each layer provides some functionality, e.g. stats collection, etc.
Fast-Client's layers include the below components. Check
ClientFactory.getAndStartGenericStoreClient(com.linkedin.venice.fastclient.ClientConfig)
to figure out how the layers are put together for different requirements.
Layer -1:
AvroGenericStoreClient, AvroGenericReadComputeStoreClient => interfaces: Borrowed from thin-client
Layer 0:
InternalAvroStoreClient implements AvroGenericReadComputeStoreClient => The abstract class
implementing above interfaces for fast-client. All other internal implementations of different tiers should extend
this class.
Layer 1:
DispatchingAvroGenericStoreClient extends InternalAvroStoreClient => in charge of routing and
serialization/de-serialization
Layer 2:
RetriableAvroGenericStoreClient extends DelegatingAvroStoreClient => Adds optional retry ability on
top of DispatchingAvroGenericStoreClient
Layer 3:
StatsAvroGenericStoreClient extends DelegatingAvroStoreClient => Adds stats on top of Layer 2 or
Layer 1. There is no option to disable it, but if needed, can be disabled.
Layer 4:
DualReadAvroGenericStoreClient extends DelegatingAvroStoreClient => Adds an extra read via thin
client on top of Layer 3.
utils class:
DelegatingAvroStoreClient extends InternalAvroStoreClient => Delegator pattern to not override all
the functions in every superclass in a duplicate manner.
Interactions between these class for some flows: https://swimlanes.io/u/iHTCBvlf0
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingAvroStoreClient(InternalAvroStoreClient<K, V> delegate, ClientConfig clientConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Release the internal resources.protected voidcompute(ComputeRequestContext<K, V> requestContext, ComputeRequestWrapper computeRequestWrapper, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, ComputeGenericRecord> callback, long preRequestTimeInNS) compute(Optional<ClientStats> stats, Optional<ClientStats> streamingStats, AvroGenericReadComputeStoreClient computeStoreClient, long preRequestTimeInNS) decompressAndDeserialize(ByteBuffer rawValue, int version, K key) Re-entry point for callers that obtained Venice-format raw value bytes from a path other than the standard Venice routing layer (e.g.protected CompletableFuture<V>get(GetRequestContext<K> requestContext, K key) org.apache.avro.SchemaGet key schema.org.apache.avro.SchemaDeprecated.voidRegister aStoreConfigChangeListenerthat fires when the underlying metadata layer observes a change to the store-level config snapshot (e.g.voidRegister aStoreVersionSwitchListenerthat fires when the underlying metadata layer observes a change to the store's current serving version.voidstart()protected voidstreamingBatchGet(BatchGetRequestContext<K, V> requestContext, Set<K> keys, StreamingCallback<K, V> callback) Methods inherited from class com.linkedin.venice.fastclient.InternalAvroStoreClient
batchGet, batchGet, compute, computeWithKeyPrefixFilter, get, isProjectionFieldValidationEnabled, streamingBatchGet, streamingBatchGet, streamingBatchGetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.venice.client.store.AvroGenericReadComputeStoreClient
compute, compute, compute, computeAggregationMethods inherited from interface com.linkedin.venice.client.store.AvroGenericStoreClient
get
-
Constructor Details
-
DelegatingAvroStoreClient
-
-
Method Details
-
getClientConfig
- Specified by:
getClientConfigin classInternalAvroStoreClient<K,V>
-
getSchemaReader
-
get
protected CompletableFuture<V> get(GetRequestContext<K> requestContext, K key) throws VeniceClientException - Specified by:
getin classInternalAvroStoreClient<K,V> - Throws:
VeniceClientException
-
streamingBatchGet
protected void streamingBatchGet(BatchGetRequestContext<K, V> requestContext, Set<K> keys, StreamingCallback<K, V> callback) - Specified by:
streamingBatchGetin classInternalAvroStoreClient<K,V>
-
compute
protected void compute(ComputeRequestContext<K, V> requestContext, ComputeRequestWrapper computeRequestWrapper, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, throws VeniceClientExceptionComputeGenericRecord> callback, long preRequestTimeInNS) - Specified by:
computein classInternalAvroStoreClient<K,V> - Throws:
VeniceClientException
-
start
- Throws:
VeniceClientException
-
close
public void close()Description copied from interface:AvroGenericStoreClientRelease the internal resources. -
getStoreName
-
getKeySchema
public org.apache.avro.Schema getKeySchema()Description copied from interface:AvroGenericStoreClientGet key schema. -
getLatestValueSchema
Deprecated.Description copied from interface:AvroGenericStoreClientGet the latest value schema known in current store client. This function doesn't guarantee it will return the latest schema if you add a new value schema when current store client is running. -
compute
public ComputeRequestBuilder<K> compute(Optional<ClientStats> stats, Optional<ClientStats> streamingStats, AvroGenericReadComputeStoreClient computeStoreClient, long preRequestTimeInNS) throws VeniceClientException - Throws:
VeniceClientException
-
decompressAndDeserialize
public V decompressAndDeserialize(ByteBuffer rawValue, int version, K key) throws VeniceClientException Description copied from interface:AvroGenericStoreClientRe-entry point for callers that obtained Venice-format raw value bytes from a path other than the standard Venice routing layer (e.g. an external storage system holding the same wire bytes) and want to run those bytes through the Fast Client's existing decompression + Avro deserialization pipeline without duplicating that logic.This entry point is Fast Client only — implemented by
com.linkedin.venice.fastclient.DispatchingAvroGenericStoreClientand forwarded by Fast Client'sDelegatingAvroStoreClientwrapper chain. Thin-client implementations inherit the throwing default because they lack the metadata refresh loop that supplies per-version compression state.Wire format.
rawValuemust hold the bytes exactly as Venice's storage layer writes them on disk / to an external sink: a 4-byte big-endianintwriter-schema id followed by the post-compression Avro-serialized value body. This matches whatcom.linkedin.venice.writer.DualWriteVeniceWriter#toRocksDbFormattedValueproduces for the dual-write external sink. The seam reads the schema id from those 4 bytes (so a store that has schema-evolved will still decode old payloads with their original writer schema), resolves the per-version compressor fromStoreMetadata, decompresses the remainder, and deserializes with the embedded schema id.- Parameters:
rawValue- the value payload, prefixed by a 4-byte big-endian writer-schema id. Must not benulland must have at least 4 bytes.version- the store version therawValuebytes were written under. Used to resolve the per-version compressor (including any ZSTD dictionary). Throws if the version is unknown to the metadata layer.key- the key that produced this value (used only for error messages and tracing)- Returns:
- the deserialized value
- Throws:
VeniceClientException- if the version is unknown, or if decompression or deserialization fails
-
registerVersionSwitchListener
Description copied from interface:AvroGenericStoreClientRegister aStoreVersionSwitchListenerthat fires when the underlying metadata layer observes a change to the store's current serving version.Fast Client only. Thin-client implementations inherit the throwing default — there is no metadata refresh loop on the thin client, so version-switch transitions are not observable. See
com.linkedin.venice.fastclient.DispatchingAvroGenericStoreClientfor the Fast Client implementation andStoreVersionSwitchListenerfor threading and exception semantics.Registration timing. Listeners must be registered before
AvroGenericStoreClient.start()to observe the initial transition committed by the first metadata refresh. Listeners registered afterstart()returns observe only subsequent transitions (and re-entrant registration from inside a callback observes only subsequent transitions as well). Callers needing the initial transition should use the non-starting factory entry point (com.linkedin.venice.fastclient.factory.ClientFactory#getGenericStoreClient), register their listeners, then callstart()on the returned client.Registration is thread-safe.
-
registerStoreConfigChangeListener
Description copied from interface:AvroGenericStoreClientRegister aStoreConfigChangeListenerthat fires when the underlying metadata layer observes a change to the store-level config snapshot (e.g. operator-drivenexternalStorageReadModeflip).Fast Client only. Thin-client implementations inherit the throwing default. See
com.linkedin.venice.fastclient.DispatchingAvroGenericStoreClientfor the Fast Client implementation andStoreConfigChangeListenerfor threading and exception semantics.Registration timing. Same as
AvroGenericStoreClient.registerVersionSwitchListener(com.linkedin.venice.client.store.listeners.StoreVersionSwitchListener)— register beforeAvroGenericStoreClient.start()to observe the initial snapshot; post-start registration observes only subsequent changes.
-