refactoring content uploading

This commit is contained in:
Chris Lu
2012-09-20 17:58:29 -07:00
parent 7d8e9f829c
commit 5e97179d06
6 changed files with 74 additions and 47 deletions

View File

@@ -137,6 +137,30 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
writeJson(w, r, ne)
} else {
ret := store.Write(volumeId, needle)
if ret > 0 { //send to other replica locations
if r.FormValue("type") != "standard" {
waitTime, err := strconv.Atoi(r.FormValue("wait"))
lookupResult, lookupErr := operation.Lookup(*server, volumeId)
if lookupErr == nil {
sendFunc := func(background bool) {
postContentFunc := func(location operation.Location) bool{
return true
}
for _, location := range lookupResult.Locations {
if background {
go postContentFunc(location)
}else{
postContentFunc(location)
}
}
}
sendFunc(err == nil && waitTime > 0)
} else {
log.Println("Failed to lookup for", volumeId, lookupErr.Error())
}
}
}
m := make(map[string]uint32)
m["size"] = ret
writeJson(w, r, m)