X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/908261de15c98553a4200f01aff1f26ef57c8fb8..80689aac71f6e3e9b103f0f6b668bd173a76554f:/sdk/go/keepclient/keepclient.go diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go index 26aa7177e0..4f84afca61 100644 --- a/sdk/go/keepclient/keepclient.go +++ b/sdk/go/keepclient/keepclient.go @@ -4,7 +4,6 @@ package keepclient import ( "bytes" "crypto/md5" - "crypto/tls" "errors" "fmt" "git.curoverse.com/arvados.git/sdk/go/arvadosclient" @@ -73,6 +72,7 @@ type KeepClient struct { lock sync.RWMutex Client *http.Client Retries int + BlockCache *BlockCache // set to 1 if all writable services are of disk type, otherwise 0 replicasPerService int @@ -103,7 +103,7 @@ func New(arv *arvadosclient.ArvadosClient) *KeepClient { Arvados: arv, Want_replicas: defaultReplicationLevel, Client: &http.Client{Transport: &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: arv.ApiInsecure}}}, + TLSClientConfig: arvadosclient.MakeTLSConfig(arv.ApiInsecure)}}, Retries: 2, } return kc @@ -168,6 +168,10 @@ func (kc *KeepClient) PutR(r io.Reader) (locator string, replicas int, err error } func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, int64, string, error) { + if strings.HasPrefix(locator, "d41d8cd98f00b204e9800998ecf8427e+0") { + return ioutil.NopCloser(bytes.NewReader(nil)), 0, "", nil + } + var errs []string tries_remaining := 1 + kc.Retries @@ -352,7 +356,7 @@ func (kc *KeepClient) WritableLocalRoots() map[string]string { // caller can reuse/modify them after SetServiceRoots returns, but // they should not be modified by any other goroutine while // SetServiceRoots is running. -func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals map[string]string, newGateways map[string]string) { +func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals, newGateways map[string]string) { locals := make(map[string]string) for uuid, root := range newLocals { locals[uuid] = root @@ -403,6 +407,14 @@ func (kc *KeepClient) getSortedRoots(locator string) []string { return found } +func (kc *KeepClient) cache() *BlockCache { + if kc.BlockCache != nil { + return kc.BlockCache + } else { + return DefaultBlockCache + } +} + type Locator struct { Hash string Size int // -1 if data size is not known