本文整理匯總了Golang中git/curoverse/com/arvados/git/sdk/go/arvadosclient.MakeArvadosClient函數的典型用法代碼示例。如果您正苦於以下問題:Golang MakeArvadosClient函數的具體用法?Golang MakeArvadosClient怎麽用?Golang MakeArvadosClient使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MakeArvadosClient函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
flag.Parse()
if minutesBetweenRuns == 0 {
arv, err := arvadosclient.MakeArvadosClient()
if err != nil {
loggerutil.FatalWithMessage(arvLogger, fmt.Sprintf("Error making arvados client: %v", err))
}
err = singlerun(arv)
if err != nil {
loggerutil.FatalWithMessage(arvLogger, fmt.Sprintf("singlerun: %v", err))
}
} else {
waitTime := time.Minute * time.Duration(minutesBetweenRuns)
for {
log.Println("Beginning Run")
arv, err := arvadosclient.MakeArvadosClient()
if err != nil {
loggerutil.FatalWithMessage(arvLogger, fmt.Sprintf("Error making arvados client: %v", err))
}
err = singlerun(arv)
if err != nil {
log.Printf("singlerun: %v", err)
}
log.Printf("Sleeping for %d minutes", minutesBetweenRuns)
time.Sleep(waitTime)
}
}
}
示例2: SetupDataManagerTest
func SetupDataManagerTest(t *testing.T) {
os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
// start api and keep servers
arvadostest.ResetEnv()
arvadostest.StartAPI()
arvadostest.StartKeep(2, false)
var err error
arv, err = arvadosclient.MakeArvadosClient()
if err != nil {
t.Fatalf("Error making arvados client: %s", err)
}
arv.ApiToken = arvadostest.DataManagerToken
// keep client
keepClient = &keepclient.KeepClient{
Arvados: &arv,
Want_replicas: 2,
Client: &http.Client{},
}
// discover keep services
if err = keepClient.DiscoverKeepServers(); err != nil {
t.Fatalf("Error discovering keep services: %s", err)
}
keepServers = []string{}
for _, host := range keepClient.LocalRoots() {
keepServers = append(keepServers, host)
}
}
示例3: main
func main() {
flag.Parse()
arv, err := arvadosclient.MakeArvadosClient()
if err != nil {
log.Fatal(err)
}
kc, err := keepclient.MakeKeepClient(&arv)
if err != nil {
log.Fatal(err)
}
kc.Want_replicas = *Replicas
kc.Client.Timeout = 10 * time.Minute
nextBuf := make(chan []byte, *WriteThreads)
nextLocator := make(chan string, *ReadThreads+*WriteThreads)
go countBeans(nextLocator)
for i := 0; i < *WriteThreads; i++ {
go makeBufs(nextBuf, i)
go doWrites(kc, nextBuf, nextLocator)
}
for i := 0; i < *ReadThreads; i++ {
go doReads(kc, nextLocator)
}
<-make(chan struct{})
}
示例4: TestChecksum
func (s *StandaloneSuite) TestChecksum(c *C) {
foohash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
barhash := fmt.Sprintf("%x", md5.Sum([]byte("bar")))
st := BarHandler{make(chan string, 1)}
ks := RunFakeKeepServer(st)
defer ks.listener.Close()
arv, err := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
arv.ApiToken = "abc123"
kc.SetServiceRoots(map[string]string{"x": ks.url}, map[string]string{ks.url: ""}, nil)
r, n, _, err := kc.Get(barhash)
_, err = ioutil.ReadAll(r)
c.Check(n, Equals, int64(3))
c.Check(err, Equals, nil)
<-st.handled
r, n, _, err = kc.Get(foohash)
_, err = ioutil.ReadAll(r)
c.Check(n, Equals, int64(3))
c.Check(err, Equals, BadChecksum)
<-st.handled
}
示例5: TestGet
func (s *StandaloneSuite) TestGet(c *C) {
log.Printf("TestGet")
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubGetHandler{
c,
hash,
"abc123",
http.StatusOK,
[]byte("foo")}
ks := RunFakeKeepServer(st)
defer ks.listener.Close()
arv, err := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
arv.ApiToken = "abc123"
kc.SetServiceRoots(map[string]string{"x": ks.url}, map[string]string{ks.url: ""}, nil)
r, n, url2, err := kc.Get(hash)
defer r.Close()
c.Check(err, Equals, nil)
c.Check(n, Equals, int64(3))
c.Check(url2, Equals, fmt.Sprintf("%s/%s", ks.url, hash))
content, err2 := ioutil.ReadAll(r)
c.Check(err2, Equals, nil)
c.Check(content, DeepEquals, []byte("foo"))
log.Printf("TestGet done")
}
示例6: TestPutProxyInsufficientReplicas
func (s *StandaloneSuite) TestPutProxyInsufficientReplicas(c *C) {
log.Printf("TestPutProxy")
st := StubProxyHandler{make(chan string, 1)}
arv, err := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 3
kc.Using_proxy = true
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
ks1 := RunSomeFakeKeepServers(st, 1)
for i, k := range ks1 {
localRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
writableLocalRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
defer k.listener.Close()
}
kc.SetServiceRoots(localRoots, writableLocalRoots, nil)
_, replicas, err := kc.PutB([]byte("foo"))
<-st.handled
c.Check(err, Equals, InsufficientReplicasError)
c.Check(replicas, Equals, 2)
log.Printf("TestPutProxy done")
}
示例7: makeArvadosClient
func makeArvadosClient() arvadosclient.ArvadosClient {
arv, err := arvadosclient.MakeArvadosClient()
if err != nil {
log.Fatalf("Error setting up arvados client: %s", err)
}
return arv
}
示例8: TestPutBRetry
func (s *StandaloneSuite) TestPutBRetry(c *C) {
st := &FailThenSucceedPutHandler{make(chan string, 1), 0,
StubPutHandler{
c,
Md5String("foo"),
"abc123",
"foo",
make(chan string, 5)}}
arv, _ := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 2
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
ks := RunSomeFakeKeepServers(st, 2)
for i, k := range ks {
localRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
writableLocalRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
defer k.listener.Close()
}
kc.SetServiceRoots(localRoots, writableLocalRoots, nil)
hash, replicas, err := kc.PutB([]byte("foo"))
c.Check(err, Equals, nil)
c.Check(hash, Equals, "")
c.Check(replicas, Equals, 2)
}
示例9: TestPutBWithNoWritableLocalRoots
func (s *StandaloneSuite) TestPutBWithNoWritableLocalRoots(c *C) {
hash := Md5String("foo")
st := StubPutHandler{
c,
hash,
"abc123",
"foo",
make(chan string, 5)}
arv, _ := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 2
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
ks := RunSomeFakeKeepServers(st, 5)
for i, k := range ks {
localRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
defer k.listener.Close()
}
kc.SetServiceRoots(localRoots, writableLocalRoots, nil)
_, replicas, err := kc.PutB([]byte("foo"))
c.Check(err, Equals, InsufficientReplicasError)
c.Check(replicas, Equals, 0)
}
示例10: TestGetIndexWithPrefix
func (s *StandaloneSuite) TestGetIndexWithPrefix(c *C) {
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubGetIndexHandler{
c,
"/index/" + hash[0:3],
"abc123",
http.StatusOK,
[]byte(hash + "+3 1443559274\n\n")}
ks := RunFakeKeepServer(st)
defer ks.listener.Close()
arv, err := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
arv.ApiToken = "abc123"
kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
r, err := kc.GetIndex("x", hash[0:3])
c.Check(err, Equals, nil)
content, err2 := ioutil.ReadAll(r)
c.Check(err2, Equals, nil)
c.Check(content, DeepEquals, st.body[0:len(st.body)-1])
}
示例11: TestAskGetKeepProxyConnectionError
func (s *ServerRequiredSuite) TestAskGetKeepProxyConnectionError(c *C) {
arv, err := arvadosclient.MakeArvadosClient()
c.Assert(err, Equals, nil)
// keepclient with no such keep server
kc := keepclient.New(&arv)
locals := map[string]string{
TestProxyUUID: "http://localhost:12345",
}
kc.SetServiceRoots(locals, nil, nil)
// Ask should result in temporary connection refused error
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
_, _, err = kc.Ask(hash)
c.Check(err, NotNil)
errNotFound, _ := err.(*keepclient.ErrNotFound)
c.Check(errNotFound.Temporary(), Equals, true)
c.Assert(strings.Contains(err.Error(), "connection refused"), Equals, true)
// Get should result in temporary connection refused error
_, _, _, err = kc.Get(hash)
c.Check(err, NotNil)
errNotFound, _ = err.(*keepclient.ErrNotFound)
c.Check(errNotFound.Temporary(), Equals, true)
c.Assert(strings.Contains(err.Error(), "connection refused"), Equals, true)
}
示例12: test100BlockFile
func (s *IntegrationSuite) test100BlockFile(c *check.C, blocksize int) {
testdata := make([]byte, blocksize)
for i := 0; i < blocksize; i++ {
testdata[i] = byte(' ')
}
arv, err := arvadosclient.MakeArvadosClient()
c.Assert(err, check.Equals, nil)
arv.ApiToken = arvadostest.ActiveToken
kc, err := keepclient.MakeKeepClient(&arv)
c.Assert(err, check.Equals, nil)
loc, _, err := kc.PutB(testdata[:])
c.Assert(err, check.Equals, nil)
mtext := "."
for i := 0; i < 100; i++ {
mtext = mtext + " " + loc
}
mtext = mtext + fmt.Sprintf(" 0:%d00:testdata.bin\n", blocksize)
coll := map[string]interface{}{}
err = arv.Create("collections",
map[string]interface{}{
"collection": map[string]interface{}{
"name": fmt.Sprintf("testdata blocksize=%d", blocksize),
"manifest_text": mtext,
},
}, &coll)
c.Assert(err, check.Equals, nil)
uuid := coll["uuid"].(string)
hdr, body, size := s.runCurl(c, arv.ApiToken, uuid+".collections.example.com", "/testdata.bin")
c.Check(hdr, check.Matches, `(?s)HTTP/1.1 200 OK\r\n.*`)
c.Check(hdr, check.Matches, `(?si).*Content-length: `+fmt.Sprintf("%d00", blocksize)+`\r\n.*`)
c.Check([]byte(body)[:1234], check.DeepEquals, testdata[:1234])
c.Check(size, check.Equals, int64(blocksize)*100)
}
示例13: newArvadosClient
func newArvadosClient() interface{} {
arv, err := arvadosclient.MakeArvadosClient()
if err != nil {
log.Println("MakeArvadosClient:", err)
return nil
}
return &arv
}
示例14: TestPutWithFail
func (s *StandaloneSuite) TestPutWithFail(c *C) {
log.Printf("TestPutWithFail")
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubPutHandler{
c,
hash,
"abc123",
"foo",
make(chan string, 4)}
fh := FailHandler{
make(chan string, 1)}
arv, err := arvadosclient.MakeArvadosClient()
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 2
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
ks1 := RunSomeFakeKeepServers(st, 4)
ks2 := RunSomeFakeKeepServers(fh, 1)
for i, k := range ks1 {
localRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
writableLocalRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i)] = k.url
defer k.listener.Close()
}
for i, k := range ks2 {
localRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i+len(ks1))] = k.url
writableLocalRoots[fmt.Sprintf("zzzzz-bi6l4-fakefakefake%03d", i+len(ks1))] = k.url
defer k.listener.Close()
}
kc.SetServiceRoots(localRoots, writableLocalRoots, nil)
shuff := NewRootSorter(
kc.LocalRoots(), Md5String("foo")).GetSortedRoots()
phash, replicas, err := kc.PutB([]byte("foo"))
<-fh.handled
c.Check(err, Equals, nil)
c.Check(phash, Equals, "")
c.Check(replicas, Equals, 2)
s1 := <-st.handled
s2 := <-st.handled
c.Check((s1 == shuff[1] && s2 == shuff[2]) ||
(s1 == shuff[2] && s2 == shuff[1]),
Equals,
true)
}
示例15: RunTestPullWorker
// Since keepstore does not come into picture in tests,
// we need to explicitly start the goroutine in tests.
func RunTestPullWorker(c *C) {
arv, err := arvadosclient.MakeArvadosClient()
c.Assert(err, Equals, nil)
keepClient, err := keepclient.MakeKeepClient(&arv)
c.Assert(err, Equals, nil)
pullq = NewWorkQueue()
go RunPullWorker(pullq, keepClient)
}