mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring only
This commit is contained in:
parent
10c2a4540e
commit
5caa7bbdc9
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"pkg/storage"
|
||||
"pkg/topology"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
|
|||
func dirJoinHandler(w http.ResponseWriter, r *http.Request) {
|
||||
s := r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")+1] + r.FormValue("port")
|
||||
publicUrl := r.FormValue("publicUrl")
|
||||
volumes := new([]storage.VolumeInfo)
|
||||
volumes := new([]topology.VolumeInfo)
|
||||
json.Unmarshal([]byte(r.FormValue("volumes")), volumes)
|
||||
if *IsDebug {
|
||||
log.Println(s, "volumes", r.FormValue("volumes"))
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"pkg/storage"
|
||||
"pkg/topology"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ type MachineInfo struct {
|
|||
}
|
||||
type Machine struct {
|
||||
Server MachineInfo
|
||||
Volumes []storage.VolumeInfo
|
||||
Volumes []topology.VolumeInfo
|
||||
}
|
||||
|
||||
type Mapper struct {
|
||||
|
@ -41,7 +41,7 @@ type Mapper struct {
|
|||
volumeSizeLimit uint64
|
||||
}
|
||||
|
||||
func NewMachine(server, publicUrl string, volumes []storage.VolumeInfo) *Machine {
|
||||
func NewMachine(server, publicUrl string, volumes []topology.VolumeInfo) *Machine {
|
||||
return &Machine{Server: MachineInfo{Url: server, PublicUrl: publicUrl}, Volumes: volumes}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"pkg/topology"
|
||||
"pkg/util"
|
||||
)
|
||||
|
||||
|
@ -16,10 +17,6 @@ type Store struct {
|
|||
Port int
|
||||
PublicUrl string
|
||||
}
|
||||
type VolumeInfo struct {
|
||||
Id uint32
|
||||
Size int64
|
||||
}
|
||||
|
||||
func NewStore(port int, publicUrl, dirname string, volumeListString string) (s *Store) {
|
||||
s = &Store{Port: port, PublicUrl: publicUrl, dir: dirname}
|
||||
|
@ -63,19 +60,19 @@ func (s *Store) addVolume(vid uint64) error {
|
|||
s.volumes[vid] = NewVolume(s.dir, uint32(vid))
|
||||
return nil
|
||||
}
|
||||
func (s *Store) Status() *[]*VolumeInfo {
|
||||
stats := new([]*VolumeInfo)
|
||||
func (s *Store) Status() *[]*topology.VolumeInfo {
|
||||
stats := new([]*topology.VolumeInfo)
|
||||
for k, v := range s.volumes {
|
||||
s := new(VolumeInfo)
|
||||
s := new(topology.VolumeInfo)
|
||||
s.Id, s.Size = uint32(k), v.Size()
|
||||
*stats = append(*stats, s)
|
||||
}
|
||||
return stats
|
||||
}
|
||||
func (s *Store) Join(mserver string) {
|
||||
stats := new([]*VolumeInfo)
|
||||
stats := new([]*topology.VolumeInfo)
|
||||
for k, v := range s.volumes {
|
||||
s := new(VolumeInfo)
|
||||
s := new(topology.VolumeInfo)
|
||||
s.Id, s.Size = uint32(k), v.Size()
|
||||
*stats = append(*stats, s)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue