resource_analyzer.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package stats
  14. import (
  15. "time"
  16. "k8s.io/kubernetes/pkg/kubelet/container"
  17. )
  18. // ResourceAnalyzer provides statistics on node resource consumption
  19. type ResourceAnalyzer interface {
  20. Start()
  21. fsResourceAnalyzerInterface
  22. SummaryProvider
  23. }
  24. // resourceAnalyzer implements ResourceAnalyzer
  25. type resourceAnalyzer struct {
  26. *fsResourceAnalyzer
  27. SummaryProvider
  28. }
  29. var _ ResourceAnalyzer = &resourceAnalyzer{}
  30. // NewResourceAnalyzer returns a new ResourceAnalyzer
  31. func NewResourceAnalyzer(statsProvider StatsProvider, calVolumeFrequency time.Duration, runtime container.Runtime) ResourceAnalyzer {
  32. fsAnalyzer := newFsResourceAnalyzer(statsProvider, calVolumeFrequency)
  33. summaryProvider := NewSummaryProvider(statsProvider, fsAnalyzer, runtime)
  34. return &resourceAnalyzer{fsAnalyzer, summaryProvider}
  35. }
  36. // Start starts background functions necessary for the ResourceAnalyzer to function
  37. func (ra *resourceAnalyzer) Start() {
  38. ra.fsResourceAnalyzer.Start()
  39. }