Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dragonflyoss/Dragonfly2 into featur…
Browse files Browse the repository at this point in the history
…e/charts
  • Loading branch information
gaius-qi committed Aug 11, 2021
2 parents 9b707ba + e04408f commit 4ff9527
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 4ff9527

Please sign in to comment.