// "foo" acbd18db4cc2f85cedef654fccc4a4d8
foo_shuffle := []string{"http://localhost:4", "http://localhost:1", "http://localhost:3", "http://localhost:2"}
- c.Check(kc.shuffledServiceRoots("acbd18db4cc2f85cedef654fccc4a4d8"), DeepEquals, foo_shuffle)
+ c.Check(NewRootSorter(
+ kc.ServiceRoots(), Md5String("foo")).GetSortedRoots(),
+ DeepEquals, foo_shuffle)
// "bar" 37b51d194a7513e45b56f6524f2d51f2
bar_shuffle := []string{"http://localhost:3", "http://localhost:2", "http://localhost:4", "http://localhost:1"}
- c.Check(kc.shuffledServiceRoots("37b51d194a7513e45b56f6524f2d51f2"), DeepEquals, bar_shuffle)
+ c.Check(NewRootSorter(
+ kc.ServiceRoots(), Md5String("bar")).GetSortedRoots(),
+ DeepEquals, bar_shuffle)
}
type StubPutHandler struct {
func (s *StandaloneSuite) TestPutB(c *C) {
log.Printf("TestPutB")
- hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+ hash := Md5String("foo")
st := StubPutHandler{
c,
kc.PutB([]byte("foo"))
- shuff := kc.shuffledServiceRoots(fmt.Sprintf("%x", md5.Sum([]byte("foo"))))
+ shuff := NewRootSorter(
+ kc.ServiceRoots(), Md5String("foo")).GetSortedRoots()
s1 := <-st.handled
s2 := <-st.handled
kc.PutHR(hash, reader, 3)
- shuff := kc.shuffledServiceRoots(hash)
+ shuff := NewRootSorter(kc.ServiceRoots(), hash).GetSortedRoots()
log.Print(shuff)
s1 := <-st.handled
kc.SetServiceRoots(service_roots)
- shuff := kc.shuffledServiceRoots(fmt.Sprintf("%x", md5.Sum([]byte("foo"))))
+ shuff := NewRootSorter(
+ kc.ServiceRoots(), Md5String("foo")).GetSortedRoots()
phash, replicas, err := kc.PutB([]byte("foo"))
package keepclient
import (
+ "crypto/md5"
"git.curoverse.com/arvados.git/sdk/go/streamer"
"errors"
"fmt"
SvcType string `json:"service_type"`
}
+func Md5String(s string) (string) {
+ return fmt.Sprintf("%x", md5.Sum([]byte(s)))
+}
+
func (this *KeepClient) DiscoverKeepServers() error {
if prx := os.Getenv("ARVADOS_KEEP_PROXY"); prx != "" {
sr := map[string]string{"proxy":prx}
return nil
}
-func (this KeepClient) shuffledServiceRoots(hash string) (pseq []string) {
- return NewRootSorter(this.ServiceRoots(), hash).GetSortedRoots()
-}
-
type uploadStatus struct {
err error
url string