X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1d1c6de3c842a33a57b7d469fdaaaa1b873433dc..7ed2f9d875d69b1494372c0cb790b18187dbacf2:/sdk/go/keepclient/support.go diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go index 8414afab1e..b904b099cb 100644 --- a/sdk/go/keepclient/support.go +++ b/sdk/go/keepclient/support.go @@ -2,7 +2,6 @@ package keepclient import ( "crypto/md5" - "encoding/json" "errors" "fmt" "git.curoverse.com/arvados.git/sdk/go/streamer" @@ -35,9 +34,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 @@ -59,8 +58,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 @@ -87,86 +86,6 @@ type svcList struct { Items []keepService `json:"items"` } -// DiscoverKeepServers gets list of available keep services from api server -func (this *KeepClient) DiscoverKeepServers() error { - var list svcList - - // Get keep services from api server - err := this.Arvados.Call("GET", "keep_services", "", "accessible", nil, &list) - if err != nil { - return err - } - - return this.loadKeepServers(list) -} - -// LoadKeepServicesFromJSON gets list of available keep services from given JSON -func (this *KeepClient) LoadKeepServicesFromJSON(services string) error { - var list svcList - - // Load keep services from given json - dec := json.NewDecoder(strings.NewReader(services)) - if err := dec.Decode(&list); err != nil { - return err - } - - return this.loadKeepServers(list) -} - -// loadKeepServers -func (this *KeepClient) loadKeepServers(list svcList) error { - listed := make(map[string]bool) - localRoots := make(map[string]string) - gatewayRoots := make(map[string]string) - writableLocalRoots := make(map[string]string) - - // replicasPerService is 1 for disks; unknown or unlimited otherwise - this.replicasPerService = 1 - this.Using_proxy = false - - for _, service := range list.Items { - scheme := "http" - if service.SSL { - scheme = "https" - } - url := fmt.Sprintf("%s://%s:%d", scheme, service.Hostname, service.Port) - - // Skip duplicates - if listed[url] { - continue - } - listed[url] = true - - localRoots[service.Uuid] = url - if service.SvcType == "proxy" { - this.Using_proxy = true - } - - if service.ReadOnly == false { - writableLocalRoots[service.Uuid] = url - if service.SvcType != "disk" { - this.replicasPerService = 0 - } - } - - // Gateway services are only used when specified by - // UUID, so there's nothing to gain by filtering them - // by service type. Including all accessible services - // (gateway and otherwise) merely accommodates more - // service configurations. - gatewayRoots[service.Uuid] = url - } - - if this.Using_proxy { - this.setClientSettingsProxy() - } else { - this.setClientSettingsDisk() - } - - this.SetServiceRoots(localRoots, writableLocalRoots, gatewayRoots) - return nil -} - type uploadStatus struct { err error url string