Implement a VolumeEcStatus() RPC for volume servers. (#8006)
Just like `VolumeStatus()`, this call allows inspecting details for a given EC volume - including number of files and their total size.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/stats"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
@@ -128,11 +129,18 @@ func (shard *EcVolumeShard) Destroy() {
|
||||
}
|
||||
|
||||
func (shard *EcVolumeShard) ReadAt(buf []byte, offset int64) (int, error) {
|
||||
|
||||
n, err := shard.ecdFile.ReadAt(buf, offset)
|
||||
if err == io.EOF && n == len(buf) {
|
||||
err = nil
|
||||
}
|
||||
return n, err
|
||||
|
||||
}
|
||||
|
||||
func (shard *EcVolumeShard) ToEcShardInfo() *volume_server_pb.EcShardInfo {
|
||||
return &volume_server_pb.EcShardInfo{
|
||||
ShardId: uint32(shard.ShardId),
|
||||
Size: int64(shard.Size()),
|
||||
Collection: shard.Collection,
|
||||
VolumeId: uint32(shard.VolumeId),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,6 +333,13 @@ func (ev *EcVolume) IsTimeToDestroy() bool {
|
||||
return ev.ExpireAtSec > 0 && time.Now().Unix() > (int64(ev.ExpireAtSec)+destroyDelaySeconds)
|
||||
}
|
||||
|
||||
func (ev *EcVolume) WalkIndex(processNeedleFn func(key types.NeedleId, offset types.Offset, size types.Size) error) error {
|
||||
if ev.ecxFile == nil {
|
||||
return fmt.Errorf("no ECX file associated with EC volume %v", ev.VolumeId)
|
||||
}
|
||||
return idx.WalkIndexFile(ev.ecxFile, 0, processNeedleFn)
|
||||
}
|
||||
|
||||
func (ev *EcVolume) CheckIndex() (int64, []error) {
|
||||
if ev.ecxFile == nil {
|
||||
return 0, []error{fmt.Errorf("no ECX file associated with EC volume %v", ev.VolumeId)}
|
||||
|
||||
Reference in New Issue
Block a user