Package com.linkedin.davinci.store
Class DelegatingStorageEngine<P extends AbstractStoragePartition>
java.lang.Object
com.linkedin.davinci.store.DelegatingStorageEngine<P>
- All Implemented Interfaces:
- StorageEngine<P>,- Closeable,- AutoCloseable
public class DelegatingStorageEngine<P extends AbstractStoragePartition>
extends Object
implements StorageEngine<P>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddStoragePartition(StoragePartitionConfig storagePartitionConfig) voidaddStoragePartitionIfAbsent(int partitionId) voidadjustStoragePartition(int partitionId, StoragePartitionAdjustmentTrigger mode, StoragePartitionConfig partitionConfig) Adjust the opened storage partition according to the provided storagePartitionConfig.voidbeginBatchWrite(StoragePartitionConfig storagePartitionConfig, Map<String, String> checkpointedInfo, Optional<Supplier<byte[]>> checksumSupplier) A lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source.booleancheckDatabaseIntegrity(int partitionId, Map<String, String> checkpointedInfo, StoragePartitionConfig storagePartitionConfig) checks whether the current state of the database is valid during the start of ingestion.voidclearPartitionOffset(int partitionId) Clear the offset associated with the partitionId in the metadata partition.voidClear the store version state in the metadata partition.voidclose()voidvoidclosePartition(int partitionId) booleancontainsPartition(int partitionId) Return true or false based on whether a given partition exists within this storage enginevoiddelete(int partitionId, byte[] key) voiddeleteWithReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) voiddrop()Drop the whole storevoiddropPartition(int partitionId) Removes and returns a partition from the current storevoiddropPartition(int partitionId, boolean dropMetadataPartitionWhenEmpty) Removes and returns a partition from the current storevoidendBatchWrite(StoragePartitionConfig storagePartitionConfig) byte[]get(int partitionId, byte[] key) get(int partitionId, byte[] key, ByteBuffer valueToBePopulated) byte[]get(int partitionId, ByteBuffer keyBuffer) voidgetByKeyPrefix(int partitionId, byte[] partialKey, BytesStreamingCallback bytesStreamingCallback) protected StorageEngine<P>Subclasses should be able to access the delegate, but other classes should not, otherwise they could keep a handle on the delegate, while the delegate may later be swapped viasetDelegate(StorageEngine).getIterator(int partitionId) Get all Partition Ids which are assigned to the current Node.getPartitionOffset(int partitionId, PubSubContext pubSubContext) Retrieve the offset associated with the partitionId from the metadata partition.getPartitionOrThrow(int partitionId) byte[]getReplicationMetadata(int partitionId, ByteBuffer key) getStats()Retrieve the store version state from the metadata partition.getType()booleanisClosed()booleanisKeyUrnCompressionEnabled(int partitionId) voidput(int partitionId, byte[] key, byte[] value) voidput(int partitionId, byte[] key, ByteBuffer value) voidputPartitionOffset(int partitionId, OffsetRecord offsetRecord) Put the offset associated with the partitionId into the metadata partition.voidputReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) voidputStoreVersionState(StoreVersionState versionState) Put the store version state into the metadata partition.voidputWithReplicationMetadata(int partitionId, byte[] key, ByteBuffer value, byte[] replicationMetadata) voidreopenStoragePartition(int partitionId) Reopen the underlying database.voidsetDelegate(StorageEngine<P> delegate) This setter can be used to swap the delegate which all calls get forwarded to.voidsetKeyDictCompressionFunction(Function<Integer, KeyUrnCompressor> keyDictCompressionFunction) voidsuppressLogs(boolean b) sync(int partitionId) voidupdateStoreVersionStateCache(StoreVersionState versionState) Used in ingestion isolation mode update the storage engine's cache in sync with the updates to the state inMainIngestionStorageMetadataService
- 
Constructor Details- 
DelegatingStorageEngine
 
- 
- 
Method Details- 
setDelegateThis setter can be used to swap the delegate which all calls get forwarded to. In this way, in cases where a storage engine needs to be closed and later on a new one needs to be re-opened, this fact can be hidden from other classes needing to hold a reference to the storage engine. At the time of writing this JavaDoc, only theStorageServiceclass is tasked with managing storage engine lifecycles in this way.
- 
isKeyUrnCompressionEnabledpublic boolean isKeyUrnCompressionEnabled(int partitionId) 
- 
setKeyDictCompressionFunctionpublic void setKeyDictCompressionFunction(Function<Integer, KeyUrnCompressor> keyDictCompressionFunction) 
- 
getDelegateSubclasses should be able to access the delegate, but other classes should not, otherwise they could keep a handle on the delegate, while the delegate may later be swapped viasetDelegate(StorageEngine).
- 
getStoreVersionName- Specified by:
- getStoreVersionNamein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getType- Specified by:
- getTypein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getPersistedPartitionIds- Specified by:
- getPersistedPartitionIdsin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
adjustStoragePartitionpublic void adjustStoragePartition(int partitionId, StoragePartitionAdjustmentTrigger mode, StoragePartitionConfig partitionConfig) Description copied from interface:StorageEngineAdjust the opened storage partition according to the provided storagePartitionConfig. It will throw exception if there is no opened storage partition for the given partition id. The reason to have is mainly used to ease the unit test.- Specified by:
- adjustStoragePartitionin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
addStoragePartitionIfAbsentpublic void addStoragePartitionIfAbsent(int partitionId) - Specified by:
- addStoragePartitionIfAbsentin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
addStoragePartition- Specified by:
- addStoragePartitionin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
closePartitionpublic void closePartition(int partitionId) - Specified by:
- closePartitionin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
closeMetadataPartitionpublic void closeMetadataPartition()- Specified by:
- closeMetadataPartitionin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
dropPartitionpublic void dropPartition(int partitionId) Description copied from interface:StorageEngineRemoves and returns a partition from the current store- Specified by:
- dropPartitionin interface- StorageEngine<P extends AbstractStoragePartition>
- Parameters:
- partitionId- - id of partition to retrieve and remove
 
- 
dropPartitionpublic void dropPartition(int partitionId, boolean dropMetadataPartitionWhenEmpty) Description copied from interface:StorageEngineRemoves and returns a partition from the current store- Specified by:
- dropPartitionin interface- StorageEngine<P extends AbstractStoragePartition>
- Parameters:
- partitionId- - id of partition to retrieve and remove
- dropMetadataPartitionWhenEmpty- - if true, the whole store will be dropped if ALL partitions are removed
 
- 
droppublic void drop()Description copied from interface:StorageEngineDrop the whole store- Specified by:
- dropin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
sync- Specified by:
- syncin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
isClosedpublic boolean isClosed()- Specified by:
- isClosedin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
endBatchWrite- Specified by:
- endBatchWritein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
reopenStoragePartitionpublic void reopenStoragePartition(int partitionId) Description copied from interface:StorageEngineReopen the underlying database.- Specified by:
- reopenStoragePartitionin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
put- Specified by:
- putin interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
put- Specified by:
- putin interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
putWithReplicationMetadatapublic void putWithReplicationMetadata(int partitionId, byte[] key, ByteBuffer value, byte[] replicationMetadata) throws VeniceException - Specified by:
- putWithReplicationMetadatain interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
putReplicationMetadatapublic void putReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) throws VeniceException - Specified by:
- putReplicationMetadatain interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
get- Specified by:
- getin interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
getpublic ByteBuffer get(int partitionId, byte[] key, ByteBuffer valueToBePopulated) throws VeniceException - Specified by:
- getin interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
get- Specified by:
- getin interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
getByKeyPrefixpublic void getByKeyPrefix(int partitionId, byte[] partialKey, BytesStreamingCallback bytesStreamingCallback) - Specified by:
- getByKeyPrefixin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
delete- Specified by:
- deletein interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
deleteWithReplicationMetadatapublic void deleteWithReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) throws VeniceException - Specified by:
- deleteWithReplicationMetadatain interface- StorageEngine<P extends AbstractStoragePartition>
- Throws:
- VeniceException
 
- 
getReplicationMetadata- Specified by:
- getReplicationMetadatain interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
putPartitionOffsetDescription copied from interface:StorageEnginePut the offset associated with the partitionId into the metadata partition.- Specified by:
- putPartitionOffsetin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getPartitionOffsetDescription copied from interface:StorageEngineRetrieve the offset associated with the partitionId from the metadata partition.- Specified by:
- getPartitionOffsetin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
clearPartitionOffsetpublic void clearPartitionOffset(int partitionId) Description copied from interface:StorageEngineClear the offset associated with the partitionId in the metadata partition.- Specified by:
- clearPartitionOffsetin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
putStoreVersionStateDescription copied from interface:StorageEnginePut the store version state into the metadata partition.- Specified by:
- putStoreVersionStatein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
updateStoreVersionStateCacheDescription copied from interface:StorageEngineUsed in ingestion isolation mode update the storage engine's cache in sync with the updates to the state inMainIngestionStorageMetadataService- Specified by:
- updateStoreVersionStateCachein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getStoreVersionStateDescription copied from interface:StorageEngineRetrieve the store version state from the metadata partition.- Specified by:
- getStoreVersionStatein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
clearStoreVersionStatepublic void clearStoreVersionState()Description copied from interface:StorageEngineClear the store version state in the metadata partition.- Specified by:
- clearStoreVersionStatein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
containsPartitionpublic boolean containsPartition(int partitionId) Description copied from interface:StorageEngineReturn true or false based on whether a given partition exists within this storage engine- Specified by:
- containsPartitionin interface- StorageEngine<P extends AbstractStoragePartition>
- Parameters:
- partitionId- The partition to look for
- Returns:
- True/False, does the partition exist on this node
 
- 
getPartitionIdsDescription copied from interface:StorageEngineGet all Partition Ids which are assigned to the current Node.- Specified by:
- getPartitionIdsin interface- StorageEngine<P extends AbstractStoragePartition>
- Returns:
- partition Ids that are hosted in the current Storage Engine.
 
- 
getPartitionOrThrow- Specified by:
- getPartitionOrThrowin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getIterator- Specified by:
- getIteratorin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
suppressLogspublic void suppressLogs(boolean b) - Specified by:
- suppressLogsin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
getStats- Specified by:
- getStatsin interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
beginBatchWritepublic void beginBatchWrite(StoragePartitionConfig storagePartitionConfig, Map<String, String> checkpointedInfo, Optional<Supplier<byte[]>> checksumSupplier) Description copied from interface:StorageEngineA lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source. This method puts the storage engine in this batch write mode- Specified by:
- beginBatchWritein interface- StorageEngine<P extends AbstractStoragePartition>
 
- 
checkDatabaseIntegritypublic boolean checkDatabaseIntegrity(int partitionId, Map<String, String> checkpointedInfo, StoragePartitionConfig storagePartitionConfig) Description copied from interface:StorageEnginechecks whether the current state of the database is valid during the start of ingestion.- Specified by:
- checkDatabaseIntegrityin interface- StorageEngine<P extends AbstractStoragePartition>
 
 
-