Browse Source

report errors when upload timeouts

pull/2/head
Chris Lu 12 years ago
parent
commit
54906c48f3
  1. 7
      go/storage/needle.go
  2. 27
      go/weed/volume.go

7
go/storage/needle.go

@ -60,7 +60,12 @@ func NewNeedle(r *http.Request) (n *Needle, e error) {
e = errors.New("No file found!")
return
}
data, _ := ioutil.ReadAll(part)
data, ioe := ioutil.ReadAll(part)
if ioe != nil {
e = ioe
log.Println("Reading Content [ERROR]", ioe)
return
}
dotIndex := strings.LastIndex(fname, ".")
ext, mtype := "", ""
if dotIndex > 0 {

27
go/weed/volume.go

@ -37,7 +37,7 @@ var (
publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible <ip|server_name>:<port>")
masterNode = cmdVolume.Flag.String("mserver", "localhost:9333", "master server location")
vpulse = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than the master's setting")
vReadTimeout = cmdVolume.Flag.Int("readTimeout", 3, "connection read timeout in seconds")
vReadTimeout = cmdVolume.Flag.Int("readTimeout", 3, "connection read timeout in seconds. Increase this if uploading large files.")
vMaxCpu = cmdVolume.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
dataCenter = cmdVolume.Flag.String("dataCenter", "", "current volume server's data center name")
rack = cmdVolume.Flag.String("rack", "", "current volume server's rack name")
@ -196,27 +196,28 @@ func GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool)
}
}
func PostHandler(w http.ResponseWriter, r *http.Request) {
m := make(map[string]interface{})
if e := r.ParseForm(); e != nil {
debug("form parse error:", e)
writeJsonQuiet(w, r, e)
m["error"] = e.Error()
writeJsonQuiet(w, r, m)
return
}
vid, _, _, _ := parseURLPath(r.URL.Path)
volumeId, e := storage.NewVolumeId(vid)
if e != nil {
debug("NewVolumeId error:", e)
writeJsonQuiet(w, r, e)
volumeId, ve := storage.NewVolumeId(vid)
if ve != nil {
debug("NewVolumeId error:", ve)
m["error"] = ve.Error()
writeJsonQuiet(w, r, m)
return
}
if e != nil {
writeJsonQuiet(w, r, e)
} else {
needle, ne := storage.NewNeedle(r)
if ne != nil {
writeJsonQuiet(w, r, ne)
} else {
m["error"] = ne.Error()
writeJsonQuiet(w, r, m)
return
}
ret, errorStatus := replication.ReplicatedWrite(*masterNode, store, volumeId, needle, r)
m := make(map[string]interface{})
if errorStatus == "" {
w.WriteHeader(http.StatusCreated)
} else {
@ -226,8 +227,6 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
m["size"] = ret
writeJsonQuiet(w, r, m)
}
}
}
func DeleteHandler(w http.ResponseWriter, r *http.Request) {
n := new(storage.Needle)
vid, fid, _, _ := parseURLPath(r.URL.Path)

Loading…
Cancel
Save