ui add ec shard statuses

This commit is contained in:
Chris Lu
2019-06-04 21:52:37 -07:00
parent 0e52862586
commit 2215e81be7
8 changed files with 81 additions and 0 deletions

View File

@@ -39,6 +39,10 @@ func NewEcVolumeShard(dirname string, collection string, id needle.VolumeId, sha
return
}
func (shard *EcVolumeShard) Size() int64 {
return shard.ecdFileSize
}
func (shard *EcVolumeShard) String() string {
return fmt.Sprintf("ec shard %v:%v, dir:%s, Collection:%s", shard.VolumeId, shard.ShardId, shard.dir, shard.Collection)
}

View File

@@ -20,6 +20,7 @@ type EcVolume struct {
dir string
ecxFile *os.File
ecxFileSize int64
ecxCreatedAt time.Time
Shards []*EcVolumeShard
ShardLocations map[ShardId][]string
ShardLocationsRefreshTime time.Time
@@ -41,6 +42,7 @@ func NewEcVolume(dir string, collection string, vid needle.VolumeId) (ev *EcVolu
return nil, fmt.Errorf("can not stat ec volume index %s.ecx: %v", baseFileName, statErr)
}
ev.ecxFileSize = ecxFi.Size()
ev.ecxCreatedAt = ecxFi.ModTime()
ev.ShardLocations = make(map[ShardId][]string)
@@ -113,6 +115,24 @@ func (ev *EcVolume) FileName() string {
}
func (ev *EcVolume) ShardSize() int64 {
if len(ev.Shards) > 0 {
return ev.Shards[0].Size()
}
return 0
}
func (ev *EcVolume) CreatedAt() time.Time {
return ev.ecxCreatedAt
}
func (ev *EcVolume) ShardIdList() (shardIds []ShardId) {
for _, s := range ev.Shards {
shardIds = append(shardIds, s.ShardId)
}
return
}
func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.VolumeEcShardInformationMessage) {
prevVolumeId := needle.VolumeId(math.MaxUint32)
var m *master_pb.VolumeEcShardInformationMessage

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"sort"
"sync"
"time"
@@ -365,3 +366,17 @@ func (s *Store) recoverOneRemoteEcShardInterval(ctx context.Context, ecVolume *e
return len(buf), nil
}
func (s *Store) EcVolumes() (ecVolumes []*erasure_coding.EcVolume) {
for _, location := range s.Locations {
location.ecVolumesLock.RLock()
for _, v := range location.ecVolumes {
ecVolumes = append(ecVolumes, v)
}
location.ecVolumesLock.RUnlock()
}
sort.Slice(ecVolumes, func(i, j int) bool {
return ecVolumes[i].VolumeId > ecVolumes[j].VolumeId
})
return ecVolumes
}