Details
-
Task
-
Resolution: Incomplete
-
Major - P3
-
None
-
None
-
None
-
None
-
Serverless
Description
Implement TenantToShardCache::getShard(OID& tenantId) to load the shard for the tenant from config.tenants on the config servers.
For this ticket, we can give TenantToShardCache a private map from tenantId (OID) to ShardId. getShard can simply look up from this map. In a future ticket, we will replace the private map with a private ReadThroughCache.
If there is no entry in the map, TenantToShardCache::getShard should load the entry from config.tenants, which is currently on the config servers. To do this, TenantToShardCache::getShard can call a new method similar to ShardingCatalogClient::getCollection, which reads from config.collections on the config servers.
This ticket should add a unit test of TenantToShardCache::getShard, and can use catalog_cache_test.cpp's GetDatabase and GetCachedDatabase as examples.
–
Additional implementation notes:
1. The ObjectId type in cpp is OID. Here is an example of a hash map keyed by OID.
2. ShardingCatalogClient::getCollection returns a CollectionType, which is parser and serializer in cpp. It wraps CollectionTypeBase, which is a parser and serializer in IDL. We should create a TenantType, and use IDL. TenantType should contain a tenant id of IDL type 'objectid' (example) and shard id of IDL type 'shard_id' (example). 'objectid' converts to OID in cpp, and 'shard_id' converts to ShardId in cpp.