Moved Keep code to its own package.
[arvados.git] / services / datamanager / datamanager.go
1 /* Keep Datamanager. Responsible for checking on and reporting on Keep Storage */
2
3 package main
4
5 import (
6         //"git.curoverse.com/arvados.git/sdk/go/keepclient"
7         "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
8         "git.curoverse.com/arvados.git/sdk/go/util"
9         "git.curoverse.com/arvados.git/services/datamanager/collection"
10         "git.curoverse.com/arvados.git/services/datamanager/keep"
11         "log"
12 )
13
14 // Helper type so we don't have to write out 'map[string]interface{}' every time.
15 type Dict map[string]interface{}
16
17 func main() {
18         arv, err := arvadosclient.MakeArvadosClient()
19         if err != nil {
20                 log.Fatalf("Error setting up arvados client %s", err.Error())
21         }
22
23         if is_admin, err := util.UserIsAdmin(arv); err != nil {
24                 log.Fatalf("Error querying current arvados user %s", err.Error())
25         } else if !is_admin {
26                 log.Fatalf("Current user is not an admin. Datamanager can only be run by admins.")
27         }
28
29         readCollections := collection.GetCollections(
30                 collection.GetCollectionsParams{
31                         Client: arv, Limit: 50, LogEveryNthCollectionProcessed: 10})
32
33         //log.Printf("Read Collections: %v", readCollections)
34
35         // TODO(misha): Add a "readonly" flag. If we're in readonly mode,
36         // lots of behaviors can become warnings (and obviously we can't
37         // write anything).
38         // if !readCollections.ReadAllCollections {
39         //      log.Fatalf("Did not read all collections")
40         // }
41
42         log.Printf("Read and processed %d collections",
43                 len(readCollections.UuidToCollection))
44
45         readServers := keep.GetKeepServers(
46                 keep.GetKeepServersParams{Client: arv, Limit: 1000})
47
48         log.Printf("Returned %d keep disks", len(readServers.AddressToContents))
49 }