func runBackup(cmd *Command, args []string) bool { if *s.volumeId == -1 { return false } vid := storage.VolumeId(*s.volumeId) // find volume location, replication, ttl info lookup, err := operation.Lookup(*s.master, vid.String()) if err != nil { fmt.Printf("Error looking up volume %d: %v\n", vid, err) return true } volumeServer := lookup.Locations[0].Url stats, err := operation.GetVolumeSyncStatus(volumeServer, vid.String()) if err != nil { fmt.Printf("Error get volume %d status: %v\n", vid, err) return true } ttl, err := storage.ReadTTL(stats.Ttl) if err != nil { fmt.Printf("Error get volume %d ttl %s: %v\n", vid, stats.Ttl, err) return true } replication, err := storage.NewReplicaPlacementFromString(stats.Replication) if err != nil { fmt.Printf("Error get volume %d replication %s : %v\n", vid, stats.Replication, err) return true } v, err := storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl) if err != nil { fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err) return true } if err := v.Synchronize(volumeServer); err != nil { fmt.Printf("Error synchronizing volume %d: %v\n", vid, err) return true } return true }
func fetchVolumeFileEntries(volumeServer string, vid VolumeId) (m CompactMap, lastOffset uint64, compactRevision uint16, err error) { m = NewCompactMap() syncStatus, err := operation.GetVolumeSyncStatus(volumeServer, vid.String()) if err != nil { return m, 0, 0, err } total := 0 err = operation.GetVolumeIdxEntries(volumeServer, vid.String(), func(key uint64, offset, size uint32) { // println("remote key", key, "offset", offset*NeedlePaddingSize, "size", size) if offset != 0 && size != 0 { m.Set(Key(key), offset, size) } else { m.Delete(Key(key)) } total++ }) glog.V(2).Infof("server %s volume %d, entries %d, last offset %d, revision %d", volumeServer, vid, total, syncStatus.TailOffset, syncStatus.CompactRevision) return m, syncStatus.TailOffset, syncStatus.CompactRevision, err }