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