[ARVADOS] updated: d4224bfee9d5ece132bc50db96de48da3620d5e5

git at public.curoverse.com git at public.curoverse.com
Fri Nov 14 11:23:56 EST 2014


Summary of changes:
 services/keepstore/handler_test.go |  3 ++-
 services/keepstore/handlers.go     | 35 +++++++++++++++++++++++++++++++++++
 services/keepstore/keepstore.go    |  8 +++++---
 3 files changed, 42 insertions(+), 4 deletions(-)

       via  d4224bfee9d5ece132bc50db96de48da3620d5e5 (commit)
       via  35c53e2525e0d29cb8ffae486718b4fde88b273f (commit)
      from  3a31350c6265cb1135d3d4d40af436aae91a9894 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d4224bfee9d5ece132bc50db96de48da3620d5e5
Author: radhika <radhika at curoverse.com>
Date:   Fri Nov 14 11:03:55 2014 -0500

    4194: improve logging when large block is retrieved.

diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 2f32be5..832a773 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -778,8 +778,13 @@ type WrapRESTRouter struct {
 func (wrapper *WrapRESTRouter) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
   loggingWriter := LoggingResponseWriter{200, nil, resp}
   wrapper.router.ServeHTTP(&loggingWriter, req)
-  if loggingWriter.data != nil && loggingWriter.status == 200{
-    log.Printf("[%s] %s %s %d %s", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, loggingWriter.data)
+  if loggingWriter.data != nil && loggingWriter.status == 200 {
+    data_len := len(loggingWriter.data)
+    if data_len > 200 {  // this could be a block
+      log.Printf("[%s] %s %s %d %d", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, data_len)
+    } else {  // this could be a hash or status or a small block etc
+      log.Printf("[%s] %s %s %d %s", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, loggingWriter.data)
+    }
   } else {
     log.Printf("[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status)
   }

commit 35c53e2525e0d29cb8ffae486718b4fde88b273f
Author: radhika <radhika at curoverse.com>
Date:   Fri Nov 14 09:50:39 2014 -0500

    4194: Add LoggingResponseWriter and RESTRouter wrapper. Update keepstore and handler_test to use the router wrapper.

diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index ca60915..32479d8 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -750,7 +750,8 @@ func IssueRequest(router *mux.Router, rt *RequestTester) *httptest.ResponseRecor
 	if rt.api_token != "" {
 		req.Header.Set("Authorization", "OAuth2 "+rt.api_token)
 	}
-	router.ServeHTTP(response, req)
+  routerWrapper := WrapRESTRouter{router}
+  routerWrapper.ServeHTTP(response, req)
 	return response
 }
 
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 27d1e90..2f32be5 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -754,3 +754,33 @@ func CanDelete(api_token string) bool {
 func IsDataManagerToken(api_token string) bool {
 	return data_manager_token != "" && api_token == data_manager_token
 }
+
+type LoggingResponseWriter struct {
+  status int
+  data []byte
+  http.ResponseWriter
+}
+
+func (loggingWriter *LoggingResponseWriter) WriteHeader(code int) {
+  loggingWriter.status = code
+  loggingWriter.ResponseWriter.WriteHeader(code)
+}
+
+func (loggingWriter *LoggingResponseWriter) Write(data []byte) (int, error){
+  loggingWriter.data = data
+  return loggingWriter.ResponseWriter.Write(data)
+}
+
+type WrapRESTRouter struct {
+  router *mux.Router
+}
+
+func (wrapper *WrapRESTRouter) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
+  loggingWriter := LoggingResponseWriter{200, nil, resp}
+  wrapper.router.ServeHTTP(&loggingWriter, req)
+  if loggingWriter.data != nil && loggingWriter.status == 200{
+    log.Printf("[%s] %s %s %d %s", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, loggingWriter.data)
+  } else {
+    log.Printf("[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status)
+  }
+}
diff --git a/services/keepstore/keepstore.go b/services/keepstore/keepstore.go
index c899d51..08043cc 100644
--- a/services/keepstore/keepstore.go
+++ b/services/keepstore/keepstore.go
@@ -262,9 +262,11 @@ func main() {
 	// Start a round-robin VolumeManager with the volumes we have found.
 	KeepVM = MakeRRVolumeManager(goodvols)
 
-	// Tell the built-in HTTP server to direct all requests to the REST
-	// router.
-	http.Handle("/", MakeRESTRouter())
+	// Tell the built-in HTTP server to direct all requests to the REST router.
+  routerWrapper := WrapRESTRouter{MakeRESTRouter()}
+  http.HandleFunc("/", func(resp http.ResponseWriter, req *http.Request) {
+    routerWrapper.ServeHTTP(resp, req)
+  })
 
 	// Set up a TCP listener.
 	listener, err := net.Listen("tcp", listen)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list