Skip to content

Commit

Permalink
feat: manager
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi committed Aug 6, 2021
1 parent 854657c commit e14bde9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cdnsystem/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *Server) Serve() (err error) {
}

if s.managerClient != nil {
retry.Run(ctx, func() (interface{}, bool, error) {
go retry.Run(ctx, func() (interface{}, bool, error) {
if err := s.keepAlive(ctx); err != nil {
logger.Errorf("keepalive to manager failed %v", err)
return nil, false, err
Expand Down
2 changes: 2 additions & 0 deletions scheduler/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func NewDefaultDynConfig() *DynConfig {
func NewDefaultServerConfig() *ServerConfig {
return &ServerConfig{
IP: iputils.HostIP,
Host: iputils.HostName,
Port: 8002,
}
}
Expand Down Expand Up @@ -226,6 +227,7 @@ type SchedulerConfig struct {

type ServerConfig struct {
IP string `yaml:"ip" mapstructure:"ip"`
Host string `yaml:"host" mapstructure:"host"`
Port int `yaml:"port" mapstructure:"port"`
}

Expand Down
1 change: 1 addition & 0 deletions scheduler/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestSchedulerConfig_Load(t *testing.T) {
},
Server: &ServerConfig{
IP: "127.0.0.1",
Host: "foo",
Port: 8002,
},

Expand Down
3 changes: 2 additions & 1 deletion scheduler/config/testdata/scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ scheduler:

server:
ip: "127.0.0.1"
host: "foo"
port: 8002

cdn:
Expand Down Expand Up @@ -49,4 +50,4 @@ task:
port: 6379
password: "password"
brokerDB: 1
backendDB: 2
backendDB: 2
4 changes: 2 additions & 2 deletions scheduler/daemon/cdn/d7y/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func cdnHostsToNetAddrs(hosts []*config.CDN) []dfnet.NetAddr {
for i := range hosts {
netAddrs = append(netAddrs, dfnet.NetAddr{
Type: dfnet.TCP,
Addr: fmt.Sprintf("%s:%d", hosts[i].IP, hosts[i].Port),
Addr: fmt.Sprintf("%s:%d", hosts[i].HostName, hosts[i].Port),
})
}
return netAddrs
Expand Down Expand Up @@ -195,7 +195,7 @@ func (cm *manager) DownloadTinyFileContent(task *types.Task, cdnHost *types.Peer
// TODO download the tiny file
// http://host:port/download/{taskId 前3位}/{taskId}?peerId={peerId};
url := fmt.Sprintf("http://%s:%d/download/%s/%s?peerId=scheduler",
cdnHost.IP, cdnHost.DownloadPort, task.TaskID[:3], task.TaskID)
cdnHost.HostName, cdnHost.DownloadPort, task.TaskID[:3], task.TaskID)
response, err := http.Get(url)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion scheduler/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func (s *Server) Stop() (err error) {

func (s *Server) register(ctx context.Context) error {
ip := s.config.Server.IP
host := s.config.Server.Host
port := int32(s.config.Server.Port)
idc := s.config.Host.IDC
location := s.config.Host.Location
Expand All @@ -172,7 +173,7 @@ func (s *Server) register(ctx context.Context) error {
var err error
scheduler, err = s.managerClient.UpdateScheduler(ctx, &manager.UpdateSchedulerRequest{
SourceType: manager.SourceType_SCHEDULER_SOURCE,
HostName: iputils.HostName,
HostName: host,
Ip: ip,
Port: port,
Idc: idc,
Expand Down

0 comments on commit e14bde9

Please sign in to comment.