• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang store.Store类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/Symantec/scotty/store.Store的典型用法代码示例。如果您正苦于以下问题:Golang Store类的具体用法?Golang Store怎么用?Golang Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Store类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: activateEndpoints

func activateEndpoints(endpoints []*scotty.Endpoint, s *store.Store) {
	aMetric := metrics.SimpleList{
		{
			Path:        "/foo/first",
			Description: "A description",
		},
		{
			Path:        "/foo/second",
			Description: "A description",
		},
		{
			Path:        "/foo/third",
			Description: "A description",
		},
		{
			Path:        "/foo/fourth",
			Description: "A description",
		},
	}
	for i := range aMetric {
		aMetric[i].Value = int64(i)
	}
	for i := range endpoints {
		s.AddBatch(endpoints[i], 1.0, aMetric[:])
	}
}
开发者ID:keep94,项目名称:scotty,代码行数:26,代码来源:datastructs_test.go


示例2: latestMetricsForEndpoint

func latestMetricsForEndpoint(
	metricStore *store.Store,
	app *datastructs.ApplicationStatus,
	canonicalPath string,
	json bool) (result []*messages.LatestMetric) {
	var appender store.Appender
	if json {
		appender = &latestMetricsAppenderJSON{
			result:   &result,
			hostName: app.EndpointId.HostName(),
			appName:  app.Name,
		}
	} else {
		appender = &latestMetricsAppender{
			result:   &result,
			hostName: app.EndpointId.HostName(),
			appName:  app.Name,
		}
	}
	metricStore.LatestByPrefixAndEndpointStrategy(
		canonicalPath,
		app.EndpointId,
		store.GroupMetricByPathAndNumeric,
		store.AppenderFilterFunc(
			appender,
			func(r *store.Record) bool {
				return r.Info.Path() == canonicalPath || strings.HasPrefix(
					r.Info.Path(), canonicalPath+"/")
			},
		),
	)
	sort.Sort(latestByPath(result))
	return
}
开发者ID:keep94,项目名称:scotty,代码行数:34,代码来源:jsonrpc.go


示例3: EndVisit

func (p *pstoreHandlerType) EndVisit(theStore *store.Store) {
	p.consumer.Flush()
	p.visitorMetricsStore.SetTimeLeft(
		duration.FromFloat(theStore.TimeLeft(p.iteratorName())))
	totalTime := time.Now().Sub(p.startTime)
	p.totalTimeSpentDist.Add(totalTime)

}
开发者ID:keep94,项目名称:scotty,代码行数:8,代码来源:pstorehandler.go


示例4: createApplicationStats

func createApplicationStats(
	appList *datastructs.ApplicationList,
	logger *log.Logger,
	tagvAdder suggest.Adder,
	maybeNilMemoryManager *memoryManagerType) *datastructs.ApplicationStatuses {
	var astore *store.Store
	fmt.Println("Initialization started.")
	if maybeNilMemoryManager != nil {
		memoryManager := maybeNilMemoryManager
		astore = store.NewStoreBytesPerPage(
			*fBytesPerPage,
			1,
			*fThreshhold,
			*fDegree)
		astore.SetExpanding(true)
		memoryManager.SetMemory(astore)
		if err := memoryManager.RegisterMetrics(); err != nil {
			log.Fatal(err)
		}
	} else {
		astore = store.NewStoreBytesPerPage(
			*fBytesPerPage, *fPageCount, *fThreshhold, *fDegree)
	}
	dirSpec, err := tricorder.RegisterDirectory("/store")
	if err != nil {
		log.Fatal(err)
	}
	if err := astore.RegisterMetrics(dirSpec); err != nil {
		log.Fatal(err)
	}
	stats := datastructs.NewApplicationStatuses(appList, astore)
	mdbChannel := mdbd.StartMdbDaemon(*fMdbFile, logger)
	machines := <-mdbChannel
	theHostNames := hostNames(machines.Machines)
	for _, aName := range theHostNames {
		tagvAdder.Add(aName)
	}
	stats.MarkHostsActiveExclusively(
		duration.TimeToFloat(time.Now()), theHostNames)
	fmt.Println("Initialization complete.")
	// Endpoint refresher goroutine
	go func() {
		for {
			machines := <-mdbChannel
			stats.MarkHostsActiveExclusively(
				duration.TimeToFloat(time.Now()),
				hostNames(machines.Machines))
		}
	}()
	return stats
}
开发者ID:keep94,项目名称:scotty,代码行数:51,代码来源:scotty.go


示例5: Visit

func (a *activeInactiveListType) Visit(
	s *store.Store, endpoint interface{}) error {
	a.activeFound = false
	s.LatestByEndpoint(endpoint, a)
	scottyEndpoint := endpoint.(*scotty.Endpoint)
	hostPortStr := fmt.Sprintf(
		"%s:%d", scottyEndpoint.HostName(), scottyEndpoint.Port())
	if a.activeFound {
		a.Active[hostPortStr] = true
	} else {
		a.Inactive[hostPortStr] = true
	}
	return nil
}
开发者ID:keep94,项目名称:scotty,代码行数:14,代码来源:datastructs_test.go


示例6: createNamedIterator

func createNamedIterator(
	theStore *store.Store,
	endpointId interface{},
	iteratorName string,
	rollUpSpan time.Duration) (store.NamedIterator, float64) {
	if rollUpSpan == 0 {
		return theStore.NamedIteratorForEndpoint(
			iteratorName,
			endpointId,
			kLookAheadWritingToPStore,
		)
	}
	// TODO: Strategy hard coded for now, but really the pstore writer
	// in use should dictate the grouping strategy. For now, all our
	// pstore writers convert numeric metrics to float64 which is why
	// the store.GroupByPathAndNumeric strategy works for now.
	return theStore.NamedIteratorForEndpointRollUp(
		iteratorName,
		endpointId,
		rollUpSpan,
		kLookAheadWritingToPStore,
		store.GroupMetricByPathAndNumeric,
	)
}
开发者ID:keep94,项目名称:scotty,代码行数:24,代码来源:pstorehandler.go


示例7: addValues

func addValues(
	t *testing.T,
	aStore *store.Store,
	endpointId interface{},
	path string,
	data ...float64) {
	if len(data)%2 != 0 {
		t.Fatal("Timestamp value pairs expected")
	}
	aMetric := metrics.SimpleList{
		{
			Path:        path,
			Description: "A description",
		},
	}
	dataLen := len(data)
	for i := 0; i < dataLen; i += 2 {
		aMetric[0].TimeStamp = duration.FloatToTime(data[i])
		aMetric[0].Value = data[i+1]
		if _, err := aStore.AddBatch(endpointId, 1000.0, aMetric); err != nil {
			t.Fatal(err)
		}
	}
}
开发者ID:keep94,项目名称:scotty,代码行数:24,代码来源:tsdbimpl_test.go


示例8: gatherDataForEndpoint

// gatherDataForEndpoint serves api/hosts pages.
// metricStore is the metric store.
// endpoint is the endpoint from which we are getting historical metrics.
// canonicalPath is the path of the metrics or the empty string for all
// metrics. canonicalPath is returned from canonicalisePath().
// history is the amount of time to go back in minutes.
// If isSingleton is true, fetched metrics have to match canonicalPath
// exactly.
// Otherwise fetched metrics have to be found underneath canonicalPath.
// On no match, gatherDataForEndpoint returns an empty
// messages.EndpointMetricsList instance
func gatherDataForEndpoint(
	metricStore *store.Store,
	endpoint *collector.Endpoint,
	canonicalPath string,
	history int,
	isSingleton bool) (result messages.EndpointMetricList) {
	result = make(messages.EndpointMetricList, 0)
	now := duration.TimeToFloat(time.Now())
	appender := newEndpointMetricsAppender(&result)
	if canonicalPath == "" {
		metricStore.ByEndpointStrategy(
			endpoint,
			now-60.0*float64(history),
			math.Inf(1),
			store.GroupMetricByKey,
			appender)
	} else {
		metricStore.ByNameAndEndpointStrategy(
			canonicalPath,
			endpoint,
			now-60.0*float64(history),
			math.Inf(1),
			store.GroupMetricByKey,
			appender)
		if len(result) == 0 && !isSingleton {
			metricStore.ByPrefixAndEndpointStrategy(
				canonicalPath+"/",
				endpoint,
				now-60.0*float64(history),
				math.Inf(1),
				store.GroupMetricByKey,
				appender)
		}

	}
	sortMetricsByPath(result)
	return
}
开发者ID:keep94,项目名称:scotty,代码行数:49,代码来源:jsonrpc.go



注:本文中的github.com/Symantec/scotty/store.Store类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang tricorder.DirectorySpec类代码示例发布时间:2022-05-29
下一篇:
Golang sub.UpdateRequest类代码示例发布时间:2022-05-29
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap