Skip to content

Commit

Permalink
feat: update cdn host (#530)
Browse files Browse the repository at this point in the history
Signed-off-by: santong <weipeng.swp@alibaba-inc.com>
  • Loading branch information
244372610 committed Aug 11, 2021
1 parent 9a0d057 commit e04408f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.14.0
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pborman/uuid v1.2.1
github.com/pelletier/go-toml v1.8.1 // indirect
Expand Down
10 changes: 1 addition & 9 deletions scheduler/daemon/host/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,10 @@ func (m *manager) Get(uuid string) (*types.PeerHost, bool) {
return host.(*types.PeerHost), true
}

func (m *manager) GetOrAdd(host *types.PeerHost) (actual *types.PeerHost, loaded bool) {
item, loaded := m.hostMap.LoadOrStore(host.UUID, host)
if loaded {
return item.(*types.PeerHost), true
}
return host, false
}

func (m *manager) OnNotify(dynconfig *config.DynconfigData) {
for _, cdn := range dynconfig.CDNs {
cdnHost := types.NewCDNPeerHost(idgen.CDNUUID(cdn.HostName, cdn.Port), cdn.IP, cdn.HostName, cdn.Port, cdn.DownloadPort, cdn.SecurityGroup,
cdn.Location, cdn.IDC, cdn.NetTopology, 100)
m.GetOrAdd(cdnHost)
m.hostMap.Store(cdnHost.UUID, cdnHost)
}
}
5 changes: 0 additions & 5 deletions scheduler/daemon/host_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ type HostMgr interface {

Add(host *types.PeerHost)

// GetOrAdd returns the existing value for the key if present.
// Otherwise, it stores and returns the given value.
// The loaded result is true if the value was loaded, false if stored.
GetOrAdd(host *types.PeerHost) (actual *types.PeerHost, loaded bool)

Delete(uuid string)

Get(uuid string) (*types.PeerHost, bool)
Expand Down

0 comments on commit e04408f

Please sign in to comment.