diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-11-02 23:38:45 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-11-02 23:38:45 -0700 |
| commit | 5160eb08f7665409221ebb0b9db6f4820e29bed3 (patch) | |
| tree | f63464dd23ee0742bd96afe52826b477a775dc5e /weed/shell/shell_liner.go | |
| parent | 18bfbf62fcc64be380293ce797ab23f785c01760 (diff) | |
| download | seaweedfs-5160eb08f7665409221ebb0b9db6f4820e29bed3.tar.xz seaweedfs-5160eb08f7665409221ebb0b9db6f4820e29bed3.zip | |
shell: optionally read filer address from master
Diffstat (limited to 'weed/shell/shell_liner.go')
| -rw-r--r-- | weed/shell/shell_liner.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/shell/shell_liner.go b/weed/shell/shell_liner.go index db9e815ff..3cde1d237 100644 --- a/weed/shell/shell_liner.go +++ b/weed/shell/shell_liner.go @@ -3,9 +3,12 @@ package shell import ( "context" "fmt" + "github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" + "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/util/grace" "io" + "math/rand" "os" "path" "regexp" @@ -47,6 +50,27 @@ func RunShell(options ShellOptions) { go commandEnv.MasterClient.KeepConnectedToMaster() commandEnv.MasterClient.WaitUntilConnected() + if commandEnv.option.FilerAddress == "" { + var filers []pb.ServerAddress + commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error { + resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{ + ClientType: "filer", + }) + if err != nil { + return err + } + + for _, clusterNode := range resp.ClusterNodes { + filers = append(filers, pb.ServerAddress(clusterNode.Address)) + } + return nil + }) + if len(filers) > 0 { + fmt.Printf("filers: %v\n", filers) + commandEnv.option.FilerAddress = filers[rand.Intn(len(filers))] + } + } + if commandEnv.option.FilerAddress != "" { commandEnv.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error { resp, err := filerClient.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{}) |
