index

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultMaxCacheSize = 5000000 // 默认 最多500w个,太大了内存会耗尽
)
View Source
const INDEX_SHARD = 256
View Source
const (
	IndexUpdateIncrTaskSleepInterval = time.Duration(10) * time.Second // 增量更新间隔时间, 默认30s
)

Variables

View Source
var IndexedItemCacheBigMap = make([]*IndexCacheBase, INDEX_SHARD)
View Source
var UnIndexedItemCacheBigMap = make([]*IndexCacheBase, INDEX_SHARD)
View Source
var UpdateIndexLock = semaphore.NewSemaphore(1)

重建索引全局锁

Functions

func DeleteItemFronIndex

func DeleteItemFronIndex(hash string)

func GetIndex

func GetIndex()

func GetIndexLoop

func GetIndexLoop()

func GetItemFronIndex

func GetItemFronIndex(hash string) *dataobj.TsdbItem

func Init

func Init(cfg IndexSection)

初始化索引功能模块

func RebuildAllIndex

func RebuildAllIndex(params ...[]string) error

func ReceiveItem

func ReceiveItem(item *dataobj.TsdbItem, hash string)

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

func StartIndexUpdateIncrTask

func StartIndexUpdateIncrTask()

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

func StartUpdateIndexTask

func StartUpdateIndexTask()

Types

type DsTypeAndStep

type DsTypeAndStep struct {
	DsType string `json:"dstype"`
	Step   int    `json:"step"`
}

type IndexAddrs

type IndexAddrs struct {
	sync.RWMutex
	Data []string
}
var IndexList IndexAddrs

func (*IndexAddrs) Get

func (i *IndexAddrs) Get() []string

func (*IndexAddrs) Set

func (i *IndexAddrs) Set(addrs []string)

type IndexCacheBase

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

索引缓存-基本缓存容器

func NewIndexCacheBase

func NewIndexCacheBase(max int) *IndexCacheBase

func (*IndexCacheBase) ContainsKey

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

func (*IndexCacheBase) Get

func (i *IndexCacheBase) Get(key string) *dataobj.TsdbItem

func (*IndexCacheBase) Keys

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

func (*IndexCacheBase) Put

func (i *IndexCacheBase) Put(key string, item *dataobj.TsdbItem)

func (*IndexCacheBase) Remove

func (i *IndexCacheBase) Remove(key string)

func (*IndexCacheBase) Size

func (i *IndexCacheBase) Size() int

type IndexCacheItem

type IndexCacheItem struct {
	UUID string
	Item *dataobj.TsdbItem
}

索引缓存的元素数据结构

func NewIndexCacheItem

func NewIndexCacheItem(uuid string, item *dataobj.TsdbItem) *IndexCacheItem

type IndexSection

type IndexSection struct {
	ActiveDuration  int64  `yaml:"activeDuration"`  //内存索引保留时间
	RebuildInterval int64  `yaml:"rebuildInterval"` //索引重建周期
	HbsMod          string `yaml:"hbsMod"`
}
var Config IndexSection

Jump to

Keyboard shortcuts

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