|
|
@ -14,13 +14,9 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
start := time.Now() |
|
|
|
|
|
|
|
if r.Method == "OPTIONS" { |
|
|
|
stats.FilerRequestCounter.WithLabelValues("options").Inc() |
|
|
|
OptionsHandler(w, r, false) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("options").Observe(time.Since(start).Seconds()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@ -36,12 +32,17 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
fileId = r.RequestURI[len("/?proxyChunkId="):] |
|
|
|
} |
|
|
|
if fileId != "" { |
|
|
|
stats.FilerRequestCounter.WithLabelValues("proxy").Inc() |
|
|
|
stats.FilerRequestCounter.WithLabelValues(stats.ChunkProxy).Inc() |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
if r.Header.Get("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 { |
|
|
|
case "GET": |
|
|
|
stats.FilerRequestCounter.WithLabelValues("get").Inc() |
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) |
|
|
|
case "HEAD": |
|
|
|
stats.FilerRequestCounter.WithLabelValues("head").Inc() |
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds()) |
|
|
|
case "DELETE": |
|
|
|
stats.FilerRequestCounter.WithLabelValues("delete").Inc() |
|
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
|
fs.DeleteTaggingHandler(w, r) |
|
|
|
} else { |
|
|
|
fs.DeleteHandler(w, r) |
|
|
|
} |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds()) |
|
|
|
case "POST", "PUT": |
|
|
|
|
|
|
|
// wait until in flight data is less than the limit
|
|
|
|
contentLength := getContentLength(r) |
|
|
|
fs.inFlightDataLimitCond.L.Lock() |
|
|
@ -81,17 +75,13 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
}() |
|
|
|
|
|
|
|
if r.Method == "PUT" { |
|
|
|
stats.FilerRequestCounter.WithLabelValues("put").Inc() |
|
|
|
if _, ok := r.URL.Query()["tagging"]; ok { |
|
|
|
fs.PutTaggingHandler(w, r) |
|
|
|
} else { |
|
|
|
fs.PostHandler(w, r, contentLength) |
|
|
|
} |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("put").Observe(time.Since(start).Seconds()) |
|
|
|
} else { // method == "POST"
|
|
|
|
stats.FilerRequestCounter.WithLabelValues("post").Inc() |
|
|
|
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) { |
|
|
|
|
|
|
|
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
|
|
|
|
if r.Method == "OPTIONS" { |
|
|
|
stats.FilerRequestCounter.WithLabelValues("options").Inc() |
|
|
|
OptionsHandler(w, r, true) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("options").Observe(time.Since(start).Seconds()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@ -120,13 +111,9 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
} |
|
|
|
switch r.Method { |
|
|
|
case "GET": |
|
|
|
stats.FilerRequestCounter.WithLabelValues("get").Inc() |
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) |
|
|
|
case "HEAD": |
|
|
|
stats.FilerRequestCounter.WithLabelValues("head").Inc() |
|
|
|
fs.GetOrHeadHandler(w, r) |
|
|
|
stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|