aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/shell_liner.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/shell/shell_liner.go')
-rw-r--r--weed/shell/shell_liner.go24
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{})