Package com.linkedin.venice.client.store
Class AbstractAvroStoreClient<K,V>
java.lang.Object
com.linkedin.venice.client.store.InternalAvroStoreClient<K,V>
com.linkedin.venice.client.store.AbstractAvroStoreClient<K,V>
- All Implemented Interfaces:
AvroGenericReadComputeStoreClient<K,
,V> AvroGenericStoreClient<K,
,V> Closeable
,AutoCloseable
- Direct Known Subclasses:
AvroGenericStoreClientImpl
,AvroSpecificStoreClientImpl
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected RecordSerializer<ByteBuffer>
protected RecordSerializer<K>
protected RecordSerializer<ByteBuffer>
protected final boolean
static final String
static final String
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAvroStoreClient
(TransportClient transportClient, boolean needSchemaReader, ClientConfig clientConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
The behavior of READ apis will be non-deterministic after `close` function is called.void
compute
(ComputeRequestWrapper computeRequest, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, ComputeGenericRecord> callback, long preRequestTimeInNS) protected RecordSerializer<K>
Clients using different protocols for deserialized data (e.g VSON, Proto, etc) can override this method to serialize the respective POJO to Avro bytesget
(K key, Optional<ClientStats> stats, long preRequestTimeInNS) protected final ClientConfig
protected String
abstract RecordDeserializer<V>
getDataRecordDeserializer
(int schemaId) static Executor
org.apache.avro.Schema
Get key schema.protected RecordSerializer<K>
This function will try to initialize the store client at most once in a blocking fashion, and if the init fails, one async thread will be kicked off to init the store client periodically until the init succeeds.protected RecordSerializer<K>
org.apache.avro.Schema
Deprecated.CompletableFuture<byte[]>
getRaw
(String requestPath, Optional<ClientStats> stats, long preRequestTimeInNS) protected Optional<org.apache.avro.Schema>
getRequestPathByKey
(K key) protected abstract AbstractAvroStoreClient<K,
V> To avoid cycle dependency, we need to initialize another store client for schema reader.protected TransportClient
protected static boolean
handleCallbackForEmptyKeySet
(Collection<?> keys, StreamingCallback callback) protected void
init()
During the initialization, we do the cluster discovery at first to find the real end point this client need to talk to, before initializing the serializer.boolean
void
setAsyncStoreInitSleepIntervalMs
(long intervalMs) void
start()
void
streamingBatchGet
(Set<K> keys, StreamingCallback<K, V> callback) Streaming interface forAvroGenericStoreClient.batchGet(Set)
.toString()
static <T,
K> T tryToDeserializeWithVerboseLogging
(RecordDeserializer<T> dataDeserializer, ByteBuffer data, int writerSchemaId, K key, RecordSerializer<K> keySerializer, SchemaReader schemaReader, org.apache.logging.log4j.Logger LOGGER) Methods inherited from class com.linkedin.venice.client.store.InternalAvroStoreClient
computeWithKeyPrefixFilter, get, getRaw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linkedin.venice.client.store.AvroGenericReadComputeStoreClient
compute, compute, compute, compute
Methods inherited from interface com.linkedin.venice.client.store.AvroGenericStoreClient
batchGet, get, streamingBatchGet
-
Field Details
-
TYPE_STORAGE
- See Also:
-
TYPE_COMPUTE
- See Also:
-
B64_FORMAT
- See Also:
-
needSchemaReader
protected final boolean needSchemaReader -
keySerializer
-
multiGetRequestSerializer
-
computeRequestClientKeySerializer
-
-
Constructor Details
-
AbstractAvroStoreClient
protected AbstractAvroStoreClient(TransportClient transportClient, boolean needSchemaReader, ClientConfig clientConfig)
-
-
Method Details
-
getDefaultDeserializationExecutor
-
getStoreName
-
getClientConfig
-
getTransportClient
-
getSchemaReader
-
getDeserializationExecutor
- Overrides:
getDeserializationExecutor
in classInternalAvroStoreClient<K,
V>
-
getComputeRequestPath
-
setAsyncStoreInitSleepIntervalMs
public void setAsyncStoreInitSleepIntervalMs(long intervalMs) -
getKeySerializerForRequest
This function will try to initialize the store client at most once in a blocking fashion, and if the init fails, one async thread will be kicked off to init the store client periodically until the init succeeds. -
getKeySerializerWithoutRetry
-
init
protected void init()During the initialization, we do the cluster discovery at first to find the real end point this client need to talk to, before initializing the serializer. So if sub-implementation needs to have its own serializer, please override the createKeySerializer method. -
createKeySerializer
Clients using different protocols for deserialized data (e.g VSON, Proto, etc) can override this method to serialize the respective POJO to Avro bytes- Returns:
- A serializer for key objects to Avro bytes
-
getRequestPathByKey
- Throws:
VeniceClientException
-
get
public CompletableFuture<V> get(K key, Optional<ClientStats> stats, long preRequestTimeInNS) throws VeniceClientException - Specified by:
get
in classInternalAvroStoreClient<K,
V> - Throws:
VeniceClientException
-
getRaw
public CompletableFuture<byte[]> getRaw(String requestPath, Optional<ClientStats> stats, long preRequestTimeInNS) - Specified by:
getRaw
in classInternalAvroStoreClient<K,
V>
-
tryToDeserializeWithVerboseLogging
public static <T,K> T tryToDeserializeWithVerboseLogging(RecordDeserializer<T> dataDeserializer, ByteBuffer data, int writerSchemaId, K key, RecordSerializer<K> keySerializer, SchemaReader schemaReader, org.apache.logging.log4j.Logger LOGGER) -
isProjectionFieldValidationEnabled
public boolean isProjectionFieldValidationEnabled() -
compute
public void compute(ComputeRequestWrapper computeRequest, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, ComputeGenericRecord> callback, long preRequestTimeInNS) throws VeniceClientException- Throws:
VeniceClientException
-
start
- Throws:
VeniceClientException
-
close
public void close()The behavior of READ apis will be non-deterministic after `close` function is called. -
getReaderSchema
-
getStoreClientForSchemaReader
To avoid cycle dependency, we need to initialize another store client for schema reader.- Returns:
- Throws:
VeniceClientException
-
getDataRecordDeserializer
public abstract RecordDeserializer<V> getDataRecordDeserializer(int schemaId) throws VeniceClientException - Throws:
VeniceClientException
-
toString
-
getKeySchema
public org.apache.avro.Schema getKeySchema()Description copied from interface:AvroGenericStoreClient
Get key 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. -
streamingBatchGet
public void streamingBatchGet(Set<K> keys, StreamingCallback<K, V> callback) throws VeniceClientExceptionDescription copied from interface:AvroGenericStoreClient
Streaming interface forAvroGenericStoreClient.batchGet(Set)
. You can find more info inStreamingCallback
.- Throws:
VeniceClientException
-
handleCallbackForEmptyKeySet
protected static boolean handleCallbackForEmptyKeySet(Collection<?> keys, StreamingCallback callback)
-