Package com.linkedin.venice.helix
Class HelixReadWriteSchemaRepositoryAdapter
- java.lang.Object
-
- com.linkedin.venice.helix.HelixReadWriteSchemaRepositoryAdapter
-
- All Implemented Interfaces:
ReadOnlySchemaRepository
,ReadWriteSchemaRepository
,VeniceResource
public class HelixReadWriteSchemaRepositoryAdapter extends java.lang.Object implements ReadWriteSchemaRepository
This repository supports the following operations: 1. For the regular stores, read/write operations are supported asHelixReadWriteSchemaRepository
. 2. For system stores, only read operations are supported viaHelixReadOnlyZKSharedSchemaRepository
, and if you want to update the schemas for system stores, you will need to update the corresponding zk shared store instead.
-
-
Constructor Summary
Constructors Constructor Description HelixReadWriteSchemaRepositoryAdapter(HelixReadOnlyZKSharedSchemaRepository readOnlyZKSharedSchemaRepository, ReadWriteSchemaRepository readWriteRegularStoreSchemaRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DerivedSchemaEntry
addDerivedSchema(java.lang.String storeName, java.lang.String schemaStr, int valueSchemaId)
Add a new derived schema for the given store and value schema idDerivedSchemaEntry
addDerivedSchema(java.lang.String storeName, java.lang.String schemaStr, int valueSchemaId, int derivedSchemaId)
Add a new derived schema for the given store by specifying derived schema id.RmdSchemaEntry
addReplicationMetadataSchema(java.lang.String storeName, int valueSchemaId, java.lang.String replicationMetadataSchemaStr, int replicationMetadataVersionId)
SchemaEntry
addValueSchema(java.lang.String storeName, java.lang.String schemaStr, int schemaId)
Add a new value schema for the given store by specifying schema id.SchemaEntry
addValueSchema(java.lang.String storeName, java.lang.String schemaStr, DirectionalSchemaCompatibilityType expectedCompatibilityType)
Add a new value schema for the given storevoid
clear()
DerivedSchemaEntry
getDerivedSchema(java.lang.String storeName, int valueSchemaId, int derivedSchemaId)
GeneratedSchemaID
getDerivedSchemaId(java.lang.String storeName, java.lang.String derivedSchemaStr)
Look up derived schema id and its corresponding value schema id by given store name and derived schema.java.util.Collection<DerivedSchemaEntry>
getDerivedSchemas(java.lang.String storeName)
SchemaEntry
getKeySchema(java.lang.String storeName)
Get key schema for the given store.DerivedSchemaEntry
getLatestDerivedSchema(java.lang.String storeName, int valueSchemaId)
Get the most recent derived schema added to the given store and value schema idReadWriteSchemaRepository
getReadWriteRegularStoreSchemaRepository()
RmdSchemaEntry
getReplicationMetadataSchema(java.lang.String storeName, int valueSchemaId, int replicationMetadataVersionId)
java.util.Collection<RmdSchemaEntry>
getReplicationMetadataSchemas(java.lang.String storeName)
SchemaEntry
getSupersetOrLatestValueSchema(java.lang.String storeName)
Get the most recent value schema or superset value schema if one exists.SchemaEntry
getSupersetSchema(java.lang.String storeName)
Get the superset value schema for a given store.SchemaEntry
getValueSchema(java.lang.String storeName, int id)
Get value schema for the given store and value schema id.int
getValueSchemaId(java.lang.String storeName, java.lang.String valueSchemaStr)
Return the schema ID of any schema for the store that has the same parsing canonical form as the schema provided.java.util.Collection<SchemaEntry>
getValueSchemas(java.lang.String storeName)
Get all the value schemas for the given store.boolean
hasValueSchema(java.lang.String storeName, int id)
Check whether the specified schema id is valid or notSchemaEntry
initKeySchema(java.lang.String storeName, java.lang.String schemaStr)
Set up key schema for the given storeint
preCheckDerivedSchemaAndGetNextAvailableId(java.lang.String storeName, int valueSchemaId, java.lang.String derivedSchemaStr)
int
preCheckValueSchemaAndGetNextAvailableId(java.lang.String storeName, java.lang.String valueSchemaStr, DirectionalSchemaCompatibilityType expectedCompatibilityType)
void
refresh()
DerivedSchemaEntry
removeDerivedSchema(java.lang.String storeName, int valueSchemaId, int derivedSchemaId)
Remove an existing derived schemavoid
removeValueSchema(java.lang.String storeName, int schemaID)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.venice.meta.ReadOnlySchemaRepository
getLatestDerivedSchema
-
Methods inherited from interface com.linkedin.venice.meta.ReadWriteSchemaRepository
addValueSchema
-
-
-
-
Constructor Detail
-
HelixReadWriteSchemaRepositoryAdapter
public HelixReadWriteSchemaRepositoryAdapter(HelixReadOnlyZKSharedSchemaRepository readOnlyZKSharedSchemaRepository, ReadWriteSchemaRepository readWriteRegularStoreSchemaRepository)
-
-
Method Detail
-
initKeySchema
public SchemaEntry initKeySchema(java.lang.String storeName, java.lang.String schemaStr)
Description copied from interface:ReadWriteSchemaRepository
Set up key schema for the given store- Specified by:
initKeySchema
in interfaceReadWriteSchemaRepository
-
addValueSchema
public SchemaEntry addValueSchema(java.lang.String storeName, java.lang.String schemaStr, DirectionalSchemaCompatibilityType expectedCompatibilityType)
Description copied from interface:ReadWriteSchemaRepository
Add a new value schema for the given store- Specified by:
addValueSchema
in interfaceReadWriteSchemaRepository
-
addValueSchema
public SchemaEntry addValueSchema(java.lang.String storeName, java.lang.String schemaStr, int schemaId)
Description copied from interface:ReadWriteSchemaRepository
Add a new value schema for the given store by specifying schema id. This API is mostly intended to be used in cross-colo mode. When there are multiple colos, we'd like to have consistent value id across colos, so that deserializer can work properly while reading records. Caller should figure out the schema id number by themselves. TODO: Might want to remove it from the interface and make it invisible from the outside- Specified by:
addValueSchema
in interfaceReadWriteSchemaRepository
-
addDerivedSchema
public DerivedSchemaEntry addDerivedSchema(java.lang.String storeName, java.lang.String schemaStr, int valueSchemaId)
Description copied from interface:ReadWriteSchemaRepository
Add a new derived schema for the given store and value schema id- Specified by:
addDerivedSchema
in interfaceReadWriteSchemaRepository
-
addDerivedSchema
public DerivedSchemaEntry addDerivedSchema(java.lang.String storeName, java.lang.String schemaStr, int valueSchemaId, int derivedSchemaId)
Description copied from interface:ReadWriteSchemaRepository
Add a new derived schema for the given store by specifying derived schema id. Mostly used in cross-colo mode.- Specified by:
addDerivedSchema
in interfaceReadWriteSchemaRepository
-
removeDerivedSchema
public DerivedSchemaEntry removeDerivedSchema(java.lang.String storeName, int valueSchemaId, int derivedSchemaId)
Description copied from interface:ReadWriteSchemaRepository
Remove an existing derived schema- Specified by:
removeDerivedSchema
in interfaceReadWriteSchemaRepository
- Returns:
- the derived schema that is deleted or null if the schema doesn't exist
-
preCheckValueSchemaAndGetNextAvailableId
public int preCheckValueSchemaAndGetNextAvailableId(java.lang.String storeName, java.lang.String valueSchemaStr, DirectionalSchemaCompatibilityType expectedCompatibilityType)
- Specified by:
preCheckValueSchemaAndGetNextAvailableId
in interfaceReadWriteSchemaRepository
-
preCheckDerivedSchemaAndGetNextAvailableId
public int preCheckDerivedSchemaAndGetNextAvailableId(java.lang.String storeName, int valueSchemaId, java.lang.String derivedSchemaStr)
- Specified by:
preCheckDerivedSchemaAndGetNextAvailableId
in interfaceReadWriteSchemaRepository
-
getKeySchema
public SchemaEntry getKeySchema(java.lang.String storeName)
Description copied from interface:ReadOnlySchemaRepository
Get key schema for the given store.- Specified by:
getKeySchema
in interfaceReadOnlySchemaRepository
-
getValueSchema
public SchemaEntry getValueSchema(java.lang.String storeName, int id)
Description copied from interface:ReadOnlySchemaRepository
Get value schema for the given store and value schema id.- Specified by:
getValueSchema
in interfaceReadOnlySchemaRepository
-
hasValueSchema
public boolean hasValueSchema(java.lang.String storeName, int id)
Description copied from interface:ReadOnlySchemaRepository
Check whether the specified schema id is valid or not- Specified by:
hasValueSchema
in interfaceReadOnlySchemaRepository
-
getValueSchemaId
public int getValueSchemaId(java.lang.String storeName, java.lang.String valueSchemaStr)
Description copied from interface:ReadOnlySchemaRepository
Return the schema ID of any schema for the store that has the same parsing canonical form as the schema provided.- Specified by:
getValueSchemaId
in interfaceReadOnlySchemaRepository
-
getValueSchemas
public java.util.Collection<SchemaEntry> getValueSchemas(java.lang.String storeName)
Description copied from interface:ReadOnlySchemaRepository
Get all the value schemas for the given store.- Specified by:
getValueSchemas
in interfaceReadOnlySchemaRepository
-
removeValueSchema
public void removeValueSchema(java.lang.String storeName, int schemaID)
- Specified by:
removeValueSchema
in interfaceReadWriteSchemaRepository
-
getSupersetOrLatestValueSchema
public SchemaEntry getSupersetOrLatestValueSchema(java.lang.String storeName)
Description copied from interface:ReadOnlySchemaRepository
Get the most recent value schema or superset value schema if one exists.- Specified by:
getSupersetOrLatestValueSchema
in interfaceReadOnlySchemaRepository
-
getSupersetSchema
public SchemaEntry getSupersetSchema(java.lang.String storeName)
Description copied from interface:ReadOnlySchemaRepository
Get 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:
getSupersetSchema
in interfaceReadOnlySchemaRepository
- Returns:
- Superset value schema or
null
if store {@param storeName} does not have any superset value schema.
-
getDerivedSchemaId
public GeneratedSchemaID getDerivedSchemaId(java.lang.String storeName, java.lang.String derivedSchemaStr)
Description copied from interface:ReadOnlySchemaRepository
Look 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:
getDerivedSchemaId
in interfaceReadOnlySchemaRepository
- Returns:
- a pair where the first value is value schema id and the second value is derived schema id
-
getDerivedSchema
public DerivedSchemaEntry getDerivedSchema(java.lang.String storeName, int valueSchemaId, int derivedSchemaId)
- Specified by:
getDerivedSchema
in interfaceReadOnlySchemaRepository
-
getDerivedSchemas
public java.util.Collection<DerivedSchemaEntry> getDerivedSchemas(java.lang.String storeName)
- Specified by:
getDerivedSchemas
in interfaceReadOnlySchemaRepository
-
getLatestDerivedSchema
public DerivedSchemaEntry getLatestDerivedSchema(java.lang.String storeName, int valueSchemaId)
Description copied from interface:ReadOnlySchemaRepository
Get the most recent derived schema added to the given store and value schema id- Specified by:
getLatestDerivedSchema
in interfaceReadOnlySchemaRepository
-
addReplicationMetadataSchema
public RmdSchemaEntry addReplicationMetadataSchema(java.lang.String storeName, int valueSchemaId, java.lang.String replicationMetadataSchemaStr, int replicationMetadataVersionId)
- Specified by:
addReplicationMetadataSchema
in interfaceReadWriteSchemaRepository
-
getReplicationMetadataSchema
public RmdSchemaEntry getReplicationMetadataSchema(java.lang.String storeName, int valueSchemaId, int replicationMetadataVersionId)
- Specified by:
getReplicationMetadataSchema
in interfaceReadOnlySchemaRepository
-
getReplicationMetadataSchemas
public java.util.Collection<RmdSchemaEntry> getReplicationMetadataSchemas(java.lang.String storeName)
- Specified by:
getReplicationMetadataSchemas
in interfaceReadOnlySchemaRepository
-
refresh
public void refresh()
- Specified by:
refresh
in interfaceVeniceResource
-
clear
public void clear()
- Specified by:
clear
in interfaceVeniceResource
-
getReadWriteRegularStoreSchemaRepository
public ReadWriteSchemaRepository getReadWriteRegularStoreSchemaRepository()
-
-