aboutsummaryrefslogtreecommitdiff
path: root/weed/server/volume_grpc_erasure_coding.go
diff options
context:
space:
mode:
authoraugustazz <102299780+augustazz@users.noreply.github.com>2024-08-16 15:20:00 +0800
committerGitHub <noreply@github.com>2024-08-16 00:20:00 -0700
commit0b00706454478abbb246af2f0d30d34c79b09b40 (patch)
treebe46e19b7a2afa26b8e2f388b456cee05e95bb2b /weed/server/volume_grpc_erasure_coding.go
parent8f1f1730e9925c2f9e5e01867f806dcaac3dde11 (diff)
downloadseaweedfs-0b00706454478abbb246af2f0d30d34c79b09b40.tar.xz
seaweedfs-0b00706454478abbb246af2f0d30d34c79b09b40.zip
EC volume supports expiration and displays expiration message when executing volume.list (#5895)
* ec volume expire * volume.list show DestroyTime * comments * code optimization --------- Co-authored-by: xuwenfeng <xuwenfeng1@zto.com>
Diffstat (limited to 'weed/server/volume_grpc_erasure_coding.go')
-rw-r--r--weed/server/volume_grpc_erasure_coding.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/weed/server/volume_grpc_erasure_coding.go b/weed/server/volume_grpc_erasure_coding.go
index 1590c4a84..e4346dffe 100644
--- a/weed/server/volume_grpc_erasure_coding.go
+++ b/weed/server/volume_grpc_erasure_coding.go
@@ -8,6 +8,7 @@ import (
"os"
"path"
"strings"
+ "time"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/operation"
@@ -71,11 +72,22 @@ func (vs *VolumeServer) VolumeEcShardsGenerate(ctx context.Context, req *volume_
}
// write .vif files
+ var destroyTime uint64
+ if v.Ttl != nil {
+ ttlMills := v.Ttl.ToSeconds()
+ if ttlMills > 0 {
+ destroyTime = uint64(time.Now().Unix()) + v.Ttl.ToSeconds() //calculated destroy time from the ec volume was created
+ }
+ }
+ volumeInfo := &volume_server_pb.VolumeInfo{Version: uint32(v.Version())}
+ if destroyTime == 0 {
+ glog.Warningf("gen ec volume,cal ec volume destory time fail,set time to 0,ttl:%v", v.Ttl)
+ } else {
+ volumeInfo.DestroyTime = destroyTime
+ }
datSize, _, _ := v.FileStat()
- if err := volume_info.SaveVolumeInfo(baseFileName+".vif", &volume_server_pb.VolumeInfo{
- Version: uint32(v.Version()),
- DatFileSize: int64(datSize),
- }); err != nil {
+ volumeInfo.DatFileSize = int64(datSize)
+ if err := volume_info.SaveVolumeInfo(baseFileName+".vif", volumeInfo); err != nil {
return nil, fmt.Errorf("SaveVolumeInfo %s: %v", baseFileName, err)
}
@@ -154,7 +166,6 @@ func (vs *VolumeServer) VolumeEcShardsCopy(ctx context.Context, req *volume_serv
if _, err := vs.doCopyFile(client, true, req.Collection, req.VolumeId, math.MaxUint32, math.MaxInt64, indexBaseFileName, ".ecx", false, false, nil); err != nil {
return err
}
- return nil
}
if req.CopyEcjFile {