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 Summary
Constructors -
Method Summary
Modifier 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
-
setDelegate
This 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. -
isKeyUrnCompressionEnabled
public boolean isKeyUrnCompressionEnabled(int partitionId) -
setKeyDictCompressionFunction
public void setKeyDictCompressionFunction(Function<Integer, KeyUrnCompressor> keyDictCompressionFunction) -
getDelegate
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). -
getStoreVersionName
- Specified by:
getStoreVersionNamein interfaceStorageEngine<P extends AbstractStoragePartition>
-
getType
- Specified by:
getTypein interfaceStorageEngine<P extends AbstractStoragePartition>
-
getPersistedPartitionIds
- Specified by:
getPersistedPartitionIdsin interfaceStorageEngine<P extends AbstractStoragePartition>
-
adjustStoragePartition
public 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 interfaceStorageEngine<P extends AbstractStoragePartition>
-
addStoragePartitionIfAbsent
public void addStoragePartitionIfAbsent(int partitionId) - Specified by:
addStoragePartitionIfAbsentin interfaceStorageEngine<P extends AbstractStoragePartition>
-
addStoragePartition
- Specified by:
addStoragePartitionin interfaceStorageEngine<P extends AbstractStoragePartition>
-
closePartition
public void closePartition(int partitionId) - Specified by:
closePartitionin interfaceStorageEngine<P extends AbstractStoragePartition>
-
closeMetadataPartition
public void closeMetadataPartition()- Specified by:
closeMetadataPartitionin interfaceStorageEngine<P extends AbstractStoragePartition>
-
dropPartition
public void dropPartition(int partitionId) Description copied from interface:StorageEngineRemoves and returns a partition from the current store- Specified by:
dropPartitionin interfaceStorageEngine<P extends AbstractStoragePartition>- Parameters:
partitionId- - id of partition to retrieve and remove
-
dropPartition
public void dropPartition(int partitionId, boolean dropMetadataPartitionWhenEmpty) Description copied from interface:StorageEngineRemoves and returns a partition from the current store- Specified by:
dropPartitionin interfaceStorageEngine<P extends AbstractStoragePartition>- Parameters:
partitionId- - id of partition to retrieve and removedropMetadataPartitionWhenEmpty- - if true, the whole store will be dropped if ALL partitions are removed
-
drop
public void drop()Description copied from interface:StorageEngineDrop the whole store- Specified by:
dropin interfaceStorageEngine<P extends AbstractStoragePartition>
-
sync
- Specified by:
syncin interfaceStorageEngine<P extends AbstractStoragePartition>
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceStorageEngine<P extends AbstractStoragePartition>
-
endBatchWrite
- Specified by:
endBatchWritein interfaceStorageEngine<P extends AbstractStoragePartition>
-
reopenStoragePartition
public void reopenStoragePartition(int partitionId) Description copied from interface:StorageEngineReopen the underlying database.- Specified by:
reopenStoragePartitionin interfaceStorageEngine<P extends AbstractStoragePartition>
-
put
- Specified by:
putin interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
put
- Specified by:
putin interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
putWithReplicationMetadata
public void putWithReplicationMetadata(int partitionId, byte[] key, ByteBuffer value, byte[] replicationMetadata) throws VeniceException - Specified by:
putWithReplicationMetadatain interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
putReplicationMetadata
public void putReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) throws VeniceException - Specified by:
putReplicationMetadatain interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
get
- Specified by:
getin interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
get
public ByteBuffer get(int partitionId, byte[] key, ByteBuffer valueToBePopulated) throws VeniceException - Specified by:
getin interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
get
- Specified by:
getin interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
getByKeyPrefix
public void getByKeyPrefix(int partitionId, byte[] partialKey, BytesStreamingCallback bytesStreamingCallback) - Specified by:
getByKeyPrefixin interfaceStorageEngine<P extends AbstractStoragePartition>
-
delete
- Specified by:
deletein interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
deleteWithReplicationMetadata
public void deleteWithReplicationMetadata(int partitionId, byte[] key, byte[] replicationMetadata) throws VeniceException - Specified by:
deleteWithReplicationMetadatain interfaceStorageEngine<P extends AbstractStoragePartition>- Throws:
VeniceException
-
getReplicationMetadata
- Specified by:
getReplicationMetadatain interfaceStorageEngine<P extends AbstractStoragePartition>
-
putPartitionOffset
Description copied from interface:StorageEnginePut the offset associated with the partitionId into the metadata partition.- Specified by:
putPartitionOffsetin interfaceStorageEngine<P extends AbstractStoragePartition>
-
getPartitionOffset
Description copied from interface:StorageEngineRetrieve the offset associated with the partitionId from the metadata partition.- Specified by:
getPartitionOffsetin interfaceStorageEngine<P extends AbstractStoragePartition>
-
clearPartitionOffset
public void clearPartitionOffset(int partitionId) Description copied from interface:StorageEngineClear the offset associated with the partitionId in the metadata partition.- Specified by:
clearPartitionOffsetin interfaceStorageEngine<P extends AbstractStoragePartition>
-
putStoreVersionState
Description copied from interface:StorageEnginePut the store version state into the metadata partition.- Specified by:
putStoreVersionStatein interfaceStorageEngine<P extends AbstractStoragePartition>
-
updateStoreVersionStateCache
Description 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 interfaceStorageEngine<P extends AbstractStoragePartition>
-
getStoreVersionState
Description copied from interface:StorageEngineRetrieve the store version state from the metadata partition.- Specified by:
getStoreVersionStatein interfaceStorageEngine<P extends AbstractStoragePartition>
-
clearStoreVersionState
public void clearStoreVersionState()Description copied from interface:StorageEngineClear the store version state in the metadata partition.- Specified by:
clearStoreVersionStatein interfaceStorageEngine<P extends AbstractStoragePartition>
-
containsPartition
public 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 interfaceStorageEngine<P extends AbstractStoragePartition>- Parameters:
partitionId- The partition to look for- Returns:
- True/False, does the partition exist on this node
-
getPartitionIds
Description copied from interface:StorageEngineGet all Partition Ids which are assigned to the current Node.- Specified by:
getPartitionIdsin interfaceStorageEngine<P extends AbstractStoragePartition>- Returns:
- partition Ids that are hosted in the current Storage Engine.
-
getPartitionOrThrow
- Specified by:
getPartitionOrThrowin interfaceStorageEngine<P extends AbstractStoragePartition>
-
getIterator
- Specified by:
getIteratorin interfaceStorageEngine<P extends AbstractStoragePartition>
-
suppressLogs
public void suppressLogs(boolean b) - Specified by:
suppressLogsin interfaceStorageEngine<P extends AbstractStoragePartition>
-
getStats
- Specified by:
getStatsin interfaceStorageEngine<P extends AbstractStoragePartition>
-
beginBatchWrite
public 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 interfaceStorageEngine<P extends AbstractStoragePartition>
-
checkDatabaseIntegrity
public 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 interfaceStorageEngine<P extends AbstractStoragePartition>
-