Using Url instead of PublicUrl for volume server

Originally there are only url(ip + port), and publicUrl. Because ip was
used to listen for http service, it has less flexibility and volume
server has to be accessed via publicUrl.

Recently we added ip.bind, for binding http service.

With this change, url can be used to connect to volume servers. And
publicUrl becomes a free style piece of url information, it does not
even need to be unique.
This commit is contained in:
chrislusf
2015-02-02 10:16:50 -08:00
parent 29a325626f
commit cc724305b6
8 changed files with 13 additions and 13 deletions

View File

@@ -96,7 +96,7 @@ func submitForClientHandler(w http.ResponseWriter, r *http.Request, masterUrl st
return
}
url := "http://" + assignResult.PublicUrl + "/" + assignResult.Fid
url := "http://" + assignResult.Url + "/" + assignResult.Fid
if lastModified != 0 {
url = url + "?ts=" + strconv.FormatUint(lastModified, 10)
}

View File

@@ -80,7 +80,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
w.WriteHeader(http.StatusNotFound)
return
}
urlLocation := lookup.Locations[rand.Intn(len(lookup.Locations))].PublicUrl
urlLocation := lookup.Locations[rand.Intn(len(lookup.Locations))].Url
urlString := "http://" + urlLocation + "/" + fileId
if fs.redirectOnRead {
http.Redirect(w, r, urlString, http.StatusFound)
@@ -126,7 +126,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
return
}
u, _ := url.Parse("http://" + assignResult.PublicUrl + "/" + assignResult.Fid)
u, _ := url.Parse("http://" + assignResult.Url + "/" + assignResult.Fid)
glog.V(4).Infoln("post to", u)
request := &http.Request{
Method: r.Method,

View File

@@ -119,7 +119,7 @@ func (ms *MasterServer) redirectHandler(w http.ResponseWriter, r *http.Request)
}
machines := ms.Topo.Lookup("", volumeId)
if machines != nil && len(machines) > 0 {
http.Redirect(w, r, "http://"+machines[0].PublicUrl+r.URL.Path, http.StatusMovedPermanently)
http.Redirect(w, r, "http://"+machines[0].Url()+r.URL.Path, http.StatusMovedPermanently)
} else {
writeJsonError(w, r, http.StatusNotFound, fmt.Errorf("volume id %d not found.", volumeId))
}

View File

@@ -61,7 +61,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
lookupResult, err := operation.Lookup(vs.masterNode, volumeId.String())
glog.V(2).Infoln("volume", volumeId, "found on", lookupResult, "error", err)
if err == nil && len(lookupResult.Locations) > 0 {
http.Redirect(w, r, "http://"+lookupResult.Locations[0].PublicUrl+r.URL.Path, http.StatusMovedPermanently)
http.Redirect(w, r, "http://"+lookupResult.Locations[0].Url+r.URL.Path, http.StatusMovedPermanently)
} else {
glog.V(2).Infoln("lookup error:", err, r.URL.Path)
w.WriteHeader(http.StatusNotFound)