diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2019-01-16 17:48:59 +0800 |
|---|---|---|
| committer | bingoohuang <bingoo.huang@gmail.com> | 2019-01-16 17:48:59 +0800 |
| commit | 6ddfaf33cba953b92a5e3383a15bf26ab1845dbc (patch) | |
| tree | 5e98a7f62939582459b52c0ff02b956bddbd9587 /unmaintained | |
| parent | 27093bc2e5cf3d61149e5eda14b98b1e527e5a28 (diff) | |
| download | seaweedfs-6ddfaf33cba953b92a5e3383a15bf26ab1845dbc.tar.xz seaweedfs-6ddfaf33cba953b92a5e3383a15bf26ab1845dbc.zip | |
extract VolumeFileScanner for ScanVolumeFile
Diffstat (limited to 'unmaintained')
| -rw-r--r-- | unmaintained/fix_dat/fix_dat.go | 4 | ||||
| -rw-r--r-- | unmaintained/see_dat/see_dat.go | 32 |
2 files changed, 23 insertions, 13 deletions
diff --git a/unmaintained/fix_dat/fix_dat.go b/unmaintained/fix_dat/fix_dat.go index 90287ecd6..b26c85de6 100644 --- a/unmaintained/fix_dat/fix_dat.go +++ b/unmaintained/fix_dat/fix_dat.go @@ -10,8 +10,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage" - "github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/util" ) var ( @@ -63,7 +63,7 @@ func main() { iterateEntries(datFile, indexFile, func(n *storage.Needle, offset int64) { fmt.Printf("needle id=%v name=%s size=%d dataSize=%d\n", n.Id, string(n.Name), n.Size, n.DataSize) - s, _, e := n.Append(newDatFile, superBlock.Version()) + _, s, _, e := n.Append(newDatFile, superBlock.Version()) fmt.Printf("size %d error %v\n", s, e) }) diff --git a/unmaintained/see_dat/see_dat.go b/unmaintained/see_dat/see_dat.go index ce31c1d20..f79c0a6a9 100644 --- a/unmaintained/see_dat/see_dat.go +++ b/unmaintained/see_dat/see_dat.go @@ -12,21 +12,31 @@ var ( volumeId = flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.") ) +type VolumeFileScanner4SeeDat struct { + version storage.Version +} + +func (scanner *VolumeFileScanner4SeeDat) VisitSuperBlock(superBlock storage.SuperBlock) error { + scanner.version = superBlock.Version() + return nil + +} +func (scanner *VolumeFileScanner4SeeDat) ReadNeedleBody() bool { + return false +} + +func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *storage.Needle, offset int64) error { + glog.V(0).Infof("%d,%s%x offset %d size %d cookie %x", *volumeId, n.Id, n.Cookie, offset, n.Size, n.Cookie) + return nil +} + func main() { flag.Parse() - var version storage.Version vid := storage.VolumeId(*volumeId) - err := storage.ScanVolumeFile(*volumePath, *volumeCollection, vid, - storage.NeedleMapInMemory, - func(superBlock storage.SuperBlock) error { - version = superBlock.Version() - return nil - }, false, func(n *storage.Needle, offset int64) error { - glog.V(0).Infof("%d,%s%x offset %d size %d cookie %x", - *volumeId, n.Id, n.Cookie, offset, n.Size, n.Cookie) - return nil - }) + + scanner := &VolumeFileScanner4SeeDat{} + err := storage.ScanVolumeFile(*volumePath, *volumeCollection, vid, storage.NeedleMapInMemory, scanner) if err != nil { glog.Fatalf("Reading Volume File [ERROR] %s\n", err) } |
