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

@@ -66,11 +66,11 @@ func DeleteFiles(master string, fileIds []string) (*DeleteFilesResult, error) {
continue
}
for _, location := range result.Locations {
if _, ok := server_to_fileIds[location.PublicUrl]; !ok {
server_to_fileIds[location.PublicUrl] = make([]string, 0)
if _, ok := server_to_fileIds[location.Url]; !ok {
server_to_fileIds[location.Url] = make([]string, 0)
}
server_to_fileIds[location.PublicUrl] = append(
server_to_fileIds[location.PublicUrl], vid_to_fileIds[vid]...)
server_to_fileIds[location.Url] = append(
server_to_fileIds[location.Url], vid_to_fileIds[vid]...)
}
}

View File

@@ -72,7 +72,7 @@ func LookupFileId(server string, fileId string) (fullUrl string, err error) {
if len(lookup.Locations) == 0 {
return "", errors.New("File Not Found")
}
return "http://" + lookup.Locations[rand.Intn(len(lookup.Locations))].PublicUrl + "/" + fileId, nil
return "http://" + lookup.Locations[rand.Intn(len(lookup.Locations))].Url + "/" + fileId, nil
}
// LookupVolumeIds find volume locations by cache and actual lookup

View File

@@ -137,7 +137,7 @@ func upload_one_chunk(filename string, reader io.Reader, master, replication str
if err != nil {
return "", 0, err
}
fileUrl, fid := "http://"+ret.PublicUrl+"/"+ret.Fid, ret.Fid
fileUrl, fid := "http://"+ret.Url+"/"+ret.Fid, ret.Fid
glog.V(4).Info("Uploading part ", filename, " to ", fileUrl, "...")
uploadResult, uploadError := Upload(fileUrl, filename, reader, false, "application/octet-stream")
if uploadError != nil {