Package com.linkedin.davinci.client
Class AvroGenericDaVinciClient<K,V>
java.lang.Object
com.linkedin.davinci.client.AvroGenericDaVinciClient<K,V>
- All Implemented Interfaces:
DaVinciClient<K,,V> AvroGenericReadComputeStoreClient<K,,V> AvroGenericStoreClient<K,,V> Closeable,AutoCloseable
- Direct Known Subclasses:
AvroGenericSeekableDaVinciClient,AvroSpecificDaVinciClient,AvroSpecificSeekableDaVinciClient
public class AvroGenericDaVinciClient<K,V>
extends Object
implements DaVinciClient<K,V>, AvroGenericReadComputeStoreClient<K,V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected final org.apache.logging.log4j.Loggerstatic final ExecutorServiceThe following two fields are used to speed up the requests with a big number of keys: 1.protected StoreBackendprotected final ComplementSet<Integer> -
Constructor Summary
ConstructorsModifierConstructorDescriptionAvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients) protectedAvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients, ICProvider icProvider, AbstractAvroChunkingAdapter<V> chunkingAdapter, Runnable preValidation, Executor readChunkExecutorForLargeRequest, Integer storeVersion) AvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients, ICProvider icProvider, Executor readChunkExecutorForLargeRequest) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPartitionsToSubscription(ComplementSet<Integer> partitions) Get the values associated with the given keys and return them in a map of keys to values.voidclose()Release the internal resources.voidcompute(ComputeRequestWrapper computeRequestWrapper, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, ComputeGenericRecord> callback, long preRequestTimeInNS) compute(Optional<ClientStats> stats, AvroGenericReadComputeStoreClient computeStoreClient) voidcomputeWithKeyPrefixFilter(byte[] keyPrefix, ComputeRequestWrapper computeRequestWrapper, StreamingCallback<org.apache.avro.generic.GenericRecord, org.apache.avro.generic.GenericRecord> callback) protected D2ServiceDiscoveryResponseLookup the value by given key, and get(key).get() will return null if it doesn't exist.Similar toAvroGenericStoreClient.get(Object)except that it allows passing in a instance, to minimize GC.protected AbstractAvroChunkingAdapter<V>static DaVinciBackendprotected GenericRecordChunkingAdapterorg.apache.avro.SchemaGet key schema.org.apache.avro.SchemaDeprecated.intGet partition count of a store.protected Integerprotected voidinitBackend(ClientConfig clientConfig, VeniceConfigLoader configLoader, Optional<Set<String>> managedClients, ICProvider icProvider, Optional<ObjectCacheConfig> cacheConfig) protected booleanisPartitionReadyToServe(VersionBackend versionBackend, int partition) Check if user partition is ready to serve traffic.protected booleanisPartitionSubscribed(VersionBackend versionBackend, int partition) booleanbooleanisReady()protected CompletableFuture<Void>seekToCheckpoint(Set<VeniceChangeCoordinate> checkpoints) protected CompletableFuture<Void>seekToTimestamps(Long timestamps) protected CompletableFuture<Void>seekToTimestamps(Map<Integer, Long> timestamps) voidstart()voidstreamingBatchGet(Set<K> keys, StreamingCallback<K, V> callback) Streaming interface forAvroGenericStoreClient.batchGet(Set).protected CompletableFuture<Void>subscribe(ComplementSet<Integer> partitions) Ingest specific partition/partitions locally.Ingest the entire data (i.e.protected voidtoString()protected voidunsubscribe(ComplementSet<Integer> partitions) voidunsubscribe(Set<Integer> partitions) Stop ingesting a partition locally, and drop its associated local states/data.voidStop ingesting all subscribed partition locally, and drop their associated local states/data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
streamingBatchGet
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
READ_CHUNK_EXECUTOR
The following two fields are used to speed up the requests with a big number of keys: 1. Split the big request into smaller chunks. 2. Execute these chunks concurrently. -
DEFAULT_CHUNK_SPLIT_THRESHOLD
public static final int DEFAULT_CHUNK_SPLIT_THRESHOLD- See Also:
-
subscription
-
storeBackend
-
-
Constructor Details
-
AvroGenericDaVinciClient
public AvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients) -
AvroGenericDaVinciClient
public AvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients, ICProvider icProvider, Executor readChunkExecutorForLargeRequest) -
AvroGenericDaVinciClient
protected AvroGenericDaVinciClient(DaVinciConfig daVinciConfig, ClientConfig clientConfig, VeniceProperties backendConfig, Optional<Set<String>> managedClients, ICProvider icProvider, AbstractAvroChunkingAdapter<V> chunkingAdapter, Runnable preValidation, Executor readChunkExecutorForLargeRequest, Integer storeVersion)
-
-
Method Details
-
getSchemaReader
- Specified by:
getSchemaReaderin interfaceAvroGenericReadComputeStoreClient<K,V>
-
getStoreName
- Specified by:
getStoreNamein interfaceAvroGenericStoreClient<K,V>
-
getKeySchema
public org.apache.avro.Schema getKeySchema()Description copied from interface:AvroGenericStoreClientGet key schema.- Specified by:
getKeySchemain interfaceAvroGenericStoreClient<K,V>
-
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.- Specified by:
getLatestValueSchemain interfaceAvroGenericStoreClient<K,V>
-
getPartitionCount
public int getPartitionCount()Description copied from interface:DaVinciClientGet partition count of a store.- Specified by:
getPartitionCountin interfaceDaVinciClient<K,V> - Returns:
- partition count
-
subscribeAll
Description copied from interface:DaVinciClientIngest the entire data (i.e. all partitions) locally.- Specified by:
subscribeAllin interfaceDaVinciClient<K,V> - Returns:
- a future which completes when the data is ready to serve
-
subscribe
Description copied from interface:DaVinciClientIngest specific partition/partitions locally.- Specified by:
subscribein interfaceDaVinciClient<K,V> - Parameters:
partitions- the set of partition IDs to subscribe to- Returns:
- a future which completes when the partitions are ready to serve
-
seekToCheckpoint
-
seekToTimestamps
-
seekToTimestamps
-
subscribe
-
unsubscribeAll
public void unsubscribeAll()Description copied from interface:DaVinciClientStop ingesting all subscribed partition locally, and drop their associated local states/data. If applications intend to keep the states/data for future use, no need to invoke this function before callingAvroGenericStoreClient.close().- Specified by:
unsubscribeAllin interfaceDaVinciClient<K,V>
-
unsubscribe
Description copied from interface:DaVinciClientStop ingesting a partition locally, and drop its associated local states/data. If applications intend to keep the states/data for future use, no need to invoke this function before callingAvroGenericStoreClient.close().- Specified by:
unsubscribein interfaceDaVinciClient<K,V> - Parameters:
partitions- the set of partition IDs to unsubscribe from
-
unsubscribe
-
get
Description copied from interface:AvroGenericStoreClientLookup the value by given key, and get(key).get() will return null if it doesn't exist. For now, if any backend error/exception happens, get(Object key).get() will throwExecutionException, which is a wrapper of the real exception.- Specified by:
getin interfaceAvroGenericStoreClient<K,V> - Returns:
-
get
Description copied from interface:AvroGenericStoreClientSimilar toAvroGenericStoreClient.get(Object)except that it allows passing in a instance, to minimize GC.- Specified by:
getin interfaceAvroGenericStoreClient<K,V>
-
split
-
batchGet
Description copied from interface:AvroGenericStoreClientGet the values associated with the given keys and return them in a map of keys to values. Note that the returned map will only contain entries for the keys which have a value associated with them.- Specified by:
batchGetin interfaceAvroGenericStoreClient<K,V> - Returns:
- Throws:
VeniceClientException
-
streamingBatchGet
public void streamingBatchGet(Set<K> keys, StreamingCallback<K, V> callback) throws VeniceClientExceptionDescription copied from interface:AvroGenericStoreClientStreaming interface forAvroGenericStoreClient.batchGet(Set). You can find more info inStreamingCallback.- Specified by:
streamingBatchGetin interfaceAvroGenericStoreClient<K,V> - Throws:
VeniceClientException
-
isProjectionFieldValidationEnabled
public boolean isProjectionFieldValidationEnabled()- Specified by:
isProjectionFieldValidationEnabledin interfaceAvroGenericReadComputeStoreClient<K,V>
-
compute
public ComputeRequestBuilder<K> compute(Optional<ClientStats> stats, AvroGenericReadComputeStoreClient computeStoreClient) throws VeniceClientException - Specified by:
computein interfaceAvroGenericReadComputeStoreClient<K,V> - Throws:
VeniceClientException
-
compute
public void compute(ComputeRequestWrapper computeRequestWrapper, Set<K> keys, org.apache.avro.Schema resultSchema, StreamingCallback<K, ComputeGenericRecord> callback, long preRequestTimeInNS) throws VeniceClientException- Specified by:
computein interfaceAvroGenericReadComputeStoreClient<K,V> - Throws:
VeniceClientException
-
computeWithKeyPrefixFilter
public void computeWithKeyPrefixFilter(byte[] keyPrefix, ComputeRequestWrapper computeRequestWrapper, StreamingCallback<org.apache.avro.generic.GenericRecord, org.apache.avro.generic.GenericRecord> callback) - Specified by:
computeWithKeyPrefixFilterin interfaceAvroGenericReadComputeStoreClient<K,V>
-
isReady
public boolean isReady() -
isPartitionReadyToServe
Check if user partition is ready to serve traffic. -
isPartitionSubscribed
-
throwIfNotReady
protected void throwIfNotReady() -
getAvroChunkingAdapter
-
getGenericRecordChunkingAdapter
-
discoverService
-
initBackend
protected void initBackend(ClientConfig clientConfig, VeniceConfigLoader configLoader, Optional<Set<String>> managedClients, ICProvider icProvider, Optional<ObjectCacheConfig> cacheConfig) -
getBackend
-
start
public void start()- Specified by:
startin interfaceAvroGenericStoreClient<K,V>
-
close
public void close()Description copied from interface:AvroGenericStoreClientRelease the internal resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceAvroGenericStoreClient<K,V> - Specified by:
closein interfaceCloseable
-
toString
-
getStoreVersion
- Returns:
- the version this client is specifically subscribed to. If it's null, it's a regular client.
-
addPartitionsToSubscription
-