SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
add tool to change replication or ttl
Chris Ludf49692dff75
diff --git a/unmaintained/change_replication/change_replication.go b/unmaintained/change_superblock/change_superblock.gosimilarity index 67%rename from unmaintained/change_replication/change_replication.gorename to unmaintained/change_superblock/change_superblock.goindex c32d2d266c..6ecead697f 100644--- a/unmaintained/change_replication/change_replication.go+++ b/unmaintained/change_superblock/change_superblock.go@@ -16,6 +16,7 @@ var (fixVolumeCollection = flag.String("collection", "", "the volume collection name")fixVolumeId = flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.")targetReplica = flag.String("replication", "", "If just empty, only print out current replication setting.")+ targetTTL = flag.String("ttl", "", "If just empty, only print out current ttl setting."))/*@@ -58,27 +59,45 @@ func main() {}fmt.Printf("Current Volume Replication: %s\n", superBlock.ReplicaPlacement)+ fmt.Printf("Current Volume TTL: %s\n", superBlock.Ttl.String())- if *targetReplica == "" {- return- }+ hasChange := false- replica, err := storage.NewReplicaPlacementFromString(*targetReplica)+ if *targetReplica != "" {+ replica, err := storage.NewReplicaPlacementFromString(*targetReplica)- if err != nil {- glog.Fatalf("cannot parse target replica %s: %v", *targetReplica, err)+ if err != nil {+ glog.Fatalf("cannot parse target replica %s: %v", *targetReplica, err)+ }++ fmt.Printf("Changing replication to: %s\n", replica)++ superBlock.ReplicaPlacement = replica+ hasChange = true}- fmt.Printf("Changing to: %s\n", replica)+ if *targetTTL != "" {+ ttl, err := storage.ReadTTL(*targetTTL)- superBlock.ReplicaPlacement = replica+ if err != nil {+ glog.Fatalf("cannot parse target ttl %s: %v", *targetTTL, err)+ }- header = superBlock.Bytes()+ fmt.Printf("Changing ttl to: %s\n", ttl)- if n, e := datFile.WriteAt(header, 0); n == 0 || e != nil {- glog.Fatalf("cannot write super block: %v", e)+ superBlock.Ttl = ttl+ hasChange = true}- fmt.Println("Done.")+ if hasChange {++ header = superBlock.Bytes()++ if n, e := datFile.WriteAt(header, 0); n == 0 || e != nil {+ glog.Fatalf("cannot write super block: %v", e)+ }++ fmt.Println("Change Applied.")+ }}