diff options
Diffstat (limited to 'weed/server/master_grpc_server_volume.go')
| -rw-r--r-- | weed/server/master_grpc_server_volume.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index 856c07890..156afd4a1 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -3,8 +3,8 @@ package weed_server import ( "context" "fmt" - "github.com/chrislusf/raft" + "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/security" @@ -61,11 +61,13 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest if err != nil { return nil, err } + diskType := types.ToDiskType(req.DiskType) option := &topology.VolumeGrowOption{ Collection: req.Collection, ReplicaPlacement: replicaPlacement, Ttl: ttl, + DiskType: diskType, Prealloacte: ms.preallocateSize, DataCenter: req.DataCenter, Rack: req.Rack, @@ -74,8 +76,8 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest } if !ms.Topo.HasWritableVolume(option) { - if ms.Topo.FreeSpace() <= 0 { - return nil, fmt.Errorf("No free volumes left!") + if ms.Topo.AvailableSpaceFor(option) <= 0 { + return nil, fmt.Errorf("no free volumes left for " + option.String()) } ms.vgLock.Lock() if !ms.Topo.HasWritableVolume(option) { @@ -118,9 +120,8 @@ func (ms *MasterServer) Statistics(ctx context.Context, req *master_pb.Statistic return nil, err } - volumeLayout := ms.Topo.GetVolumeLayout(req.Collection, replicaPlacement, ttl) + volumeLayout := ms.Topo.GetVolumeLayout(req.Collection, replicaPlacement, ttl, types.ToDiskType(req.DiskType)) stats := volumeLayout.Stats() - resp := &master_pb.StatisticsResponse{ TotalSize: stats.TotalSize, UsedSize: stats.UsedSize, @@ -177,12 +178,15 @@ func (ms *MasterServer) LookupEcVolume(ctx context.Context, req *master_pb.Looku return resp, nil } -func (ms *MasterServer) GetMasterConfiguration(ctx context.Context, req *master_pb.GetMasterConfigurationRequest) (*master_pb.GetMasterConfigurationResponse, error) { +func (ms *MasterServer) VacuumVolume(ctx context.Context, req *master_pb.VacuumVolumeRequest) (*master_pb.VacuumVolumeResponse, error) { - resp := &master_pb.GetMasterConfigurationResponse{ - MetricsAddress: ms.option.MetricsAddress, - MetricsIntervalSeconds: uint32(ms.option.MetricsIntervalSec), + if !ms.Topo.IsLeader() { + return nil, raft.NotLeaderError } + resp := &master_pb.VacuumVolumeResponse{} + + ms.Topo.Vacuum(ms.grpcDialOption, float64(req.GarbageThreshold), ms.preallocateSize) + return resp, nil } |
