mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 09:17:56 +08:00
add fs.FSStatfser for SeaweedFS weed mount
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage"
|
||||
@@ -22,6 +23,12 @@ type VolumeLayout struct {
|
||||
accessLock sync.RWMutex
|
||||
}
|
||||
|
||||
type VolumeLayoutStats struct {
|
||||
TotalSize uint64
|
||||
UsedSize uint64
|
||||
FileCount uint64
|
||||
}
|
||||
|
||||
func NewVolumeLayout(rp *storage.ReplicaPlacement, ttl *storage.TTL, volumeSizeLimit uint64) *VolumeLayout {
|
||||
return &VolumeLayout{
|
||||
rp: rp,
|
||||
@@ -265,3 +272,25 @@ func (vl *VolumeLayout) ToMap() map[string]interface{} {
|
||||
//m["locations"] = vl.vid2location
|
||||
return m
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) Stats() *VolumeLayoutStats {
|
||||
vl.accessLock.RLock()
|
||||
defer vl.accessLock.RUnlock()
|
||||
|
||||
ret := &VolumeLayoutStats{}
|
||||
|
||||
freshThreshold := time.Now().Unix() - 60
|
||||
|
||||
for vid, vll := range vl.vid2location {
|
||||
size, fileCount := vll.Stats(vid, freshThreshold)
|
||||
ret.FileCount += uint64(fileCount)
|
||||
ret.UsedSize += size
|
||||
if vl.readonlyVolumes[vid] {
|
||||
ret.TotalSize += size
|
||||
} else {
|
||||
ret.TotalSize += vl.volumeSizeLimit
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
Reference in New Issue
Block a user