add fs.FSStatfser for SeaweedFS weed mount

This commit is contained in:
Chris Lu
2018-11-23 00:24:51 -08:00
parent 2e32b44061
commit 444dfded84
10 changed files with 584 additions and 139 deletions

View File

@@ -84,3 +84,29 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
Count: count,
}, nil
}
func (ms *MasterServer) Statistics(ctx context.Context, req *master_pb.StatisticsRequest) (*master_pb.StatisticsResponse, error) {
if req.Replication == "" {
req.Replication = ms.defaultReplicaPlacement
}
replicaPlacement, err := storage.NewReplicaPlacementFromString(req.Replication)
if err != nil {
return nil, err
}
ttl, err := storage.ReadTTL(req.Ttl)
if err != nil {
return nil, err
}
volumeLayout := ms.Topo.GetVolumeLayout(req.Collection, replicaPlacement, ttl)
stats := volumeLayout.Stats()
resp := &master_pb.StatisticsResponse{
TotalSize: stats.TotalSize,
UsedSize: stats.UsedSize,
FileCount: stats.FileCount,
}
return resp, nil
}