mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
remove initCache
This commit is contained in:
parent
431db4c1a3
commit
ff6b3fed97
1 changed files with 5 additions and 23 deletions
28
api.go
28
api.go
|
|
@ -959,28 +959,6 @@ func (api *API) Usage(ctx context.Context, remote bool) (map[string]NodeUsage, e
|
|||
return api.usageCache.data, nil
|
||||
}
|
||||
|
||||
func (api *API) initUsageCache(refresh int) {
|
||||
api.usageCache = &usageCache{
|
||||
data: make(map[string]NodeUsage),
|
||||
refreshRateMins: refresh,
|
||||
}
|
||||
|
||||
api.usageCache.data[api.server.nodeID] = NodeUsage{
|
||||
Disk: DiskUsage{
|
||||
IndexUsage: make(map[string]IndexUsage),
|
||||
},
|
||||
}
|
||||
|
||||
nodes := api.cluster.Nodes()
|
||||
for _, node := range nodes {
|
||||
api.usageCache.data[node.ID] = NodeUsage{
|
||||
Disk: DiskUsage{
|
||||
IndexUsage: make(map[string]IndexUsage),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (api *API) calculateNodeUsage(ctx context.Context) {
|
||||
nodes := api.cluster.Nodes()
|
||||
for _, node := range nodes {
|
||||
|
|
@ -1005,6 +983,7 @@ func (api *API) calculateUsage() {
|
|||
return
|
||||
} else {
|
||||
fmt.Printf("RefreshRate, expired: time: %v, current time: %v \n", api.usageCache.lastUpdated, time.Now())
|
||||
api.usageCache.data = make(map[string]NodeUsage)
|
||||
|
||||
indexDetails, nodeMetadataBytes, err := api.holder.Txf().IndexUsageDetails()
|
||||
if err != nil {
|
||||
|
|
@ -1053,7 +1032,10 @@ func (api *API) calculateUsage() {
|
|||
|
||||
// Periodically calculates disk usage
|
||||
func (api *API) RefreshUsageCache(refresh int) {
|
||||
api.initUsageCache(refresh)
|
||||
api.usageCache = &usageCache{
|
||||
data: make(map[string]NodeUsage),
|
||||
refreshRateMins: refresh,
|
||||
}
|
||||
for {
|
||||
api.calculateUsage()
|
||||
time.Sleep(time.Duration(api.usageCache.refreshRateMins) * time.Minute)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue