diff options
Diffstat (limited to 'weed/storage/erasure_coding/ec_volume.go')
| -rw-r--r-- | weed/storage/erasure_coding/ec_volume.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/weed/storage/erasure_coding/ec_volume.go b/weed/storage/erasure_coding/ec_volume.go index ea869c475..ac25d1112 100644 --- a/weed/storage/erasure_coding/ec_volume.go +++ b/weed/storage/erasure_coding/ec_volume.go @@ -3,6 +3,7 @@ package erasure_coding import ( "errors" "fmt" + "github.com/seaweedfs/seaweedfs/weed/glog" "math" "os" "sync" @@ -20,7 +21,8 @@ import ( ) var ( - NotFoundError = errors.New("needle not found") + NotFoundError = errors.New("needle not found") + destroyDelaySeconds int64 = 0 ) type EcVolume struct { @@ -40,6 +42,7 @@ type EcVolume struct { ecjFileAccessLock sync.Mutex diskType types.DiskType datFileSize int64 + DestroyTime uint64 //ec volume destroy time, calculated from the ec volume was created } func NewEcVolume(diskType types.DiskType, dir string, dirIdx string, collection string, vid needle.VolumeId) (ev *EcVolume, err error) { @@ -70,7 +73,9 @@ func NewEcVolume(diskType types.DiskType, dir string, dirIdx string, collection if volumeInfo, _, found, _ := volume_info.MaybeLoadVolumeInfo(dataBaseFileName + ".vif"); found { ev.Version = needle.Version(volumeInfo.Version) ev.datFileSize = volumeInfo.DatFileSize + ev.DestroyTime = volumeInfo.DestroyTime } else { + glog.Warningf("vif file not found,volumeId:%d, filename:%s", vid, dataBaseFileName) volume_info.SaveVolumeInfo(dataBaseFileName+".vif", &volume_server_pb.VolumeInfo{Version: uint32(ev.Version)}) } @@ -198,9 +203,10 @@ func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.V for _, s := range ev.Shards { if s.VolumeId != prevVolumeId { m = &master_pb.VolumeEcShardInformationMessage{ - Id: uint32(s.VolumeId), - Collection: s.Collection, - DiskType: string(ev.diskType), + Id: uint32(s.VolumeId), + Collection: s.Collection, + DiskType: string(ev.diskType), + DestroyTime: ev.DestroyTime, } messages = append(messages, m) } @@ -269,3 +275,7 @@ func SearchNeedleFromSortedIndex(ecxFile *os.File, ecxFileSize int64, needleId t err = NotFoundError return } + +func (ev *EcVolume) IsTimeToDestroy() bool { + return ev.DestroyTime > 0 && time.Now().Unix() > (int64(ev.DestroyTime)+destroyDelaySeconds) +} |
