mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add tool to change replication or ttl
fix https://github.com/chrislusf/seaweedfs/issues/386
This commit is contained in:
parent
05eda424fc
commit
df49692dff
|
@ -16,6 +16,7 @@ var (
|
||||||
fixVolumeCollection = flag.String("collection", "", "the volume collection name")
|
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.")
|
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.")
|
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,20 +59,37 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Current Volume Replication: %s\n", superBlock.ReplicaPlacement)
|
fmt.Printf("Current Volume Replication: %s\n", superBlock.ReplicaPlacement)
|
||||||
|
fmt.Printf("Current Volume TTL: %s\n", superBlock.Ttl.String())
|
||||||
|
|
||||||
if *targetReplica == "" {
|
hasChange := false
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if *targetReplica != "" {
|
||||||
replica, err := storage.NewReplicaPlacementFromString(*targetReplica)
|
replica, err := storage.NewReplicaPlacementFromString(*targetReplica)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("cannot parse target replica %s: %v", *targetReplica, err)
|
glog.Fatalf("cannot parse target replica %s: %v", *targetReplica, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Changing to: %s\n", replica)
|
fmt.Printf("Changing replication to: %s\n", replica)
|
||||||
|
|
||||||
superBlock.ReplicaPlacement = replica
|
superBlock.ReplicaPlacement = replica
|
||||||
|
hasChange = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if *targetTTL != "" {
|
||||||
|
ttl, err := storage.ReadTTL(*targetTTL)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("cannot parse target ttl %s: %v", *targetTTL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Changing ttl to: %s\n", ttl)
|
||||||
|
|
||||||
|
superBlock.Ttl = ttl
|
||||||
|
hasChange = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasChange {
|
||||||
|
|
||||||
header = superBlock.Bytes()
|
header = superBlock.Bytes()
|
||||||
|
|
||||||
|
@ -79,6 +97,7 @@ func main() {
|
||||||
glog.Fatalf("cannot write super block: %v", e)
|
glog.Fatalf("cannot write super block: %v", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Done.")
|
fmt.Println("Change Applied.")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue