[ARVADOS] updated: 30c9c2e679fe43d3a7d5e8770496beca4cf87282
Git user
git at public.curoverse.com
Wed May 25 10:24:29 EDT 2016
Summary of changes:
services/keep-balance/balance.go | 17 +++++++-
services/keep-balance/example-config.json | 17 --------
services/keep-balance/main.go | 9 +++--
services/keep-balance/usage.go | 66 +++++++++++++++++++++++++++++++
4 files changed, 87 insertions(+), 22 deletions(-)
delete mode 100644 services/keep-balance/example-config.json
create mode 100644 services/keep-balance/usage.go
via 30c9c2e679fe43d3a7d5e8770496beca4cf87282 (commit)
from 6e6a5f4005e7f7c3a41d632ed350f2da918cd01c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 30c9c2e679fe43d3a7d5e8770496beca4cf87282
Author: Tom Clegg <tom at curoverse.com>
Date: Wed May 25 10:23:55 2016 -0400
9162: Move example config to -help message, add more docs/comments
diff --git a/services/keep-balance/balance.go b/services/keep-balance/balance.go
index bbb4509..121dd7a 100644
--- a/services/keep-balance/balance.go
+++ b/services/keep-balance/balance.go
@@ -182,6 +182,8 @@ func (bal *Balancer) GetCurrentState(c *arvados.Client) error {
errs := make(chan error, 2+len(bal.KeepServices))
wg := sync.WaitGroup{}
+ // Start one goroutine for each KeepService: retrieve the
+ // index, and add the returned blocks to BlockStateMap.
for _, srv := range bal.KeepServices {
wg.Add(1)
go func(srv *KeepService) {
@@ -198,8 +200,16 @@ func (bal *Balancer) GetCurrentState(c *arvados.Client) error {
}(srv)
}
+ // collQ buffers incoming collections so we can start fetching
+ // the next page without waiting for the current page to
+ // finish processing. (1000 happens to match the page size
+ // used by (*arvados.Client)EachCollection(), but it's OK if
+ // they don't match.)
collQ := make(chan arvados.Collection, 1000)
+ // Start a goroutine to process collections. (We could use a
+ // worker pool here, but even with a single worker we already
+ // process collections much faster than we can retrieve them.)
wg.Add(1)
go func() {
defer wg.Done()
@@ -215,6 +225,8 @@ func (bal *Balancer) GetCurrentState(c *arvados.Client) error {
}
}()
+ // Start a goroutine to retrieve all collections from the
+ // Arvados database and send them to collQ for processing.
wg.Add(1)
go func() {
defer wg.Done()
@@ -281,9 +293,10 @@ func (bal *Balancer) ComputeChangeSets() {
blkid arvados.SizedDigest
blk *BlockState
}
- todo := make(chan balanceTask, 16)
+ nWorkers := 1 + runtime.NumCPU()
+ todo := make(chan balanceTask, nWorkers)
var wg sync.WaitGroup
- for i := 0; i < 1+runtime.NumCPU(); i++ {
+ for i := 0; i < nWorkers; i++ {
wg.Add(1)
go func() {
for work := range todo {
diff --git a/services/keep-balance/example-config.json b/services/keep-balance/example-config.json
deleted file mode 100644
index 4f47219..0000000
--- a/services/keep-balance/example-config.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "Client": {
- "APIHost": "4xphq.arvadosapi.com:443",
- "AuthToken": "zzzzzz",
- "Insecure": false
- },
- "RunPeriod": "600s",
- "KeepServiceTypes": [
- "disk"
- ]
- "KeepServiceList": {
- "items": [
- {"uuid":"zzzzz-bi6l4-0123456789abcdef","service_host":"keep0.zzzzz.arvadosapi.com","service_port":25107},
- {"uuid":"zzzzz-bi6l4-123456789abcdef0","service_host":"keep1.zzzzz.arvadosapi.com","service_port":25107}
- ]
- }
-}
diff --git a/services/keep-balance/main.go b/services/keep-balance/main.go
index c6e92ab..607ba87 100644
--- a/services/keep-balance/main.go
+++ b/services/keep-balance/main.go
@@ -48,22 +48,25 @@ func main() {
var config Config
var runOptions RunOptions
- configPath := flag.String("config",
- os.Getenv("HOME")+"/.config/arvados/keep-balance.json",
+ configPath := flag.String("config", "",
"`path` of json configuration file")
serviceListPath := flag.String("config.KeepServiceList", "",
"`path` of json file with list of keep services to balance, as given by \"arv keep_service list\" "+
"(default: config[\"KeepServiceList\"], or if none given, get all available services and filter by config[\"KeepServiceTypes\"])")
once := flag.Bool("once", false,
- "balance once and then exit, instead of balancing on a timer (config[\"RunPeriod\"]) and SIGUSR1")
+ "balance once and then exit")
flag.BoolVar(&runOptions.CommitPulls, "commit-pulls", false,
"send pull requests (make more replicas of blocks that are underreplicated or are not in optimal rendezvous probe order)")
flag.BoolVar(&runOptions.CommitTrash, "commit-trash", false,
"send trash requests (delete unreferenced old blocks, and excess replicas of overreplicated blocks)")
dumpFlag := flag.Bool("dump", false, "dump details for each block to stdout")
debugFlag := flag.Bool("debug", false, "enable debug messages")
+ flag.Usage = usage
flag.Parse()
+ if *configPath == "" {
+ log.Fatal("You must specify a config file (see `keep-balance -help`)")
+ }
mustReadJSON(&config, *configPath)
if *serviceListPath != "" {
mustReadJSON(&config.KeepServiceList, *serviceListPath)
diff --git a/services/keep-balance/usage.go b/services/keep-balance/usage.go
new file mode 100644
index 0000000..fab7d09
--- /dev/null
+++ b/services/keep-balance/usage.go
@@ -0,0 +1,66 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+)
+
+func usage() {
+ fmt.Fprintf(os.Stderr, `
+keep-balance copies blocks to better positions so clients find them
+faster, and deletes excess copies of overreplicated and unreferenced
+blocks.
+
+Usage: keep-balance -config path/to/config.json [options]
+
+Options:
+`)
+ flag.PrintDefaults()
+ fmt.Fprintf(os.Stderr, `
+Example config file:
+
+ {
+ "Client": {
+ "APIHost": "zzzzz.arvadosapi.com:443",
+ "AuthToken": "xyzzy",
+ "Insecure": false
+ },
+ "KeepServiceTypes": [
+ "disk"
+ ],
+ "RunPeriod": "600s"
+ }
+
+ Client.AuthToken must be recognized by Arvados as an admin token,
+ and must be recognized by all Keep services as a "data manager
+ key".
+
+ Client.Insecure should be true if your Arvados API endpoint uses
+ an unverifiable SSL/TLS certificate.
+
+Service mode:
+
+ By default, keep-balance runs in service mode: do a balance
+ operation, sleep, repeat.
+
+ RunPeriod determines the interval between start times of
+ successive balance operations. If a balance operation takes longer
+ than RunPeriod, the next one will follow it immediately.
+
+ If SIGUSR1 is received during an idle period between operations,
+ the next operation will start immediately.
+
+ Use the -once flag to do a single operation and then exit. The
+ exit code will be zero if the operation was successful.
+
+Committing:
+
+ By default, keep-service computes and reports changes but does not
+ implement them by sending pull and trash lists to the Keep
+ services.
+
+ Use the -commit-pull and -commit-trash flags to implement the
+ computed changes.
+
+`) }
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list