예제 #1
0
func runCompact(cmd *Command, args []string) bool {

	if *compactVolumeId == -1 {
		return false
	}

	vid := storage.VolumeId(*compactVolumeId)
	v, err := storage.NewVolume(*compactVolumePath, *compactVolumeCollection, vid,
		storage.NeedleMapInMemory, nil, nil)
	if err != nil {
		glog.Fatalf("Load Volume [ERROR] %s\n", err)
	}
	if err = v.Compact(); err != nil {
		glog.Fatalf("Compact Volume [ERROR] %s\n", err)
	}

	return true
}
예제 #2
0
파일: backup.go 프로젝트: netroby/seaweedfs
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
}