aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/commands.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/shell/commands.go')
-rw-r--r--weed/shell/commands.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/weed/shell/commands.go b/weed/shell/commands.go
index 5497e89cc..08f639d34 100644
--- a/weed/shell/commands.go
+++ b/weed/shell/commands.go
@@ -22,14 +22,15 @@ type ShellOptions struct {
// shell transient context
FilerHost string
FilerPort int64
- FilerAddress string
+ FilerGroup *string
+ FilerAddress pb.ServerAddress
Directory string
}
type CommandEnv struct {
env map[string]string
MasterClient *wdclient.MasterClient
- option ShellOptions
+ option *ShellOptions
locker *exclusive_locks.ExclusiveLocker
}
@@ -43,13 +44,13 @@ var (
Commands = []command{}
)
-func NewCommandEnv(options ShellOptions) *CommandEnv {
+func NewCommandEnv(options *ShellOptions) *CommandEnv {
ce := &CommandEnv{
env: make(map[string]string),
- MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, pb.AdminShellClient, "", 0, "", strings.Split(*options.Masters, ",")),
+ MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, *options.FilerGroup, pb.AdminShellClient, "", "", pb.ServerAddresses(*options.Masters).ToAddressMap()),
option: options,
}
- ce.locker = exclusive_locks.NewExclusiveLocker(ce.MasterClient)
+ ce.locker = exclusive_locks.NewExclusiveLocker(ce.MasterClient, "admin")
return ce
}
@@ -70,11 +71,12 @@ func (ce *CommandEnv) isDirectory(path string) bool {
}
-func (ce *CommandEnv) confirmIsLocked() error {
+func (ce *CommandEnv) confirmIsLocked(args []string) error {
if ce.locker.IsLocking() {
return nil
}
+ ce.locker.SetMessage(fmt.Sprintf("%v", args))
return fmt.Errorf("need to run \"lock\" first to continue")
@@ -96,10 +98,9 @@ func (ce *CommandEnv) checkDirectory(path string) error {
var _ = filer_pb.FilerClient(&CommandEnv{})
-func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
+func (ce *CommandEnv) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
- filerGrpcAddress := fmt.Sprintf("%s:%d", ce.option.FilerHost, ce.option.FilerPort+10000)
- return pb.WithGrpcFilerClient(filerGrpcAddress, ce.option.GrpcDialOption, fn)
+ return pb.WithGrpcFilerClient(streamingMode, ce.option.FilerAddress, ce.option.GrpcDialOption, fn)
}