コード例 #1
0
ファイル: backup.go プロジェクト: GodUseVPN/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
}
コード例 #2
0
func (ms *MasterServer) getVolumeGrowOption(r *http.Request) (*topology.VolumeGrowOption, error) {
	replicationString := r.FormValue("replication")
	if replicationString == "" {
		replicationString = ms.defaultReplicaPlacement
	}
	replicaPlacement, err := storage.NewReplicaPlacementFromString(replicationString)
	if err != nil {
		return nil, err
	}
	ttl, err := storage.ReadTTL(r.FormValue("ttl"))
	if err != nil {
		return nil, err
	}
	volumeGrowOption := &topology.VolumeGrowOption{
		Collection:       r.FormValue("collection"),
		ReplicaPlacement: replicaPlacement,
		Ttl:              ttl,
		DataCenter:       r.FormValue("dataCenter"),
		Rack:             r.FormValue("rack"),
		DataNode:         r.FormValue("dataNode"),
	}
	return volumeGrowOption, nil
}