metacache

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvisorNotifier added in v0.3.0

type AdvisorNotifier struct{}

type MetaCache

type MetaCache interface {
	MetaReader
	MetaWriter
}

type MetaCacheCheckpoint

type MetaCacheCheckpoint struct {
	PodEntries    types.PodEntries    `json:"pod_entries"`
	PoolEntries   types.PoolEntries   `json:"pool_entries"`
	RegionEntries types.RegionEntries `json:"region_entries"`
	Checksum      checksum.Checksum   `json:"checksum"`
}

func NewMetaCacheCheckpoint

func NewMetaCacheCheckpoint() *MetaCacheCheckpoint

func (*MetaCacheCheckpoint) MarshalCheckpoint

func (cp *MetaCacheCheckpoint) MarshalCheckpoint() ([]byte, error)

MarshalCheckpoint returns marshaled checkpoint

func (*MetaCacheCheckpoint) UnmarshalCheckpoint

func (cp *MetaCacheCheckpoint) UnmarshalCheckpoint(blob []byte) error

UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint

func (*MetaCacheCheckpoint) VerifyChecksum

func (cp *MetaCacheCheckpoint) VerifyChecksum() error

VerifyChecksum verifies that current checksum of checkpoint is valid

type MetaCacheImp added in v0.2.0

type MetaCacheImp struct {
	metrictypes.MetricsReader
	// contains filtered or unexported fields
}

MetaCacheImp stores metadata and info of pod, node, pool, subnuma etc. as a cache, and synchronizes data to sysadvisor state file. It is thread-safe to read and write. Deep copy logic is performed during accessing metacache entries instead of directly return pointer of each struct to avoid mis-overwrite.

func NewMetaCacheImp added in v0.2.0

func NewMetaCacheImp(conf *config.Configuration, emitterPool metricspool.MetricsEmitterPool, metricsReader metrictypes.MetricsReader) (*MetaCacheImp, error)

NewMetaCacheImp returns the single instance of MetaCacheImp

func (*MetaCacheImp) AddContainer added in v0.2.0

func (mc *MetaCacheImp) AddContainer(podUID string, containerName string, containerInfo *types.ContainerInfo) error

func (*MetaCacheImp) ClearContainers added in v0.4.0

func (mc *MetaCacheImp) ClearContainers() error

func (*MetaCacheImp) DeleteContainer added in v0.2.0

func (mc *MetaCacheImp) DeleteContainer(podUID string, containerName string) error

func (*MetaCacheImp) DeletePool added in v0.2.0

func (mc *MetaCacheImp) DeletePool(poolName string) error

func (*MetaCacheImp) GCPoolEntries added in v0.2.0

func (mc *MetaCacheImp) GCPoolEntries(livingPoolNameSet sets.String) error

func (*MetaCacheImp) GetContainerEntries added in v0.2.0

func (mc *MetaCacheImp) GetContainerEntries(podUID string) (types.ContainerEntries, bool)

func (*MetaCacheImp) GetContainerInfo added in v0.2.0

func (mc *MetaCacheImp) GetContainerInfo(podUID string, containerName string) (*types.ContainerInfo, bool)

func (*MetaCacheImp) GetFilteredInferenceResult added in v0.4.0

func (mc *MetaCacheImp) GetFilteredInferenceResult(filterFunc func(result interface{}) (interface{}, error),
	modelName string) (interface{}, error)

GetFilteredInferenceResult gets specified model inference result with filter function whether it returns a deep copied result depends on the implementation of filterFunc

func (*MetaCacheImp) GetInferenceResult added in v0.4.0

func (mc *MetaCacheImp) GetInferenceResult(modelName string) (interface{}, error)

GetInferenceResult gets specified model inference result notice it doesn't return a deep copied result

func (*MetaCacheImp) GetPoolInfo added in v0.2.0

func (mc *MetaCacheImp) GetPoolInfo(poolName string) (*types.PoolInfo, bool)

func (*MetaCacheImp) GetPoolSize added in v0.2.0

func (mc *MetaCacheImp) GetPoolSize(poolName string) (int, bool)

func (*MetaCacheImp) GetRegionInfo added in v0.2.0

func (mc *MetaCacheImp) GetRegionInfo(regionName string) (*types.RegionInfo, bool)

func (*MetaCacheImp) RangeAndDeleteContainer added in v0.2.0

func (mc *MetaCacheImp) RangeAndDeleteContainer(f func(containerInfo *types.ContainerInfo) bool, safeTime int64) error

func (*MetaCacheImp) RangeAndUpdateContainer added in v0.2.0

func (mc *MetaCacheImp) RangeAndUpdateContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool) error

func (*MetaCacheImp) RangeContainer added in v0.2.0

func (mc *MetaCacheImp) RangeContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool)

RangeContainer should deepcopy so that pod and container entries will not be overwritten.

func (*MetaCacheImp) RangeRegionInfo added in v0.2.0

func (mc *MetaCacheImp) RangeRegionInfo(f func(regionName string, regionInfo *types.RegionInfo) bool)

func (*MetaCacheImp) RemovePod added in v0.2.0

func (mc *MetaCacheImp) RemovePod(podUID string) error

func (*MetaCacheImp) SetContainerInfo added in v0.2.0

func (mc *MetaCacheImp) SetContainerInfo(podUID string, containerName string, containerInfo *types.ContainerInfo) error

func (*MetaCacheImp) SetInferenceResult added in v0.4.0

func (mc *MetaCacheImp) SetInferenceResult(modelName string, result interface{}) error

SetInferenceResult sets specified model inference result

func (*MetaCacheImp) SetPoolInfo added in v0.2.0

func (mc *MetaCacheImp) SetPoolInfo(poolName string, poolInfo *types.PoolInfo) error

func (*MetaCacheImp) SetRegionEntries added in v0.2.0

func (mc *MetaCacheImp) SetRegionEntries(entries types.RegionEntries) error

func (*MetaCacheImp) SetRegionInfo added in v0.2.0

func (mc *MetaCacheImp) SetRegionInfo(regionName string, regionInfo *types.RegionInfo) error

type MetaReader added in v0.2.0

type MetaReader interface {
	// GetContainerEntries returns a ContainerEntry copy keyed by pod uid
	GetContainerEntries(podUID string) (types.ContainerEntries, bool)
	// GetContainerInfo returns a ContainerInfo copy keyed by pod uid and container name
	GetContainerInfo(podUID string, containerName string) (*types.ContainerInfo, bool)
	// RangeContainer applies a function to every podUID, containerName, containerInfo set
	RangeContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool)

	// GetPoolInfo returns a PoolInfo copy by pool name
	GetPoolInfo(poolName string) (*types.PoolInfo, bool)
	// GetPoolSize returns the size of pool as integer
	GetPoolSize(poolName string) (int, bool)

	// GetRegionInfo returns a RegionInfo copy by region name
	GetRegionInfo(regionName string) (*types.RegionInfo, bool)
	// RangeRegionInfo applies a function to every regionName, regionInfo set.
	// If f returns false, range stops the iteration.
	RangeRegionInfo(f func(regionName string, regionInfo *types.RegionInfo) bool)

	// GetFilteredInferenceResult gets specified model inference result with filter function
	GetFilteredInferenceResult(filterFunc func(result interface{}) (interface{}, error), modelName string) (interface{}, error)
	// GetInferenceResult gets specified model inference result
	GetInferenceResult(modelName string) (interface{}, error)

	metrictypes.MetricsReader
}

MetaReader provides a standard interface to refer to metadata type

type MetaWriter added in v0.4.0

type MetaWriter interface {
	// AddContainer adds a container keyed by pod uid and container name. For repeatedly added
	// container, only mutable metadata will be updated, i.e. request quantity changed by vpa
	AddContainer(podUID string, containerName string, containerInfo *types.ContainerInfo) error
	// SetContainerInfo updates ContainerInfo keyed by pod uid and container name
	SetContainerInfo(podUID string, containerName string, containerInfo *types.ContainerInfo) error
	// RangeAndUpdateContainer applies a function to every podUID, containerName, containerInfo set.
	// Not recommended using if RangeContainer satisfies the requirement.
	// If f returns false, range stops the iteration.
	RangeAndUpdateContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool) error

	// DeleteContainer deletes a ContainerInfo keyed by pod uid and container name
	DeleteContainer(podUID string, containerName string) error
	// RangeAndDeleteContainer applies a function to every podUID, containerName, containerInfo set.
	// If f returns true, the containerInfo will be deleted.
	RangeAndDeleteContainer(f func(containerInfo *types.ContainerInfo) bool, safeTime int64) error
	// RemovePod deletes a PodInfo keyed by pod uid. Repeatedly remove will be ignored.
	RemovePod(podUID string) error
	// ClearContainers remove all containers
	ClearContainers() error

	// SetPoolInfo stores a PoolInfo by pool name
	SetPoolInfo(poolName string, poolInfo *types.PoolInfo) error
	// DeletePool deletes a PoolInfo keyed by pool name
	DeletePool(poolName string) error
	// GCPoolEntries deletes GCPoolEntries not existing on node
	GCPoolEntries(livingPoolNameSet sets.String) error

	// SetRegionEntries overwrites the whole region entries
	SetRegionEntries(entries types.RegionEntries) error
	// SetRegionInfo stores a RegionInfo by region name
	SetRegionInfo(regionName string, regionInfo *types.RegionInfo) error

	// SetInferenceResult sets specified model inference result
	SetInferenceResult(modelName string, result interface{}) error
}

MetaWriter provides a standard interface to modify raw metadata (generated by other agents) in local cache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL