Simplify access to local node name (#11907)

The local node name is heavily used in tracing, create a new global 
variable to store it. Multiple goroutines can access it since it won't be
changed later.
This commit is contained in:
Anis Elleuch
2021-03-26 19:37:58 +01:00
committed by GitHub
parent 9efcb9e15c
commit 2c296652f7
16 changed files with 48 additions and 53 deletions

View File

@@ -354,7 +354,7 @@ func (sys *NotificationSys) DownloadProfilingData(ctx context.Context, writer io
}
// Local host
thisAddr, err := xnet.ParseHost(GetLocalPeer(globalEndpoints))
thisAddr, err := xnet.ParseHost(globalLocalNodeName)
if err != nil {
logger.LogIf(ctx, err)
return profilingDataFound
@@ -889,7 +889,7 @@ func (sys *NotificationSys) NetInfo(ctx context.Context) madmin.ServerNetHealthI
}
for i := 0; i < len(sortedGlobalEndpoints); i++ {
if sortedGlobalEndpoints[i] != GetLocalPeer(globalEndpoints) {
if sortedGlobalEndpoints[i] != globalLocalNodeName {
continue
}
for j := 0; j < len(sortedGlobalEndpoints); j++ {
@@ -922,7 +922,7 @@ func (sys *NotificationSys) NetInfo(ctx context.Context) madmin.ServerNetHealthI
}
return madmin.ServerNetHealthInfo{
Net: netInfos,
Addr: GetLocalPeer(globalEndpoints),
Addr: globalLocalNodeName,
}
}
@@ -997,7 +997,7 @@ func (sys *NotificationSys) NetPerfParallelInfo(ctx context.Context) madmin.Serv
wg.Wait()
return madmin.ServerNetHealthInfo{
Net: netInfos,
Addr: GetLocalPeer(globalEndpoints),
Addr: globalLocalNodeName,
}
}