Added the stats collector to GC
This commit is contained in:
parent
e855cd587b
commit
7aef9bcabe
|
@ -177,6 +177,8 @@ func NewClient(cfg *config.Config, consulSyncer *consul.Syncer, logger *log.Logg
|
|||
tlsWrap = tw
|
||||
}
|
||||
|
||||
statsCollector := stats.NewHostStatsCollector(logger)
|
||||
|
||||
// Create the client
|
||||
c := &Client{
|
||||
config: cfg,
|
||||
|
@ -184,7 +186,7 @@ func NewClient(cfg *config.Config, consulSyncer *consul.Syncer, logger *log.Logg
|
|||
start: time.Now(),
|
||||
connPool: nomad.NewPool(cfg.LogOutput, clientRPCCache, clientMaxStreams, tlsWrap),
|
||||
logger: logger,
|
||||
hostStatsCollector: stats.NewHostStatsCollector(logger),
|
||||
hostStatsCollector: statsCollector,
|
||||
allocs: make(map[string]*AllocRunner),
|
||||
blockedAllocations: make(map[string]*structs.Allocation),
|
||||
allocUpdates: make(chan *structs.Allocation, 64),
|
||||
|
@ -193,7 +195,7 @@ func NewClient(cfg *config.Config, consulSyncer *consul.Syncer, logger *log.Logg
|
|||
servers: newServerList(),
|
||||
triggerDiscoveryCh: make(chan struct{}),
|
||||
serversDiscoveredCh: make(chan struct{}),
|
||||
garbageCollector: NewAllocGarbageCollector(logger),
|
||||
garbageCollector: NewAllocGarbageCollector(logger, statsCollector),
|
||||
}
|
||||
|
||||
// Initialize the client
|
||||
|
|
15
client/gc.go
15
client/gc.go
|
@ -7,6 +7,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/client/stats"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
|
@ -102,17 +103,19 @@ func (i *IndexedGCAllocPQ) Length() int {
|
|||
|
||||
// AllocGarbageCollector garbage collects terminated allocations on a node
|
||||
type AllocGarbageCollector struct {
|
||||
allocRunners *IndexedGCAllocPQ
|
||||
allocsLock sync.Mutex
|
||||
logger *log.Logger
|
||||
allocRunners *IndexedGCAllocPQ
|
||||
allocsLock sync.Mutex
|
||||
statsCollector *stats.HostStatsCollector
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
// NewAllocGarbageCollector returns a garbage collector for terminated
|
||||
// allocations on a node.
|
||||
func NewAllocGarbageCollector(logger *log.Logger) *AllocGarbageCollector {
|
||||
func NewAllocGarbageCollector(logger *log.Logger, statsCollector *stats.HostStatsCollector) *AllocGarbageCollector {
|
||||
return &AllocGarbageCollector{
|
||||
allocRunners: NewIndexedGCAllocPQ(),
|
||||
logger: logger,
|
||||
allocRunners: NewIndexedGCAllocPQ(),
|
||||
statsCollector: statsCollector,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue