aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-11-23 00:24:51 -0800
committerChris Lu <chris.lu@gmail.com>2018-11-23 00:24:51 -0800
commit444dfded84696eb2d67876e228939ca3f9e7819f (patch)
tree6a026fca7ac363c7f76fab963603733208ed1f12 /weed/server
parent2e32b44061e10d599faf6180d3f5bcffb16a12bb (diff)
downloadseaweedfs-444dfded84696eb2d67876e228939ca3f9e7819f.tar.xz
seaweedfs-444dfded84696eb2d67876e228939ca3f9e7819f.zip
add fs.FSStatfser for SeaweedFS weed mount
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/filer_grpc_server.go25
-rw-r--r--weed/server/master_grpc_server_volume.go26
2 files changed, 49 insertions, 2 deletions
diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go
index 72d5b2e1d..3993bcf07 100644
--- a/weed/server/filer_grpc_server.go
+++ b/weed/server/filer_grpc_server.go
@@ -5,6 +5,8 @@ import (
"fmt"
"os"
"path/filepath"
+ "strconv"
+ "strings"
"time"
"github.com/chrislusf/seaweedfs/weed/filer2"
@@ -12,8 +14,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
- "strconv"
- "strings"
+ "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
)
func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {
@@ -233,3 +234,23 @@ func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.Delet
return &filer_pb.DeleteCollectionResponse{}, err
}
+
+func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsRequest) (resp *filer_pb.StatisticsResponse, err error) {
+
+ input := &master_pb.StatisticsRequest{
+ Replication: req.Replication,
+ Collection: req.Collection,
+ Ttl: req.Ttl,
+ }
+
+ output, err := operation.Statistics(fs.filer.GetMaster(), input)
+ if err != nil {
+ return nil, err
+ }
+
+ return &filer_pb.StatisticsResponse{
+ TotalSize: output.TotalSize,
+ UsedSize: output.UsedSize,
+ FileCount: output.FileCount,
+ }, nil
+}
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go
index 26dec1577..76d659009 100644
--- a/weed/server/master_grpc_server_volume.go
+++ b/weed/server/master_grpc_server_volume.go
@@ -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
+}