Package com.linkedin.venice.cleaner
Class BackupVersionOptimizationService
- java.lang.Object
-
- com.linkedin.venice.service.AbstractVeniceService
-
- com.linkedin.venice.cleaner.BackupVersionOptimizationService
-
- All Implemented Interfaces:
ResourceReadUsageTracker
,java.io.Closeable
,java.lang.AutoCloseable
public class BackupVersionOptimizationService extends AbstractVeniceService implements ResourceReadUsageTracker
This class is used to periodically scan inactive store versions and perform optimization if the inactive period of some store version meets the pre-configured threshold, this class will trigger the database reopen action to unload unnecessary RAM usage, which was built up when there were active reads coming. The optimization follows the following rules: 1. Don't touch current version no matter whether it is being actively used in the read path or not. 2. Don't touch versions, which are not ready-to-serve yet. 3. If some specific store version is ready-to-serve, but haven't been active recently, this class will reopen all the storage partitions belonging to the inactive version to free up unnecessary RAM usage. 4. Don't reopen the database again if there is no more read usage after the optimization. This optimization is mainly forRocksDBStorageEngine
. 1. Block-based format. Reopening the database will release the index/filter usages from the shared block cache. 2. Plain-table format. Reopening the database will un-mmap the file contents, which were brought into memory by the past read requests.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.linkedin.venice.service.AbstractVeniceService
AbstractVeniceService.ServiceState
-
-
Field Summary
-
Fields inherited from class com.linkedin.venice.service.AbstractVeniceService
logger, serviceState
-
-
Constructor Summary
Constructors Constructor Description BackupVersionOptimizationService(ReadOnlyStoreRepository storeRepository, StorageEngineRepository storageEngineRepository, long noReadThresholdMSForDatabaseOptimization, long scheduleIntervalSeconds, BackupVersionOptimizationServiceStats stats)
Allocate and initialize a newBackupVersionOptimizationService
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
recordReadUsage(java.lang.String resourceName)
boolean
startInner()
void
stopInner()
-
-
-
Constructor Detail
-
BackupVersionOptimizationService
public BackupVersionOptimizationService(ReadOnlyStoreRepository storeRepository, StorageEngineRepository storageEngineRepository, long noReadThresholdMSForDatabaseOptimization, long scheduleIntervalSeconds, BackupVersionOptimizationServiceStats stats)
Allocate and initialize a newBackupVersionOptimizationService
object.- Parameters:
storeRepository
- provides readonly operations to access stores.storageEngineRepository
- local storage engines for a server node.noReadThresholdMSForDatabaseOptimization
- controls the no read threshold for database optimization to kick in.scheduleIntervalSeconds
- sets the scheduling interval for this service.stats
- records the statistics for this service.
-
-
Method Detail
-
startInner
public boolean startInner() throws java.lang.Exception
- Specified by:
startInner
in classAbstractVeniceService
- Returns:
- true if the service is completely started,
false if it is still starting asynchronously (in this case, it is the implementer's
responsibility to set
AbstractVeniceService.serviceState
toAbstractVeniceService.ServiceState.STARTED
upon completion of the async work). - Throws:
java.lang.Exception
-
stopInner
public void stopInner() throws java.lang.Exception
- Specified by:
stopInner
in classAbstractVeniceService
- Throws:
java.lang.Exception
-
recordReadUsage
public void recordReadUsage(java.lang.String resourceName)
- Specified by:
recordReadUsage
in interfaceResourceReadUsageTracker
-
-