seaweedfs/weed/server/volume_grpc_vacuum.go
Chris Lu 6c9156b25f switch to logrus
losing filename and line number. Critical for debugging.
2020-11-16 22:26:58 -08:00

79 lines
2.1 KiB
Go

package weed_server
import (
"context"
"github.com/chrislusf/seaweedfs/weed/util/log"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
)
func (vs *VolumeServer) VacuumVolumeCheck(ctx context.Context, req *volume_server_pb.VacuumVolumeCheckRequest) (*volume_server_pb.VacuumVolumeCheckResponse, error) {
resp := &volume_server_pb.VacuumVolumeCheckResponse{}
garbageRatio, err := vs.store.CheckCompactVolume(needle.VolumeId(req.VolumeId))
resp.GarbageRatio = garbageRatio
if err != nil {
log.Tracef("check volume %d: %v", req.VolumeId, err)
}
return resp, err
}
func (vs *VolumeServer) VacuumVolumeCompact(ctx context.Context, req *volume_server_pb.VacuumVolumeCompactRequest) (*volume_server_pb.VacuumVolumeCompactResponse, error) {
resp := &volume_server_pb.VacuumVolumeCompactResponse{}
err := vs.store.CompactVolume(needle.VolumeId(req.VolumeId), req.Preallocate, vs.compactionBytePerSecond)
if err != nil {
log.Errorf("compact volume %d: %v", req.VolumeId, err)
} else {
log.Debugf("compact volume %d", req.VolumeId)
}
return resp, err
}
func (vs *VolumeServer) VacuumVolumeCommit(ctx context.Context, req *volume_server_pb.VacuumVolumeCommitRequest) (*volume_server_pb.VacuumVolumeCommitResponse, error) {
resp := &volume_server_pb.VacuumVolumeCommitResponse{}
err := vs.store.CommitCompactVolume(needle.VolumeId(req.VolumeId))
if err != nil {
log.Errorf("commit volume %d: %v", req.VolumeId, err)
} else {
log.Debugf("commit volume %d", req.VolumeId)
}
if err == nil {
if vs.store.GetVolume(needle.VolumeId(req.VolumeId)).IsReadOnly() {
resp.IsReadOnly = true
}
}
return resp, err
}
func (vs *VolumeServer) VacuumVolumeCleanup(ctx context.Context, req *volume_server_pb.VacuumVolumeCleanupRequest) (*volume_server_pb.VacuumVolumeCleanupResponse, error) {
resp := &volume_server_pb.VacuumVolumeCleanupResponse{}
err := vs.store.CommitCleanupVolume(needle.VolumeId(req.VolumeId))
if err != nil {
log.Errorf("cleanup volume %d: %v", req.VolumeId, err)
} else {
log.Debugf("cleanup volume %d", req.VolumeId)
}
return resp, err
}