Class DispatchingAvroGenericStoreClient<K,V>

java.lang.Object
com.linkedin.venice.fastclient.InternalAvroStoreClient<K,V>
com.linkedin.venice.fastclient.DispatchingAvroGenericStoreClient<K,V>
All Implemented Interfaces:
AvroGenericReadComputeStoreClient<K,V>, AvroGenericStoreClient<K,V>, Closeable, AutoCloseable
Direct Known Subclasses:
DispatchingAvroSpecificStoreClient, DispatchingVsonStoreClient

public class DispatchingAvroGenericStoreClient<K,V> extends InternalAvroStoreClient<K,V>
This class is in charge of routing and serialization/de-serialization.
  • Field Details

  • Constructor Details

  • Method Details

    • getStoreMetadata

      protected StoreMetadata getStoreMetadata()
    • getClientConfig

      public ClientConfig getClientConfig()
      Specified by:
      getClientConfig in class InternalAvroStoreClient<K,V>
    • get

      protected CompletableFuture<V> get(GetRequestContext<K> requestContext, K key) throws VeniceClientException
      Specified by:
      get in class InternalAvroStoreClient<K,V>
      Throws:
      VeniceClientException
    • streamingBatchGet

      protected void streamingBatchGet(BatchGetRequestContext<K,V> requestContext, Set<K> keys, StreamingCallback<K,V> callback)
      This is the main implementation of the "streaming" version of batch get. As such this API doesn't provide a way to handle early exceptions. Further we tend to mix callback style and future style of asynchronous programming which makes it hard to make flexible and composable abstractions on top of this. For future enhancements we could consider returning a java stream , a bounded stream in the shape of a flux (project reactor), or one of the similar java 9 flow constructs.
      Specified by:
      streamingBatchGet in class InternalAvroStoreClient<K,V>
      Parameters:
      requestContext -
      keys -
      callback -
    • compute

      protected void compute(ComputeRequestContext<K,V> requestContext, ComputeRequestWrapper computeRequest, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K,ComputeGenericRecord> callback, long preRequestTimeInNS) throws VeniceClientException
      Specified by:
      compute in class InternalAvroStoreClient<K,V>
      Throws:
      VeniceClientException
    • getMultiGetResponseRecordDeserializer

      protected RecordDeserializer<MultiGetResponseRecordV1> getMultiGetResponseRecordDeserializer(int schemaId)
    • getDataRecordDeserializer

      protected RecordDeserializer<V> getDataRecordDeserializer(int schemaId) throws VeniceClientException
      Throws:
      VeniceClientException
    • start

      public void start() throws VeniceClientException
      Throws:
      VeniceClientException
    • getKeySerializer

      protected RecordSerializer<K> getKeySerializer(org.apache.avro.Schema keySchema)
    • close

      public void close()
      Description copied from interface: AvroGenericStoreClient
      Release the internal resources.
    • getStoreName

      public String getStoreName()
    • getKeySchema

      public org.apache.avro.Schema getKeySchema()
      Description copied from interface: AvroGenericStoreClient
      Get key schema.
    • getLatestValueSchema

      @Deprecated public org.apache.avro.Schema getLatestValueSchema()
      Deprecated.
      Description copied from interface: AvroGenericStoreClient
      Get 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.
    • getSchemaReader

      public SchemaReader getSchemaReader()
    • decompressAndDeserialize

      public V decompressAndDeserialize(ByteBuffer rawValue, int version, K key) throws VeniceClientException
      Fast Client implementation of the external-storage re-entry seam. Reads the 4-byte BE writer-schema-id prefix from rawValue, resolves the per-version compressor from metadata (including any ZSTD dictionary cached on prior refreshes), decompresses the remainder, and runs the existing deserialization pipeline at the embedded schema id. Reuses getDataRecordDeserializer(int) + tryToDeserialize(com.linkedin.venice.serializer.RecordDeserializer<T>, java.nio.ByteBuffer, int, K) so any future change to the in-band read path propagates here automatically.
      Parameters:
      rawValue - the value payload, prefixed by a 4-byte big-endian writer-schema id. Must not be null and must have at least 4 bytes.
      version - the store version the rawValue bytes 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

      public void registerVersionSwitchListener(StoreVersionSwitchListener listener)
      Description copied from interface: AvroGenericStoreClient
      Register a StoreVersionSwitchListener that 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.DispatchingAvroGenericStoreClient for the Fast Client implementation and StoreVersionSwitchListener for 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 after start() 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 call start() on the returned client.

      Registration is thread-safe.

    • registerStoreConfigChangeListener

      public void registerStoreConfigChangeListener(StoreConfigChangeListener listener)
      Description copied from interface: AvroGenericStoreClient
      Register a StoreConfigChangeListener that fires when the underlying metadata layer observes a change to the store-level config snapshot (e.g. operator-driven externalStorageReadMode flip).

      Fast Client only. Thin-client implementations inherit the throwing default. See com.linkedin.venice.fastclient.DispatchingAvroGenericStoreClient for the Fast Client implementation and StoreConfigChangeListener for threading and exception semantics.

      Registration timing. Same as AvroGenericStoreClient.registerVersionSwitchListener(com.linkedin.venice.client.store.listeners.StoreVersionSwitchListener) — register before AvroGenericStoreClient.start() to observe the initial snapshot; post-start registration observes only subsequent changes.