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:
Lisandro Pin
2026-02-09 20:52:08 +01:00
committed by GitHub
parent 818a1ff8b1
commit 1a5679a5eb
7 changed files with 104 additions and 29 deletions

View File

@@ -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),
}
}

View File

@@ -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)}