Class DfsBlockCacheConfig
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheConfig
-
public class DfsBlockCacheConfig extends Object
Configuration parameters forDfsBlockCache
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DfsBlockCacheConfig.IndexEventConsumer
Consumer of DfsBlockCache loading and eviction events for indexes.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CACHE_HOT_MAX
Default number of max cache hits.static int
KB
1024 (number of bytes in one kibibyte/kilobyte)static int
MB
1024KB
(number of bytes in one mebibyte/megabyte)
-
Constructor Summary
Constructors Constructor Description DfsBlockCacheConfig()
Create a default configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DfsBlockCacheConfig
fromConfig(Config rc)
Update properties by setting fields from the configuration.long
getBlockLimit()
Get maximum number bytes of heap memory to dedicate to caching pack file data.int
getBlockSize()
Get size in bytes of a single window mapped or read in from the pack file.Map<PackExt,Integer>
getCacheHotMap()
Get the map of hot count per pack extension forDfsBlockCache
.int
getConcurrencyLevel()
Get the estimated number of threads concurrently accessing the cache.DfsBlockCacheConfig.IndexEventConsumer
getIndexEventConsumer()
Get the consumer of cache index events.Consumer<Long>
getRefLockWaitTimeConsumer()
Get the consumer of the object reference lock wait time in milliseconds.double
getStreamRatio()
Get highest percentage ofgetBlockLimit()
a single pack can occupy while being copied by the pack reuse strategy.DfsBlockCacheConfig
setBlockLimit(long newLimit)
Set maximum number bytes of heap memory to dedicate to caching pack file data.DfsBlockCacheConfig
setBlockSize(int newSize)
Set size in bytes of a single window read in from the pack file.DfsBlockCacheConfig
setCacheHotMap(Map<PackExt,Integer> cacheHotMap)
Set the map of hot count per pack extension forDfsBlockCache
.DfsBlockCacheConfig
setConcurrencyLevel(int newConcurrencyLevel)
Set the estimated number of threads concurrently accessing the cache.DfsBlockCacheConfig
setIndexEventConsumer(DfsBlockCacheConfig.IndexEventConsumer indexEventConsumer)
Set the consumer of cache index events.DfsBlockCacheConfig
setRefLockWaitTimeConsumer(Consumer<Long> c)
Set the consumer for lock wait time.DfsBlockCacheConfig
setStreamRatio(double ratio)
Set percentage of cache to occupy with a copied pack.
-
-
-
Field Detail
-
KB
public static final int KB
1024 (number of bytes in one kibibyte/kilobyte)- See Also:
- Constant Field Values
-
MB
public static final int MB
1024KB
(number of bytes in one mebibyte/megabyte)- See Also:
- Constant Field Values
-
DEFAULT_CACHE_HOT_MAX
public static final int DEFAULT_CACHE_HOT_MAX
Default number of max cache hits.- See Also:
- Constant Field Values
-
-
Method Detail
-
getBlockLimit
public long getBlockLimit()
Get maximum number bytes of heap memory to dedicate to caching pack file data.- Returns:
- maximum number bytes of heap memory to dedicate to caching pack file data. Default is 32 MB.
-
setBlockLimit
public DfsBlockCacheConfig setBlockLimit(long newLimit)
Set maximum number bytes of heap memory to dedicate to caching pack file data.It is strongly recommended to set the block limit to be an integer multiple of the block size. This constraint is not enforced by this method (since it may be called before
setBlockSize(int)
), but it is enforced byfromConfig(Config)
.- Parameters:
newLimit
- maximum number bytes of heap memory to dedicate to caching pack file data; must be positive.- Returns:
this
-
getBlockSize
public int getBlockSize()
Get size in bytes of a single window mapped or read in from the pack file.- Returns:
- size in bytes of a single window mapped or read in from the pack file. Default is 64 KB.
-
setBlockSize
public DfsBlockCacheConfig setBlockSize(int newSize)
Set size in bytes of a single window read in from the pack file.- Parameters:
newSize
- size in bytes of a single window read in from the pack file. The value must be a power of 2.- Returns:
this
-
getConcurrencyLevel
public int getConcurrencyLevel()
Get the estimated number of threads concurrently accessing the cache.- Returns:
- the estimated number of threads concurrently accessing the cache. Default is 32.
-
setConcurrencyLevel
public DfsBlockCacheConfig setConcurrencyLevel(int newConcurrencyLevel)
Set the estimated number of threads concurrently accessing the cache.- Parameters:
newConcurrencyLevel
- the estimated number of threads concurrently accessing the cache.- Returns:
this
-
getStreamRatio
public double getStreamRatio()
Get highest percentage ofgetBlockLimit()
a single pack can occupy while being copied by the pack reuse strategy.- Returns:
- highest percentage of
getBlockLimit()
a single pack can occupy while being copied by the pack reuse strategy. Default is 0.30, or 30%.
-
setStreamRatio
public DfsBlockCacheConfig setStreamRatio(double ratio)
Set percentage of cache to occupy with a copied pack.- Parameters:
ratio
- percentage of cache to occupy with a copied pack.- Returns:
this
-
getRefLockWaitTimeConsumer
public Consumer<Long> getRefLockWaitTimeConsumer()
Get the consumer of the object reference lock wait time in milliseconds.- Returns:
- consumer of wait time in milliseconds.
-
setRefLockWaitTimeConsumer
public DfsBlockCacheConfig setRefLockWaitTimeConsumer(Consumer<Long> c)
Set the consumer for lock wait time.- Parameters:
c
- consumer of wait time in milliseconds.- Returns:
this
-
getCacheHotMap
public Map<PackExt,Integer> getCacheHotMap()
Get the map of hot count per pack extension forDfsBlockCache
.- Returns:
- map of hot count per pack extension for
DfsBlockCache
.
-
setCacheHotMap
public DfsBlockCacheConfig setCacheHotMap(Map<PackExt,Integer> cacheHotMap)
Set the map of hot count per pack extension forDfsBlockCache
.- Parameters:
cacheHotMap
- map of hot count per pack extension forDfsBlockCache
.- Returns:
this
-
getIndexEventConsumer
public DfsBlockCacheConfig.IndexEventConsumer getIndexEventConsumer()
Get the consumer of cache index events.- Returns:
- consumer of cache index events.
-
setIndexEventConsumer
public DfsBlockCacheConfig setIndexEventConsumer(DfsBlockCacheConfig.IndexEventConsumer indexEventConsumer)
Set the consumer of cache index events.- Parameters:
indexEventConsumer
- consumer of cache index events.- Returns:
this
-
fromConfig
public DfsBlockCacheConfig fromConfig(Config rc)
Update properties by setting fields from the configuration.If a property is not defined in the configuration, then it is left unmodified.
Enforces certain constraints on the combination of settings in the config, for example that the block limit is a multiple of the block size.
- Parameters:
rc
- configuration to read properties from.- Returns:
this
-
-