@ -37,17 +37,19 @@ import (
)
const (
dataUsageObjName = ".usage.json"
dataUsageCacheName = ".usage-cache.bin"
envDataUsageCrawlConf = "MINIO_DISK_USAGE_CRAWL_ENABLE"
envDataUsageCrawlDelay = "MINIO_DISK_USAGE_CRAWL_DELAY"
envDataUsageCrawlDebug = "MINIO_DISK_USAGE_CRAWL_DEBUG"
dataUsageSleepPerFolder = 1 * time . Millisecond
dataUsageSleepDefMult = 10.0
dataUsageUpdateDirCycles = 16
dataUsageRoot = SlashSeparator
dataUsageBucket = minioMetaBucket + SlashSeparator + bucketMetaPrefix
dataUsageObjName = ".usage.json"
dataUsageCacheName = ".usage-cache.bin"
dataUsageBloomName = ".bloomcycle.bin"
dataUsageSleepPerFolder = 1 * time . Millisecond
dataUsageSleepDefMult = 10.0
dataUsageUpdateDirCycles = 16
dataUsageStartDelay = 5 * time . Minute // Time to wait on startup and between cycles.
)
@ -104,11 +106,13 @@ func runDataUsageInfo(ctx context.Context, objAPI ObjectLayer) {
}
_ , err = objAPI . PutObject ( ctx , dataUsageBucket , dataUsageBloomName , NewPutObjReader ( r , nil , nil ) , ObjectOptions { } )
if ! isErrBucketNotFound ( err ) {
logger . LogIf ( ctx , err )
}
}
}
}
}
// storeDataUsageInBackend will store all objects sent on the gui channel until closed.
func storeDataUsageInBackend ( ctx context . Context , objAPI ObjectLayer , gui <- chan DataUsageInfo ) {
@ -126,16 +130,18 @@ func storeDataUsageInBackend(ctx context.Context, objAPI ObjectLayer, gui <-chan
}
_ , err = objAPI . PutObject ( ctx , dataUsageBucket , dataUsageObjName , NewPutObjReader ( r , nil , nil ) , ObjectOptions { } )
if ! isErrBucketNotFound ( err ) {
logger . LogIf ( ctx , err )
}
}
}
func loadDataUsageFromBackend ( ctx context . Context , objAPI ObjectLayer ) ( DataUsageInfo , error ) {
var dataUsageInfoJSON bytes . Buffer
err := objAPI . GetObject ( ctx , dataUsageBucket , dataUsageObjName , 0 , - 1 , & dataUsageInfoJSON , "" , ObjectOptions { } )
if err != nil {
if isErrObjectNotFound ( err ) {
if isErrObjectNotFound ( err ) || isErrBucketNotFound ( err ) {
return DataUsageInfo { } , nil
}
return DataUsageInfo { } , toObjectErr ( err , dataUsageBucket , dataUsageObjName )