rename weedc option name to publicUrl

git-svn-id: https://weed-fs.googlecode.com/svn/trunk@27 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
chris.lu@gmail.com 2011-12-26 10:07:53 +00:00
parent c27f6175d7
commit 4c36190dd3
4 changed files with 11 additions and 11 deletions

View file

@ -17,8 +17,8 @@ var (
port = flag.Int("port", 8080, "http listen port") port = flag.Int("port", 8080, "http listen port")
chunkFolder = flag.String("dir", "/tmp", "data directory to store files") chunkFolder = flag.String("dir", "/tmp", "data directory to store files")
volumes = flag.String("volumes", "0,1-3,4", "comma-separated list of volume ids or range of ids") volumes = flag.String("volumes", "0,1-3,4", "comma-separated list of volume ids or range of ids")
publicServer = flag.String("pserver", "localhost:8080", "public server to serve data read") publicUrl = flag.String("publicUrl", "localhost:8080", "public url to serve data read")
metaServer = flag.String("mserver", "localhost:9333", "metadata server to store mappings") metaServer = flag.String("mserver", "localhost:9333", "master directory server to store mappings")
IsDebug = flag.Bool("debug", false, "enable debug mode") IsDebug = flag.Bool("debug", false, "enable debug mode")
pulse = flag.Int("pulseSeconds", 5, "number of seconds between heartbeats") pulse = flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
@ -128,7 +128,7 @@ func parseURLPath(path string) (vid, fid, ext string) {
func main() { func main() {
flag.Parse() flag.Parse()
//TODO: now default to 1G, this value should come from server? //TODO: now default to 1G, this value should come from server?
store = storage.NewStore(*port, *publicServer, *chunkFolder, *volumes) store = storage.NewStore(*port, *publicUrl, *chunkFolder, *volumes)
defer store.Close() defer store.Close()
http.HandleFunc("/", storeHandler) http.HandleFunc("/", storeHandler)
http.HandleFunc("/status", statusHandler) http.HandleFunc("/status", statusHandler)

View file

@ -40,11 +40,11 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
} }
func dirJoinHandler(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") s := r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")+1] + r.FormValue("port")
publicServer := r.FormValue("publicServer") publicUrl := r.FormValue("publicUrl")
volumes := new([]storage.VolumeInfo) volumes := new([]storage.VolumeInfo)
json.Unmarshal([]byte(r.FormValue("volumes")), volumes) json.Unmarshal([]byte(r.FormValue("volumes")), volumes)
log.Println("Recieved updates from", s, "volumes", r.FormValue("volumes")) log.Println("Recieved updates from", s, "volumes", r.FormValue("volumes"))
mapper.Add(*directory.NewMachine(s, publicServer, *volumes)) mapper.Add(*directory.NewMachine(s, publicUrl, *volumes))
} }
func dirStatusHandler(w http.ResponseWriter, r *http.Request) { func dirStatusHandler(w http.ResponseWriter, r *http.Request) {
writeJson(w, r, mapper) writeJson(w, r, mapper)

View file

@ -37,8 +37,8 @@ type Mapper struct {
fileIdCounter uint64 fileIdCounter uint64
} }
func NewMachine(server, publicServer string, volumes []storage.VolumeInfo) *Machine { func NewMachine(server, publicUrl string, volumes []storage.VolumeInfo) *Machine {
return &Machine{Server: MachineInfo{Url: server, PublicUrl: publicServer}, Volumes: volumes} return &Machine{Server: MachineInfo{Url: server, PublicUrl: publicUrl}, Volumes: volumes}
} }
func NewMapper(dirname string, filename string) (m *Mapper) { func NewMapper(dirname string, filename string) (m *Mapper) {

View file

@ -14,15 +14,15 @@ type Store struct {
volumes map[uint64]*Volume volumes map[uint64]*Volume
dir string dir string
Port int Port int
PublicServer string PublicUrl string
} }
type VolumeInfo struct { type VolumeInfo struct {
Id uint32 Id uint32
Size int64 Size int64
} }
func NewStore(port int, publicServer, dirname string, volumeListString string) (s *Store) { func NewStore(port int, publicUrl, dirname string, volumeListString string) (s *Store) {
s = &Store{Port: port, PublicServer: publicServer, dir: dirname} s = &Store{Port: port, PublicUrl: publicUrl, dir: dirname}
s.volumes = make(map[uint64]*Volume) s.volumes = make(map[uint64]*Volume)
for _, range_string := range strings.Split(volumeListString, ",") { for _, range_string := range strings.Split(volumeListString, ",") {
@ -74,7 +74,7 @@ func (s *Store) Join(mserver string) {
bytes, _ := json.Marshal(stats) bytes, _ := json.Marshal(stats)
values := make(url.Values) values := make(url.Values)
values.Add("port", strconv.Itoa(s.Port)) values.Add("port", strconv.Itoa(s.Port))
values.Add("publicServer", s.PublicServer) values.Add("publicUrl", s.PublicUrl)
values.Add("volumes", string(bytes)) values.Add("volumes", string(bytes))
log.Println("Exiting volumes", string(bytes)) log.Println("Exiting volumes", string(bytes))
util.Post("http://"+mserver+"/dir/join", values) util.Post("http://"+mserver+"/dir/join", values)