[ARVADOS] updated: 6c29e76287d9df651a0bc54d7c0a7a4611862ada
git at public.curoverse.com
git at public.curoverse.com
Tue Aug 26 20:51:34 EDT 2014
Summary of changes:
services/keepstore/handler_test.go | 4 ++--
services/keepstore/handlers.go | 5 ++++-
services/keepstore/replicator/replica.go | 15 ++++++++-------
3 files changed, 14 insertions(+), 10 deletions(-)
via 6c29e76287d9df651a0bc54d7c0a7a4611862ada (commit)
from b185fc94a543b5b1361497c8502e876d6fdc2838 (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 6c29e76287d9df651a0bc54d7c0a7a4611862ada
Author: Tim Pierce <twp at curoverse.com>
Date: Tue Aug 26 20:50:01 2014 -0400
3414: update for code review
Added logging for pull lists. Unsuccessful pull lists are logged with
an error, successful ones are logged with the new pull list.
Renamed the Replicator interface with GetList and SetList.
diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index 2b1f7cd..9d60312 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -591,7 +591,7 @@ func TestDeleteHandler(t *testing.T) {
//
// TODO(twp): test concurrency: launch 100 goroutines to update the
// pull list simultaneously. Make sure that none of them return 400
-// Bad Request and that replica.Dump() returns a valid list.
+// Bad Request and that replica.GetList() returns a valid list.
//
func TestPullHandler(t *testing.T) {
defer teardown()
@@ -663,7 +663,7 @@ func TestPullHandler(t *testing.T) {
// The Keep replicator should have received one good list with 3
// requests on it.
- var saved_pull_list = replica.Dump()
+ var saved_pull_list = replica.GetList()
if len(saved_pull_list) != 3 {
t.Errorf(
"saved_pull_list: expected 3 elements, got %d\nsaved_pull_list = %v",
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 9d4c617..a488e37 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -441,6 +441,7 @@ func PullHandler(resp http.ResponseWriter, req *http.Request) {
api_token := GetApiToken(req)
if !IsDataManagerToken(api_token) {
http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
+ log.Printf("%s %s: %s\n", req.Method, req.URL, UnauthorizedError.Error())
return
}
@@ -449,12 +450,14 @@ func PullHandler(resp http.ResponseWriter, req *http.Request) {
r := json.NewDecoder(req.Body)
if err := r.Decode(&pull_list); err != nil {
http.Error(resp, BadRequestError.Error(), BadRequestError.HTTPCode)
+ log.Printf("%s %s: %s\n", req.Method, req.URL, err.Error())
return
}
// We have a properly formatted pull list sent from the data
// manager. Report success and send the list to the keep
// replicator for further handling.
+ log.Printf("%s %s: received %s\n", req.Method, req.URL, pull_list)
resp.WriteHeader(http.StatusOK)
resp.Write([]byte(
fmt.Sprintf("Received %d pull requests\n", len(pull_list))))
@@ -462,7 +465,7 @@ func PullHandler(resp http.ResponseWriter, req *http.Request) {
if replica == nil {
replica = replicator.New()
}
- replica.Pull(pull_list)
+ replica.SetList(pull_list)
}
// ==============================
diff --git a/services/keepstore/replicator/replica.go b/services/keepstore/replicator/replica.go
index b9995c1..e314b86 100644
--- a/services/keepstore/replicator/replica.go
+++ b/services/keepstore/replicator/replica.go
@@ -8,9 +8,10 @@ package replicator
replicator.New() launches a replication goroutine and returns the
new Replicator object.
- replicator.Pull() assigns a new pull list to the goroutine.
+ replicator.SetList() assigns a new pull list to the goroutine. Any
+ existing list is discarded.
- replicator.Dump() reports the goroutine's current pull list.
+ replicator.GetList() reports the goroutine's current pull list.
replicator.Close() shuts down the replicator.
*/
@@ -37,16 +38,16 @@ func New() *Replicator {
return &r
}
-// Pull sends a new list of pull requests to the replicator goroutine.
-// The replicator will discard any outstanding pull requests and begin
+// SetList sends a new list of pull requests to the replicator goroutine.
+// The replicator will discard any outstanding pull list and begin
// working on the new list.
//
-func (r *Replicator) Pull(pr []PullRequest) {
+func (r *Replicator) SetList(pr []PullRequest) {
r.queue <- pr
}
-// Dump reports the contents of the current pull list.
-func (r *Replicator) Dump() []PullRequest {
+// GetList reports the contents of the current pull list.
+func (r *Replicator) GetList() []PullRequest {
return <-r.dump
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list