Package com.linkedin.davinci.repository
Class NativeMetadataRepository
java.lang.Object
com.linkedin.davinci.repository.NativeMetadataRepository
- All Implemented Interfaces:
ClusterInfoProvider,ReadOnlySchemaRepository,ReadOnlyStoreRepository,SubscriptionBasedReadOnlyStoreRepository,VeniceResource
- Direct Known Subclasses:
RequestBasedMetaRepository,ThinClientMetaStoreBasedRepository
public abstract class NativeMetadataRepository
extends Object
implements SubscriptionBasedReadOnlyStoreRepository, ReadOnlySchemaRepository, ClusterInfoProvider
Venice in-house implementation of a read only metadata repository where callers can retrieve various metadata such as
Store objects and their corresponding schemas. The implementers of this abstract class all relies on some flavors of
Venice system store to carry the metadata from Venice internal components (source) to external consumers such as a
DaVinci client (destination). This abstract class includes the implementation of an in-memory cache for all subscribed
stores' metadata. Callers are served by the cache and the cache is refreshed periodically by updating it with methods
provided by the implementers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNativeMetadataRepository(ClientConfig clientConfig, VeniceProperties backendConfig) protectedNativeMetadataRepository(ClientConfig clientConfig, VeniceProperties backendConfig, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprotected StoreConfigcacheStoreConfigFromRemote(String storeName) Get the store cluster config from system store and update the local cache with it.voidclear()TODO: we may need to rename this function to be 'close' since this resource should not used any more after calling this function.protected abstract StoreConfigfetchStoreConfigFromRemote(String storeName) protected abstract StorefetchStoreFromRemote(String storeName, String clusterName) Get all stores in the current repositoryprotected SchemaDatagetAndCacheSchemaData(String storeName) intgetBatchGetLimit(String storeName) Get batch-get limit for the specified storegetDerivedSchema(String storeName, int valueSchemaId, int derivedSchemaId) getDerivedSchemaId(String storeName, String derivedSchemaStr) Look up derived schema id and its corresponding value schema id by given store name and derived schema.getDerivedSchemas(String storeName) static NativeMetadataRepositorygetInstance(ClientConfig clientConfig, VeniceProperties backendConfig) static NativeMetadataRepositorygetInstance(ClientConfig clientConfig, VeniceProperties backendConfig, ICProvider icProvider) getKeySchema(String storeName) This function is used to retrieve key schema for the given store.getLatestDerivedSchema(String storeName, int valueSchemaId) Get the most recent derived schema added to the given store and value schema idgetReplicationMetadataSchema(String storeName, int valueSchemaId, int replicationMetadataVersionId) getReplicationMetadataSchemas(String storeName) protected abstract SchemaDatagetSchemaData(String storeName) Get one store by given name from repository.getStoreOrThrow(String storeName) getSupersetOrLatestValueSchema(String storeName) Get the most recent value schema or superset value schema if one exists.getSupersetSchema(String storeName) Get the superset value schema for a given store.longGet total read quota of all stores.getValueSchema(String storeName, int id) This function is used to retrieve the value schema for the given store and value schema id.intgetValueSchemaId(String storeName, String valueSchemaStr) This function is used to retrieve value schema id for the given store and schema.protected SchemaEntrygetValueSchemaInternally(String storeName, int id) getValueSchemas(String storeName) This function is used to retrieve all the value schemas for the given store.getVeniceCluster(String storeName) Get the associated Venice cluster name given a Venice store name.booleanWhether the store exists or not.booleanhasValueSchema(String storeName, int id) This function is used to check whether the value schema id is valid in the given store.booleanisReadComputationEnabled(String storeName) Whether computation is enabled for the specified store.protected voidnotifyStoreChanged(Store store) protected voidnotifyStoreCreated(Store store) protected voidnotifyStoreDeleted(Store store) protected Storevoidrefresh()This method will be triggered periodically to keep the store/schema information up-to-date.refreshOneStore(String storeName) Selective refresh operation which fetches one store from ZKvoidRegister store data change listener.protected StoreremoveStore(String storeName) protected voidremoveStoreSchema(String storeName) This function is used to remove schema entry for the given store from local cache, and related listeners as well.voidstart()voidvoidUnregister store data change listener.voidunsubscribe(String storeName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.venice.meta.ReadOnlySchemaRepository
getLatestDerivedSchemaMethods inherited from interface com.linkedin.venice.meta.ReadOnlyStoreRepository
waitVersion, waitVersion
-
Field Details
-
clientConfig
-
subscribedStoreMap
-
schemaMap
-
-
Constructor Details
-
NativeMetadataRepository
-
NativeMetadataRepository
protected NativeMetadataRepository(ClientConfig clientConfig, VeniceProperties backendConfig, Clock clock)
-
-
Method Details
-
start
public void start() -
getInstance
public static NativeMetadataRepository getInstance(ClientConfig clientConfig, VeniceProperties backendConfig) -
getInstance
public static NativeMetadataRepository getInstance(ClientConfig clientConfig, VeniceProperties backendConfig, ICProvider icProvider) -
subscribe
- Specified by:
subscribein interfaceSubscriptionBasedReadOnlyStoreRepository- Throws:
InterruptedException
-
unsubscribe
- Specified by:
unsubscribein interfaceSubscriptionBasedReadOnlyStoreRepository
-
getStore
Description copied from interface:ReadOnlyStoreRepositoryGet one store by given name from repository.- Specified by:
getStorein interfaceReadOnlyStoreRepository- Parameters:
storeName- name of wanted store.- Returns:
- Store for given name.
-
getStoreOrThrow
- Specified by:
getStoreOrThrowin interfaceReadOnlyStoreRepository- Throws:
VeniceNoStoreException
-
hasStore
Description copied from interface:ReadOnlyStoreRepositoryWhether the store exists or not.- Specified by:
hasStorein interfaceReadOnlyStoreRepository- Parameters:
storeName- store name- Returns:
-
refreshOneStore
Description copied from interface:ReadOnlyStoreRepositorySelective refresh operation which fetches one store from ZK- Specified by:
refreshOneStorein interfaceReadOnlyStoreRepository- Parameters:
storeName- store name- Returns:
- the newly refreshed store
-
getAllStores
Description copied from interface:ReadOnlyStoreRepositoryGet all stores in the current repository- Specified by:
getAllStoresin interfaceReadOnlyStoreRepository- Returns:
-
getTotalStoreReadQuota
public long getTotalStoreReadQuota()Description copied from interface:ReadOnlyStoreRepositoryGet total read quota of all stores.- Specified by:
getTotalStoreReadQuotain interfaceReadOnlyStoreRepository
-
registerStoreDataChangedListener
Description copied from interface:ReadOnlyStoreRepositoryRegister store data change listener.- Specified by:
registerStoreDataChangedListenerin interfaceReadOnlyStoreRepository
-
unregisterStoreDataChangedListener
Description copied from interface:ReadOnlyStoreRepositoryUnregister store data change listener.- Specified by:
unregisterStoreDataChangedListenerin interfaceReadOnlyStoreRepository
-
getBatchGetLimit
Description copied from interface:ReadOnlyStoreRepositoryGet batch-get limit for the specified store- Specified by:
getBatchGetLimitin interfaceReadOnlyStoreRepository- Returns:
-
isReadComputationEnabled
Description copied from interface:ReadOnlyStoreRepositoryWhether computation is enabled for the specified store.- Specified by:
isReadComputationEnabledin interfaceReadOnlyStoreRepository- Parameters:
storeName- store name- Returns:
-
getKeySchema
This function is used to retrieve key schema for the given store. If key schema for the given store doesn't exist, will return null; Otherwise, it will return the key schema;- Specified by:
getKeySchemain interfaceReadOnlySchemaRepository- Returns:
- null, if key schema for the given store doesn't exist; key schema entry, otherwise;
-
getValueSchema
This function is used to retrieve the value schema for the given store and value schema id. Caller shouldn't modify the returned SchemeEntry- Specified by:
getValueSchemain interfaceReadOnlySchemaRepository- Returns:
- null, if the schema doesn't exist; value schema entry, otherwise;
-
hasValueSchema
This function is used to check whether the value schema id is valid in the given store.- Specified by:
hasValueSchemain interfaceReadOnlySchemaRepository
-
getValueSchemaId
This function is used to retrieve value schema id for the given store and schema.- Specified by:
getValueSchemaIdin interfaceReadOnlySchemaRepository- Returns:
SchemaData.INVALID_VALUE_SCHEMA_ID, if the schema doesn't exist in the given store; schema id (int), if the schema exists in the given store
-
getValueSchemas
This function is used to retrieve all the value schemas for the given store.- Specified by:
getValueSchemasin interfaceReadOnlySchemaRepository
-
getSupersetOrLatestValueSchema
Description copied from interface:ReadOnlySchemaRepositoryGet the most recent value schema or superset value schema if one exists.- Specified by:
getSupersetOrLatestValueSchemain interfaceReadOnlySchemaRepository
-
getSupersetSchema
Description copied from interface:ReadOnlySchemaRepositoryGet the superset value schema for a given store. Each store has at most one active superset schema. Specifically a store must have some features enabled (e.g. read compute, write compute) to have a superset value schema which evolves as new value schemas are added.- Specified by:
getSupersetSchemain interfaceReadOnlySchemaRepository- Returns:
- Superset value schema or
nullif store does not have any superset value schema.
-
getDerivedSchemaId
Description copied from interface:ReadOnlySchemaRepositoryLook up derived schema id and its corresponding value schema id by given store name and derived schema. This is likely used by clients that write to Venice- Specified by:
getDerivedSchemaIdin interfaceReadOnlySchemaRepository- Returns:
- a pair where the first value is value schema id and the second value is derived schema id
-
getDerivedSchema
public DerivedSchemaEntry getDerivedSchema(String storeName, int valueSchemaId, int derivedSchemaId) - Specified by:
getDerivedSchemain interfaceReadOnlySchemaRepository
-
getDerivedSchemas
- Specified by:
getDerivedSchemasin interfaceReadOnlySchemaRepository
-
getLatestDerivedSchema
Description copied from interface:ReadOnlySchemaRepositoryGet the most recent derived schema added to the given store and value schema id- Specified by:
getLatestDerivedSchemain interfaceReadOnlySchemaRepository
-
getReplicationMetadataSchema
public RmdSchemaEntry getReplicationMetadataSchema(String storeName, int valueSchemaId, int replicationMetadataVersionId) - Specified by:
getReplicationMetadataSchemain interfaceReadOnlySchemaRepository
-
getReplicationMetadataSchemas
- Specified by:
getReplicationMetadataSchemasin interfaceReadOnlySchemaRepository
-
refresh
public void refresh()This method will be triggered periodically to keep the store/schema information up-to-date.- Specified by:
refreshin interfaceVeniceResource
-
clear
public void clear()TODO: we may need to rename this function to be 'close' since this resource should not used any more after calling this function.- Specified by:
clearin interfaceVeniceResource
-
cacheStoreConfigFromRemote
Get the store cluster config from system store and update the local cache with it. Different implementation will get the data differently but should all populate the store cluster config map. -
fetchStoreConfigFromRemote
-
fetchStoreFromRemote
-
getSchemaData
-
putStore
-
removeStore
-
notifyStoreCreated
-
notifyStoreDeleted
-
notifyStoreChanged
-
getAndCacheSchemaData
-
getValueSchemaInternally
-
removeStoreSchema
This function is used to remove schema entry for the given store from local cache, and related listeners as well. -
getVeniceCluster
Description copied from interface:ClusterInfoProviderGet the associated Venice cluster name given a Venice store name.- Specified by:
getVeniceClusterin interfaceClusterInfoProvider- Returns:
- the cluster name that the store belongs to or null if such information cannot be provided.
-