-
Notifications
You must be signed in to change notification settings - Fork 21
/
allocation.go
54 lines (42 loc) · 1.05 KB
/
allocation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package command
import (
"flag"
"fmt"
"strings"
"github.com/funkygao/gafka/ctx"
"github.com/funkygao/gafka/zk"
"github.com/funkygao/gocli"
)
type Allocation struct {
Ui cli.Ui
Cmd string
}
func (this *Allocation) Run(args []string) (exitCode int) {
var (
zone string
cluster string
)
cmdFlags := flag.NewFlagSet("allocation", flag.ContinueOnError)
cmdFlags.Usage = func() { this.Ui.Output(this.Help()) }
cmdFlags.StringVar(&zone, "z", ctx.EsDefaultZone(), "")
cmdFlags.StringVar(&cluster, "c", "", "")
if err := cmdFlags.Parse(args); err != nil {
return 1
}
zkzone := zk.NewZkZone(zk.DefaultConfig(zone, ctx.ZoneZkAddrs(zone)))
handleCatCommand(this.Ui, zkzone, cluster, "allocation", "h=shards,disk.total,disk.used,ip,node")
return
}
func (*Allocation) Synopsis() string {
return "Display #shards and disk space used by data node"
}
func (this *Allocation) Help() string {
help := fmt.Sprintf(`
Usage: %s allocation [options]
%s
Options:
-z zone
-c cluster
`, this.Cmd, this.Synopsis())
return strings.TrimSpace(help)
}