aboutsummaryrefslogtreecommitdiff
path: root/go/weed/fix.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-11-12 02:21:22 -0800
committerChris Lu <chris.lu@gmail.com>2013-11-12 02:21:22 -0800
commit3b687111399fd08468e4a6232bcbe6068df961bf (patch)
treecde07f3ba6c9ae411d55b25c331bca6827253c30 /go/weed/fix.go
parent8f0e2f31afad1fcb2f06ef3ae55866313b7b4b02 (diff)
downloadseaweedfs-3b687111399fd08468e4a6232bcbe6068df961bf.tar.xz
seaweedfs-3b687111399fd08468e4a6232bcbe6068df961bf.zip
support for collections!
Diffstat (limited to 'go/weed/fix.go')
-rw-r--r--go/weed/fix.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/go/weed/fix.go b/go/weed/fix.go
index c97fd60d3..159e2dbde 100644
--- a/go/weed/fix.go
+++ b/go/weed/fix.go
@@ -22,8 +22,9 @@ var cmdFix = &Command{
}
var (
- fixVolumePath = cmdFix.Flag.String("dir", "/tmp", "data directory to store files")
- fixVolumeId = cmdFix.Flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.")
+ fixVolumePath = cmdFix.Flag.String("dir", "/tmp", "data directory to store files")
+ fixVolumeCollection = cmdFix.Flag.String("collection", "", "the volume collection name")
+ fixVolumeId = cmdFix.Flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.")
)
func runFix(cmd *Command, args []string) bool {
@@ -33,6 +34,9 @@ func runFix(cmd *Command, args []string) bool {
}
fileName := strconv.Itoa(*fixVolumeId)
+ if *fixVolumeCollection != "" {
+ fileName = *fixVolumeCollection + "_" + fileName
+ }
indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
@@ -43,7 +47,7 @@ func runFix(cmd *Command, args []string) bool {
defer nm.Close()
vid := storage.VolumeId(*fixVolumeId)
- err = storage.ScanVolumeFile(*fixVolumePath, vid, func(superBlock storage.SuperBlock) error {
+ err = storage.ScanVolumeFile(*fixVolumePath, *fixVolumeCollection, vid, func(superBlock storage.SuperBlock) error {
return nil
}, func(n *storage.Needle, offset int64) error {
debug("key", n.Id, "offset", offset, "size", n.Size, "disk_size", n.DiskSize(), "gzip", n.IsGzipped())