You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
994 B

  1. package main
  2. import (
  3. "flag"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/storage"
  6. )
  7. var (
  8. volumePath = flag.String("dir", "/tmp", "data directory to store files")
  9. volumeCollection = flag.String("collection", "", "the volume collection name")
  10. volumeId = flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir. The volume index file should not exist.")
  11. )
  12. func main() {
  13. flag.Parse()
  14. var version storage.Version
  15. vid := storage.VolumeId(*volumeId)
  16. err := storage.ScanVolumeFile(*volumePath, *volumeCollection, vid,
  17. storage.NeedleMapInMemory,
  18. func(superBlock storage.SuperBlock) error {
  19. version = superBlock.Version()
  20. return nil
  21. }, false, func(n *storage.Needle, offset int64) error {
  22. glog.V(0).Infof("%d,%s%x offset %d size %d cookie %x",
  23. *volumeId, n.Id, n.Cookie, offset, n.Size, n.Cookie)
  24. return nil
  25. })
  26. if err != nil {
  27. glog.Fatalf("Reading Volume File [ERROR] %s\n", err)
  28. }
  29. }