mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
weed filer: set grpc port to port + 10000
This commit is contained in:
parent
916b809c08
commit
da871896c3
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
type MountOptions struct {
|
||||
filer *string
|
||||
filerGrpcPort *int
|
||||
filerMountRootPath *string
|
||||
dir *string
|
||||
dirListingLimit *int
|
||||
|
@ -29,7 +28,6 @@ var (
|
|||
func init() {
|
||||
cmdMount.Run = runMount // break init cycle
|
||||
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
|
||||
mountOptions.filerGrpcPort = cmdMount.Flag.Int("filer.grpc.port", 0, "filer grpc server listen port, default to http port + 10000")
|
||||
mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
|
||||
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
|
||||
mountOptions.dirListingLimit = cmdMount.Flag.Int("dirListLimit", 100000, "limit directory listing size")
|
||||
|
@ -61,7 +59,7 @@ var cmdMount = &Command{
|
|||
`,
|
||||
}
|
||||
|
||||
func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress string, err error) {
|
||||
func parseFilerGrpcAddress(filer string) (filerGrpcAddress string, err error) {
|
||||
hostnameAndPort := strings.Split(filer, ":")
|
||||
if len(hostnameAndPort) != 2 {
|
||||
return "", fmt.Errorf("The filer should have hostname:port format: %v", hostnameAndPort)
|
||||
|
@ -73,9 +71,6 @@ func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress
|
|||
}
|
||||
|
||||
filerGrpcPort := int(filerPort) + 10000
|
||||
if optionalGrpcPort != 0 {
|
||||
filerGrpcPort = optionalGrpcPort
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%d", hostnameAndPort[0], filerGrpcPort), nil
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ func runMount(cmd *Command, args []string) bool {
|
|||
c.Close()
|
||||
})
|
||||
|
||||
filerGrpcAddress, err := parseFilerGrpcAddress(*mountOptions.filer, *mountOptions.filerGrpcPort)
|
||||
filerGrpcAddress, err := parseFilerGrpcAddress(*mountOptions.filer)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
return false
|
||||
|
|
|
@ -51,7 +51,7 @@ func runS3(cmd *Command, args []string) bool {
|
|||
|
||||
weed_server.LoadConfiguration("security", false)
|
||||
|
||||
filerGrpcAddress, err := parseFilerGrpcAddress(*s3options.filer, *s3options.filerGrpcPort)
|
||||
filerGrpcAddress, err := parseFilerGrpcAddress(*s3options.filer)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
return false
|
||||
|
|
|
@ -42,7 +42,7 @@ func withMasterServerClient(masterServer string, grpcDialOption grpc.DialOption,
|
|||
|
||||
ctx := context.Background()
|
||||
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(masterServer, 0)
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(masterServer)
|
||||
if parseErr != nil {
|
||||
return fmt.Errorf("failed to parse master grpc %v", masterServer)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func NewRaftServer(grpcDialOption grpc.DialOption, peers []string, serverAddr st
|
|||
s.raftServer.Start()
|
||||
|
||||
for _, peer := range s.peers {
|
||||
s.raftServer.AddPeer(peer, util.ServerToGrpcAddress(peer, 19333))
|
||||
s.raftServer.AddPeer(peer, util.ServerToGrpcAddress(peer))
|
||||
}
|
||||
|
||||
s.GrpcServer = raft.NewGrpcServer(s.raftServer)
|
||||
|
@ -72,7 +72,7 @@ func NewRaftServer(grpcDialOption grpc.DialOption, peers []string, serverAddr st
|
|||
|
||||
_, err := s.raftServer.Do(&raft.DefaultJoinCommand{
|
||||
Name: s.raftServer.Name(),
|
||||
ConnectionString: util.ServerToGrpcAddress(s.serverAddr, 19333),
|
||||
ConnectionString: util.ServerToGrpcAddress(s.serverAddr),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,7 @@ func (vs *VolumeServer) heartbeat() {
|
|||
if newLeader != "" {
|
||||
master = newLeader
|
||||
}
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master, 0)
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master)
|
||||
if parseErr != nil {
|
||||
glog.V(0).Infof("failed to parse master grpc %v", masterGrpcAddress)
|
||||
continue
|
||||
|
|
|
@ -335,7 +335,7 @@ func (v *Volume) copyDataBasedOnIndexFile(dstName, idxName string) (err error) {
|
|||
}
|
||||
|
||||
n := new(Needle)
|
||||
err :=n.ReadData(v.dataFile, int64(offset)*NeedlePaddingSize, size, v.Version())
|
||||
err := n.ReadData(v.dataFile, int64(offset)*NeedlePaddingSize, size, v.Version())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error,
|
|||
return err
|
||||
}
|
||||
|
||||
func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAddress string, err error) {
|
||||
func ParseServerToGrpcAddress(server string) (serverGrpcAddress string, err error) {
|
||||
hostnameAndPort := strings.Split(server, ":")
|
||||
if len(hostnameAndPort) != 2 {
|
||||
return "", fmt.Errorf("server should have hostname:port format: %v", hostnameAndPort)
|
||||
|
@ -93,22 +93,19 @@ func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAd
|
|||
}
|
||||
|
||||
grpcPort := int(port) + 10000
|
||||
if optionalGrpcPort != 0 {
|
||||
grpcPort = optionalGrpcPort
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%d", hostnameAndPort[0], grpcPort), nil
|
||||
}
|
||||
|
||||
func ServerToGrpcAddress(server string, defaultGrpcPort int) (serverGrpcAddress string) {
|
||||
func ServerToGrpcAddress(server string) (serverGrpcAddress string) {
|
||||
hostnameAndPort := strings.Split(server, ":")
|
||||
if len(hostnameAndPort) != 2 {
|
||||
return fmt.Sprintf("%s:%d", server, defaultGrpcPort)
|
||||
return fmt.Sprintf("unexpected server address: %s", server)
|
||||
}
|
||||
|
||||
port, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64)
|
||||
if parseErr != nil {
|
||||
return fmt.Sprintf("%s:%d", hostnameAndPort[0], defaultGrpcPort)
|
||||
return fmt.Sprintf("failed to parse port for %s:%s", hostnameAndPort[0], hostnameAndPort[1])
|
||||
}
|
||||
|
||||
grpcPort := int(port) + 10000
|
||||
|
|
|
@ -101,7 +101,7 @@ func (mc *MasterClient) tryAllMasters() {
|
|||
|
||||
func withMasterClient(ctx context.Context, master string, grpcDialOption grpc.DialOption, fn func(ctx context.Context, client master_pb.SeaweedClient) error) error {
|
||||
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master, 0)
|
||||
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master)
|
||||
if parseErr != nil {
|
||||
return fmt.Errorf("failed to parse master grpc %v", master)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue