func NewESHandler() (*ESHandler, error) {

	err := eventdef.InitElasticsearch(*esAddr, "", "")
	if err != nil {
		return nil, err
	}

	return &ESHandler{}, nil
}
示例#2
0
func init() {
	setting.InitConfig()

	var numCPU int
	if setting.Config.NumWorkers != 0 {
		numCPU = setting.Config.NumWorkers
	} else {
		numCPU = runtime.NumCPU()
	}
	runtime.GOMAXPROCS(numCPU)

	bufCh = make(chan metricdef.IndvMetric, numCPU)

	err := eventdef.InitElasticsearch()
	if err != nil {
		panic(err)
	}
	err = metricdef.InitElasticsearch()
	if err != nil {
		panic(err)
	}
	err = metricdef.InitRedis()
	if err != nil {
		panic(err)
	}

	metricDefs, err = metricdef.InitMetricDefCache()
	if err != nil {
		panic(err)
	}

	for i := 0; i < numCPU; i++ {
		mStore, err := metricstore.NewMetricStore()
		if err != nil {
			panic(err)
		}

		go mStore.ProcessBuffer(bufCh, i)
	}
}