本文整理匯總了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[:])
}
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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,
)
}
示例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)
}
}
}
示例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
}