|
@ -14,13 +14,9 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
start := time.Now() |
|
|
start := time.Now() |
|
|
|
|
|
|
|
|
if r.Method == "OPTIONS" { |
|
|
if r.Method == "OPTIONS" { |
|
|
stats.FilerRequestCounter.WithLabelValues("options").Inc() |
|
|
|
|
|
OptionsHandler(w, r, false) |
|
|
OptionsHandler(w, r, false) |
|
|
stats.FilerRequestHistogram.WithLabelValues("options").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -36,12 +32,17 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
fileId = r.RequestURI[len("/?proxyChunkId="):] |
|
|
fileId = r.RequestURI[len("/?proxyChunkId="):] |
|
|
} |
|
|
} |
|
|
if fileId != "" { |
|
|
if fileId != "" { |
|
|
stats.FilerRequestCounter.WithLabelValues("proxy").Inc() |
|
|
|
|
|
|
|
|
stats.FilerRequestCounter.WithLabelValues(stats.ChunkProxy).Inc() |
|
|
fs.proxyToVolumeServer(w, r, fileId) |
|
|
fs.proxyToVolumeServer(w, r, fileId) |
|
|
stats.FilerRequestHistogram.WithLabelValues("proxy").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
|
|
|
stats.FilerRequestHistogram.WithLabelValues(stats.ChunkProxy).Observe(time.Since(start).Seconds()) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stats.FilerRequestCounter.WithLabelValues(r.Method).Inc() |
|
|
|
|
|
defer func() { |
|
|
|
|
|
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds()) |
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION) |
|
|
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION) |
|
|
if r.Header.Get("Origin") != "" { |
|
|
if r.Header.Get("Origin") != "" { |
|
|
w.Header().Set("Access-Control-Allow-Origin", "*") |
|
|
w.Header().Set("Access-Control-Allow-Origin", "*") |
|
@ -49,23 +50,16 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
} |
|
|
} |
|
|
switch r.Method { |
|
|
switch r.Method { |
|
|
case "GET": |
|
|
case "GET": |
|
|
stats.FilerRequestCounter.WithLabelValues("get").Inc() |
|
|
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
fs.GetOrHeadHandler(w, r) |
|
|
stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
case "HEAD": |
|
|
case "HEAD": |
|
|
stats.FilerRequestCounter.WithLabelValues("head").Inc() |
|
|
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
fs.GetOrHeadHandler(w, r) |
|
|
stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
case "DELETE": |
|
|
case "DELETE": |
|
|
stats.FilerRequestCounter.WithLabelValues("delete").Inc() |
|
|
|
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
fs.DeleteTaggingHandler(w, r) |
|
|
fs.DeleteTaggingHandler(w, r) |
|
|
} else { |
|
|
} else { |
|
|
fs.DeleteHandler(w, r) |
|
|
fs.DeleteHandler(w, r) |
|
|
} |
|
|
} |
|
|
stats.FilerRequestHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
case "POST", "PUT": |
|
|
case "POST", "PUT": |
|
|
|
|
|
|
|
|
// wait until in flight data is less than the limit
|
|
|
// wait until in flight data is less than the limit
|
|
|
contentLength := getContentLength(r) |
|
|
contentLength := getContentLength(r) |
|
|
fs.inFlightDataLimitCond.L.Lock() |
|
|
fs.inFlightDataLimitCond.L.Lock() |
|
@ -81,17 +75,13 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
}() |
|
|
}() |
|
|
|
|
|
|
|
|
if r.Method == "PUT" { |
|
|
if r.Method == "PUT" { |
|
|
stats.FilerRequestCounter.WithLabelValues("put").Inc() |
|
|
|
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
fs.PutTaggingHandler(w, r) |
|
|
fs.PutTaggingHandler(w, r) |
|
|
} else { |
|
|
} else { |
|
|
fs.PostHandler(w, r, contentLength) |
|
|
fs.PostHandler(w, r, contentLength) |
|
|
} |
|
|
} |
|
|
stats.FilerRequestHistogram.WithLabelValues("put").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
} else { // method == "POST"
|
|
|
} else { // method == "POST"
|
|
|
stats.FilerRequestCounter.WithLabelValues("post").Inc() |
|
|
|
|
|
fs.PostHandler(w, r, contentLength) |
|
|
fs.PostHandler(w, r, contentLength) |
|
|
stats.FilerRequestHistogram.WithLabelValues("post").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -99,12 +89,13 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
start := time.Now() |
|
|
start := time.Now() |
|
|
|
|
|
|
|
|
|
|
|
stats.FilerRequestCounter.WithLabelValues(r.Method).Inc() |
|
|
|
|
|
defer func() { |
|
|
|
|
|
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds()) |
|
|
|
|
|
}() |
|
|
// We handle OPTIONS first because it never should be authenticated
|
|
|
// We handle OPTIONS first because it never should be authenticated
|
|
|
if r.Method == "OPTIONS" { |
|
|
if r.Method == "OPTIONS" { |
|
|
stats.FilerRequestCounter.WithLabelValues("options").Inc() |
|
|
|
|
|
OptionsHandler(w, r, true) |
|
|
OptionsHandler(w, r, true) |
|
|
stats.FilerRequestHistogram.WithLabelValues("options").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -120,13 +111,9 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque |
|
|
} |
|
|
} |
|
|
switch r.Method { |
|
|
switch r.Method { |
|
|
case "GET": |
|
|
case "GET": |
|
|
stats.FilerRequestCounter.WithLabelValues("get").Inc() |
|
|
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
fs.GetOrHeadHandler(w, r) |
|
|
stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
case "HEAD": |
|
|
case "HEAD": |
|
|
stats.FilerRequestCounter.WithLabelValues("head").Inc() |
|
|
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
fs.GetOrHeadHandler(w, r) |
|
|
stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds()) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|