From e8b9fa0482266f26eb63c14b512f0fc60f062bd3 Mon Sep 17 00:00:00 2001 From: Samir Patel Date: Tue, 25 May 2021 22:36:50 -0500 Subject: [PATCH] update comments and rename nodeUsage() --- api.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api.go b/api.go index 4ac463a4f..e0ad9b6d2 100644 --- a/api.go +++ b/api.go @@ -941,7 +941,6 @@ type MemoryUsage struct { TotalUse uint64 `json:"totalInUse"` } -// Usage gets the resource usage per index, in a map[nodeID]NodeUsage // Returns disk usage from cache. Waits for calculation if cache is empty. func (api *API) Usage(ctx context.Context, remote bool) (map[string]NodeUsage, error) { span, _ := tracing.StartSpanFromContext(ctx, "API.Usage") @@ -956,8 +955,8 @@ func (api *API) Usage(ctx context.Context, remote bool) (map[string]NodeUsage, e return api.usageCache.data, nil } -// Calculate node usage for each node in cluster -func (api *API) calculateNodeUsage() { +// Makes a ui/usage request for each node in cluster to calculates its usage and adds it to the cache +func (api *API) requestUsageOfNodes() { nodes := api.cluster.Nodes() for _, node := range nodes { if node.ID == api.server.nodeID { @@ -1037,7 +1036,7 @@ func (api *API) RefreshUsageCache(refresh time.Duration) { } for { api.calculateUsage() - api.calculateNodeUsage() + api.requestUsageOfNodes() time.Sleep(api.usageCache.refreshInterval) } }