X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dfb9a5e285e4275c26b6f959a04babd5a8ad836e..ecf4a87ac687b713d3eb4f191f4c5ead293fa046:/sdk/go/keepclient/support.go diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go index 90ac3bcb17..b12f512507 100644 --- a/sdk/go/keepclient/support.go +++ b/sdk/go/keepclient/support.go @@ -7,7 +7,6 @@ import ( "git.curoverse.com/arvados.git/sdk/go/streamer" "io" "io/ioutil" - "log" "math/rand" "net" "net/http" @@ -34,9 +33,9 @@ func Md5String(s string) string { return fmt.Sprintf("%x", md5.Sum([]byte(s))) } -// Set timeouts apply when connecting to keepproxy services (assumed to be over -// the Internet). -func (this *KeepClient) setClientSettingsProxy() { +// Set timeouts applicable when connecting to non-disk services +// (assumed to be over the Internet). +func (this *KeepClient) setClientSettingsNonDisk() { if this.Client.Timeout == 0 { // Maximum time to wait for a complete response this.Client.Timeout = 300 * time.Second @@ -58,8 +57,8 @@ func (this *KeepClient) setClientSettingsProxy() { } } -// Set timeouts apply when connecting to keepstore services directly (assumed -// to be on the local network). +// Set timeouts applicable when connecting to keepstore services directly +// (assumed to be on the local network). func (this *KeepClient) setClientSettingsDisk() { if this.Client.Timeout == 0 { // Maximum time to wait for a complete response @@ -101,7 +100,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea var err error var url = fmt.Sprintf("%s/%s", host, hash) if req, err = http.NewRequest("PUT", url, nil); err != nil { - log.Printf("[%08x] Error creating request PUT %v error: %v", requestID, url, err.Error()) + DebugPrintf("DEBUG: [%08x] Error creating request PUT %v error: %v", requestID, url, err.Error()) upload_status <- uploadStatus{err, url, 0, 0, ""} body.Close() return @@ -126,7 +125,7 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea var resp *http.Response if resp, err = this.Client.Do(req); err != nil { - log.Printf("[%08x] Upload failed %v error: %v", requestID, url, err.Error()) + DebugPrintf("DEBUG: [%08x] Upload failed %v error: %v", requestID, url, err.Error()) upload_status <- uploadStatus{err, url, 0, 0, ""} return } @@ -142,13 +141,13 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea respbody, err2 := ioutil.ReadAll(&io.LimitedReader{R: resp.Body, N: 4096}) response := strings.TrimSpace(string(respbody)) if err2 != nil && err2 != io.EOF { - log.Printf("[%08x] Upload %v error: %v response: %v", requestID, url, err2.Error(), response) + DebugPrintf("DEBUG: [%08x] Upload %v error: %v response: %v", requestID, url, err2.Error(), response) upload_status <- uploadStatus{err2, url, resp.StatusCode, rep, response} } else if resp.StatusCode == http.StatusOK { - log.Printf("[%08x] Upload %v success", requestID, url) + DebugPrintf("DEBUG: [%08x] Upload %v success", requestID, url) upload_status <- uploadStatus{nil, url, resp.StatusCode, rep, response} } else { - log.Printf("[%08x] Upload %v error: %v response: %v", requestID, url, resp.StatusCode, response) + DebugPrintf("DEBUG: [%08x] Upload %v error: %v response: %v", requestID, url, resp.StatusCode, response) upload_status <- uploadStatus{errors.New(resp.Status), url, resp.StatusCode, rep, response} } } @@ -205,7 +204,7 @@ func (this *KeepClient) putReplicas( for active*replicasPerThread < remaining_replicas { // Start some upload requests if next_server < len(sv) { - log.Printf("[%08x] Begin upload %s to %s", requestID, hash, sv[next_server]) + DebugPrintf("DEBUG: [%08x] Begin upload %s to %s", requestID, hash, sv[next_server]) go this.uploadToKeepServer(sv[next_server], hash, tr.MakeStreamReader(), upload_status, expectedLength, requestID) next_server += 1 active += 1 @@ -217,7 +216,7 @@ func (this *KeepClient) putReplicas( } } } - log.Printf("[%08x] Replicas remaining to write: %v active uploads: %v", + DebugPrintf("DEBUG: [%08x] Replicas remaining to write: %v active uploads: %v", requestID, remaining_replicas, active) // Now wait for something to happen.