[ARVADOS] created: bb663993cc851971d9444d834acfc416363931b2
git at public.curoverse.com
git at public.curoverse.com
Mon Sep 21 11:10:05 EDT 2015
at bb663993cc851971d9444d834acfc416363931b2 (commit)
commit bb663993cc851971d9444d834acfc416363931b2
Author: radhika <radhika at curoverse.com>
Date: Mon Sep 21 11:08:07 2015 -0400
7162: enhance SetServiceRoots to look for all service hints, not just K@ hints.
diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index f82e5c7..479669a 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -239,15 +239,15 @@ func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals map[string]st
func (kc *KeepClient) getSortedRoots(locator string) []string {
var found []string
for _, hint := range strings.Split(locator, "+") {
- if len(hint) < 7 || hint[0:2] != "K@" {
+ if len(hint) < 7 || hint[0:1] == "A" || (hint[0:1] >= "0" && hint[0:1] <= "9") {
// Not a service hint.
continue
}
- if len(hint) == 7 {
+ if len(hint) == 7 && hint[0:2] == "K@" {
// +K at abcde means fetch from proxy at
// keep.abcde.arvadosapi.com
found = append(found, "https://keep."+hint[2:]+".arvadosapi.com")
- } else if len(hint) == 29 {
+ } else if len(hint) == 29 && arvadosclient.UUIDMatch(hint[2:]){
// +K at abcde-abcde-abcdeabcdeabcde means fetch
// from gateway with given uuid
if gwURI, ok := kc.GatewayRoots()[hint[2:]]; ok {
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index b467d06..592d77e 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -14,7 +14,7 @@ import (
"time"
)
-type keepDisk struct {
+type keepServices struct {
Uuid string `json:"uuid"`
Hostname string `json:"service_host"`
Port int `json:"service_port"`
@@ -23,6 +23,7 @@ type keepDisk struct {
ReadOnly bool `json:"read_only"`
}
+// Md5String returns md5 hash for the bytes in the given string
func Md5String(s string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
@@ -49,12 +50,11 @@ func (this *KeepClient) setClientSettingsProxy() {
TLSHandshakeTimeout: 10 * time.Second,
}
}
-
}
// Set timeouts apply when connecting to keepstore services directly (assumed
// to be on the local network).
-func (this *KeepClient) setClientSettingsStore() {
+func (this *KeepClient) setClientSettingsDisk() {
if this.Client.Timeout == 0 {
// Maximum time to wait for a complete response
this.Client.Timeout = 20 * time.Second
@@ -76,14 +76,17 @@ func (this *KeepClient) setClientSettingsStore() {
}
}
+// DiscoverKeepServers gets list of available keep services from api server
func (this *KeepClient) DiscoverKeepServers() error {
type svcList struct {
- Items []keepDisk `json:"items"`
+ Items []keepServices `json:"items"`
}
var m svcList
+ // Get keep services from api server
err := this.Arvados.Call("GET", "keep_services", "", "accessible", nil, &m)
+ // If there is error getting keep services, get list of keep disks
if err != nil {
if err := this.Arvados.List("keep_disks", nil, &m); err != nil {
return err
@@ -111,7 +114,7 @@ func (this *KeepClient) DiscoverKeepServers() error {
switch service.SvcType {
case "disk":
localRoots[service.Uuid] = url
- case "proxy":
+ default:
localRoots[service.Uuid] = url
this.Using_proxy = true
}
@@ -131,7 +134,7 @@ func (this *KeepClient) DiscoverKeepServers() error {
if this.Using_proxy {
this.setClientSettingsProxy()
} else {
- this.setClientSettingsStore()
+ this.setClientSettingsDisk()
}
this.SetServiceRoots(localRoots, writableLocalRoots, gatewayRoots)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list