Package com.linkedin.venice.helix
Class HelixReadOnlySchemaRepository
java.lang.Object
com.linkedin.venice.helix.HelixReadOnlySchemaRepository
- All Implemented Interfaces:
ReadOnlySchemaRepository,StoreDataChangedListener,VeniceResource
- Direct Known Subclasses:
HelixReadOnlyZKSharedSchemaRepository
public class HelixReadOnlySchemaRepository
extends Object
implements ReadOnlySchemaRepository, StoreDataChangedListener
This class is used to cache store schema and provide various query operations.
This expected user is router to support venice client schema query operations,
and storage node for schema validation;
TODO:
1. This class needs to periodically clear/warm up local cache since we might miss some notifications:
1.` Re-connect;
One way to achieve to record the previous clear timestamp, and clear it again when the duration
exceeds some amount of time in query functions.
We need to reach out Helix team for this issue since it will impact Helix cache as well.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHelixReadOnlySchemaRepository(ReadOnlyStoreRepository storeRepository, org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapter, String clusterName, int refreshAttemptsForZkReconnect, long refreshIntervalForZkReconnectInMs) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear local cache and watchesgetDerivedSchema(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) 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) getSupersetOrLatestValueSchema(String storeName) Caller shouldn't modify the returned SchemeEntrygetSupersetSchema(String storeName) Get the superset value schema for a given store.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.getValueSchemas(String storeName) This function is used to retrieve all the value schemas for the given store.voidhandleStoreChanged(Store store) voidhandleStoreCreated(Store store) Do nothing here, since we want to warm up local cache gradually.voidhandleStoreDeleted(String storeName) For store deletion, we need to delete the local cache entry right way, otherwise the local cache may contain the stale entries for store-delete-and-add scenario.booleanhasValueSchema(String storeName, int id) This function is used to check whether the value schema id is valid in the given store.voidrefresh()Refer toclear()This function will clear the local cache/watches, and populates the schemaMap from schemaRepository.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.StoreDataChangedListener
handleStoreDeleted
-
Field Details
-
VALUE_SCHEMA_STARTING_ID
public static final int VALUE_SCHEMA_STARTING_ID- See Also:
-
-
Constructor Details
-
HelixReadOnlySchemaRepository
public HelixReadOnlySchemaRepository(ReadOnlyStoreRepository storeRepository, org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapter, String clusterName, int refreshAttemptsForZkReconnect, long refreshIntervalForZkReconnectInMs)
-
-
Method Details
-
getKeySchema
This function is used to retrieve key schema for the given store. If store doesn't exist, this function will return null; If key schema for the given store doesn't exist, will return null; Otherwise, it will return the key schema; Caller shouldn't modify the returned SchemeEntry- 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
-
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
-
getValueSchemas
This function is used to retrieve all the value schemas for the given store. Caller shouldn't modify the returned SchemeEntry list.- Specified by:
getValueSchemasin interfaceReadOnlySchemaRepository- Returns:
- value schema list
-
getDerivedSchemas
- Specified by:
getDerivedSchemasin interfaceReadOnlySchemaRepository
-
getSupersetOrLatestValueSchema
Caller shouldn't modify the returned SchemeEntry- 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.
-
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()Refer toclear()This function will clear the local cache/watches, and populates the schemaMap from schemaRepository.- Specified by:
refreshin interfaceVeniceResource
-
clear
public void clear()Clear local cache and watches- Specified by:
clearin interfaceVeniceResource
-
handleStoreCreated
Do nothing here, since we want to warm up local cache gradually.- Specified by:
handleStoreCreatedin interfaceStoreDataChangedListener
-
handleStoreDeleted
For store deletion, we need to delete the local cache entry right way, otherwise the local cache may contain the stale entries for store-delete-and-add scenario.- Specified by:
handleStoreDeletedin interfaceStoreDataChangedListener
-
handleStoreChanged
- Specified by:
handleStoreChangedin interfaceStoreDataChangedListener
-