index

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxCacheSize                     = 5000000 // 默认 最多500w个,太大了内存会耗尽
	DefaultCacheProcUpdateTaskSleepInterval = time.Duration(1) * time.Second
)
View Source
const (
	DefaultUpdateStepInSec     = 2 * 24 * 3600 //更新步长,一定不能大于删除步长. 两天内的数据,都可以用来建立索引
	ConcurrentOfUpdateIndexAll = 1
)
View Source
const (
	IndexUpdateIncrTaskSleepInterval = time.Duration(1) * time.Second // 增量更新间隔时间, 默认30s
)

Variables

View Source
var (
	IndexedItemCache = NewIndexCacheBase(DefaultMaxCacheSize)
)

item缓存

Functions

func GetConcurrentOfUpdateIndexAll

func GetConcurrentOfUpdateIndexAll() int

索引全量更新的当前并行数

func GetCounterFromCache

func GetCounterFromCache(endpointId int64, counter string) (dsType string, step int, found bool)

Return DsType Step if Found

func GetEndpointFromCache

func GetEndpointFromCache(endpoint string) (int64, bool)

Return EndpointId if Found

func GetTypeAndStep

func GetTypeAndStep(endpoint string, counter string) (dsType string, step int, found bool)

USED WHEN QUERY

func InitCache

func InitCache()

初始化cache

func ReceiveItem

func ReceiveItem(item *cmodel.GraphItem, md5 string)

index收到一条新上报的监控数据,尝试用于增量更新索引

func RemoveItem

func RemoveItem(item *cmodel.GraphItem)

从graph cache中删除掉某个item, 并删除指定的counter对应的rrd文件

func Start

func Start()

初始化索引功能模块

func StartIndexUpdateIncrTask

func StartIndexUpdateIncrTask()

启动索引的 异步、增量更新 任务, 每隔一定时间,刷新cache中的数据到数据库中

func UpdateIndexAll

func UpdateIndexAll(updateStepInSec int64)

func UpdateIndexAllByDefaultStep

func UpdateIndexAllByDefaultStep()

索引的全量更新

func UpdateIndexOne

func UpdateIndexOne(endpoint string, metric string, tags map[string]string, dstype string, step int) error

更新一条监控数据对应的索引. 用于手动添加索引,一般情况下不会使用

Types

type IndexCacheBase

type IndexCacheBase struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

索引缓存-基本缓存容器

func NewIndexCacheBase

func NewIndexCacheBase(max int) *IndexCacheBase

func (*IndexCacheBase) ContainsKey

func (this *IndexCacheBase) ContainsKey(key string) bool

func (*IndexCacheBase) Get

func (this *IndexCacheBase) Get(key string) interface{}

func (*IndexCacheBase) GetMaxSize

func (this *IndexCacheBase) GetMaxSize() int

func (*IndexCacheBase) Keys

func (this *IndexCacheBase) Keys() []string

func (*IndexCacheBase) Put

func (this *IndexCacheBase) Put(key string, item interface{})

func (*IndexCacheBase) Remove

func (this *IndexCacheBase) Remove(key string)

func (*IndexCacheBase) Size

func (this *IndexCacheBase) Size() int

type IndexCacheItem

type IndexCacheItem struct {
	UUID string
	Item *cmodel.GraphItem
}

INDEX CACHE 索引缓存的元素数据结构

func NewIndexCacheItem

func NewIndexCacheItem(uuid string, item *cmodel.GraphItem) *IndexCacheItem

Jump to

Keyboard shortcuts

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