mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring
This commit is contained in:
parent
b062393f3f
commit
8e23dc078b
5
weed/pb/shared_values.go
Normal file
5
weed/pb/shared_values.go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package pb
|
||||||
|
|
||||||
|
const (
|
||||||
|
AdminShellClient = "shell"
|
||||||
|
)
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"google.golang.org/grpc/peer"
|
"google.golang.org/grpc/peer"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||||
|
@ -191,8 +192,8 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
|
||||||
peerAddress := findClientAddress(stream.Context(), req.GrpcPort)
|
peerAddress := findClientAddress(stream.Context(), req.GrpcPort)
|
||||||
|
|
||||||
// only one shell can be connected at any time
|
// only one shell can be connected at any time
|
||||||
if req.Name == "shell" {
|
if req.Name == pb.AdminShellClient {
|
||||||
if ms.currentAdminShellClient == ""{
|
if ms.currentAdminShellClient == "" {
|
||||||
ms.currentAdminShellClient = peerAddress
|
ms.currentAdminShellClient = peerAddress
|
||||||
defer func() {
|
defer func() {
|
||||||
ms.currentAdminShellClient = ""
|
ms.currentAdminShellClient = ""
|
||||||
|
@ -202,7 +203,6 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stopChan := make(chan bool)
|
stopChan := make(chan bool)
|
||||||
|
|
||||||
clientName, messageChan := ms.addClient(req.Name, peerAddress)
|
clientName, messageChan := ms.addClient(req.Name, peerAddress)
|
||||||
|
|
|
@ -43,7 +43,7 @@ var (
|
||||||
func NewCommandEnv(options ShellOptions) *CommandEnv {
|
func NewCommandEnv(options ShellOptions) *CommandEnv {
|
||||||
return &CommandEnv{
|
return &CommandEnv{
|
||||||
env: make(map[string]string),
|
env: make(map[string]string),
|
||||||
MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, "shell", 0, strings.Split(*options.Masters, ",")),
|
MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, pb.AdminShellClient, 0, strings.Split(*options.Masters, ",")),
|
||||||
option: options,
|
option: options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue