本文整理汇总了Golang中github.com/youtube/vitess/go/stats.IntFunc函数的典型用法代码示例。如果您正苦于以下问题:Golang IntFunc函数的具体用法?Golang IntFunc怎么用?Golang IntFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IntFunc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewQueryEngine
func NewQueryEngine(config Config) *QueryEngine {
qe := &QueryEngine{}
qe.cachePool = NewCachePool("CachePool", config.RowCache, time.Duration(config.QueryTimeout*1e9), time.Duration(config.IdleTimeout*1e9))
qe.schemaInfo = NewSchemaInfo(config.QueryCacheSize, time.Duration(config.SchemaReloadTime*1e9), time.Duration(config.IdleTimeout*1e9))
qe.connPool = NewConnectionPool("ConnPool", config.PoolSize, time.Duration(config.IdleTimeout*1e9))
qe.streamConnPool = NewConnectionPool("StreamConnPool", config.StreamPoolSize, time.Duration(config.IdleTimeout*1e9))
qe.streamTokens = sync2.NewSemaphore(config.StreamExecThrottle, time.Duration(config.StreamWaitTimeout*1e9))
qe.reservedPool = NewReservedPool("ReservedPool")
qe.txPool = NewConnectionPool("TxPool", config.TransactionCap, time.Duration(config.IdleTimeout*1e9)) // connections in pool has to be > transactionCap
qe.activeTxPool = NewActiveTxPool("ActiveTxPool", time.Duration(config.TransactionTimeout*1e9))
qe.activePool = NewActivePool("ActivePool", time.Duration(config.QueryTimeout*1e9), time.Duration(config.IdleTimeout*1e9))
qe.consolidator = NewConsolidator()
qe.spotCheckFreq = sync2.AtomicInt64(config.SpotCheckRatio * SPOT_CHECK_MULTIPLIER)
qe.maxResultSize = sync2.AtomicInt64(config.MaxResultSize)
qe.streamBufferSize = sync2.AtomicInt64(config.StreamBufferSize)
stats.Publish("MaxResultSize", stats.IntFunc(qe.maxResultSize.Get))
stats.Publish("StreamBufferSize", stats.IntFunc(qe.streamBufferSize.Get))
queryStats = stats.NewTimings("Queries")
stats.NewRates("QPS", queryStats, 15, 60e9)
waitStats = stats.NewTimings("Waits")
killStats = stats.NewCounters("Kills")
errorStats = stats.NewCounters("Errors")
resultStats = stats.NewHistogram("Results", resultBuckets)
stats.Publish("SpotCheckRatio", stats.FloatFunc(func() float64 {
return float64(qe.spotCheckFreq.Get()) / SPOT_CHECK_MULTIPLIER
}))
spotCheckCount = stats.NewInt("SpotCheckCount")
return qe
}
开发者ID:CERN-Stage-3,项目名称:vitess,代码行数:29,代码来源:query_engine.go
示例2: NewSchemaInfo
// NewSchemaInfo creates a new SchemaInfo.
func NewSchemaInfo(
queryCacheSize int,
statsPrefix string,
endpoints map[string]string,
reloadTime time.Duration,
idleTimeout time.Duration,
enablePublishStats bool,
queryServiceStats *QueryServiceStats) *SchemaInfo {
si := &SchemaInfo{
queries: cache.NewLRUCache(int64(queryCacheSize)),
connPool: NewConnPool("", 2, idleTimeout, enablePublishStats, queryServiceStats),
ticks: timer.NewTimer(reloadTime),
endpoints: endpoints,
reloadTime: reloadTime,
}
if enablePublishStats {
stats.Publish(statsPrefix+"QueryCacheLength", stats.IntFunc(si.queries.Length))
stats.Publish(statsPrefix+"QueryCacheSize", stats.IntFunc(si.queries.Size))
stats.Publish(statsPrefix+"QueryCacheCapacity", stats.IntFunc(si.queries.Capacity))
stats.Publish(statsPrefix+"QueryCacheOldest", stats.StringFunc(func() string {
return fmt.Sprintf("%v", si.queries.Oldest())
}))
stats.Publish(statsPrefix+"SchemaReloadTime", stats.DurationFunc(si.ticks.Interval))
_ = stats.NewMultiCountersFunc(statsPrefix+"RowcacheStats", []string{"Table", "Stats"}, si.getRowcacheStats)
_ = stats.NewMultiCountersFunc(statsPrefix+"RowcacheInvalidations", []string{"Table"}, si.getRowcacheInvalidations)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryCounts", []string{"Table", "Plan"}, si.getQueryCount)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryTimesNs", []string{"Table", "Plan"}, si.getQueryTime)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryRowCounts", []string{"Table", "Plan"}, si.getQueryRowCount)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryErrorCounts", []string{"Table", "Plan"}, si.getQueryErrorCount)
}
for _, ep := range endpoints {
http.Handle(ep, si)
}
return si
}
开发者ID:fengshao0907,项目名称:vitess,代码行数:36,代码来源:schema_info.go
示例3: NewSchemaInfo
func NewSchemaInfo(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration) *SchemaInfo {
si := &SchemaInfo{
queries: cache.NewLRUCache(int64(queryCacheSize)),
rules: NewQueryRules(),
connPool: dbconnpool.NewConnectionPool("", 2, idleTimeout),
ticks: timer.NewTimer(reloadTime),
}
stats.Publish("QueryCacheLength", stats.IntFunc(si.queries.Length))
stats.Publish("QueryCacheSize", stats.IntFunc(si.queries.Size))
stats.Publish("QueryCacheCapacity", stats.IntFunc(si.queries.Capacity))
stats.Publish("QueryCacheOldest", stats.StringFunc(func() string {
return fmt.Sprintf("%v", si.queries.Oldest())
}))
stats.Publish("SchemaReloadTime", stats.DurationFunc(si.ticks.Interval))
_ = stats.NewMultiCountersFunc("TableStats", []string{"Table", "Stats"}, si.getTableStats)
_ = stats.NewMultiCountersFunc("TableInvalidations", []string{"Table"}, si.getTableInvalidations)
_ = stats.NewMultiCountersFunc("QueryCounts", []string{"Table", "Plan"}, si.getQueryCount)
_ = stats.NewMultiCountersFunc("QueryTimesNs", []string{"Table", "Plan"}, si.getQueryTime)
_ = stats.NewMultiCountersFunc("QueryRowCounts", []string{"Table", "Plan"}, si.getQueryRowCount)
_ = stats.NewMultiCountersFunc("QueryErrorCounts", []string{"Table", "Plan"}, si.getQueryErrorCount)
http.Handle("/debug/query_plans", si)
http.Handle("/debug/query_stats", si)
http.Handle("/debug/table_stats", si)
http.Handle("/debug/schema", si)
return si
}
开发者ID:chinna1986,项目名称:vitess,代码行数:26,代码来源:schema_info.go
示例4: NewSchemaInfo
func NewSchemaInfo(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration, sensitiveMode bool) *SchemaInfo {
si := &SchemaInfo{
queryCacheSize: queryCacheSize,
queries: cache.NewLRUCache(int64(queryCacheSize)),
rules: NewQueryRules(),
connPool: NewConnectionPool("", 2, idleTimeout),
reloadTime: reloadTime,
ticks: timer.NewTimer(reloadTime),
sensitiveMode: sensitiveMode,
}
stats.Publish("QueryCacheLength", stats.IntFunc(si.queries.Length))
stats.Publish("QueryCacheSize", stats.IntFunc(si.queries.Size))
stats.Publish("QueryCacheCapacity", stats.IntFunc(si.queries.Capacity))
stats.Publish("QueryCacheOldest", stats.StringFunc(func() string {
return fmt.Sprintf("%v", si.queries.Oldest())
}))
stats.Publish("SchemaReloadTime", stats.DurationFunc(func() time.Duration {
return si.reloadTime
}))
stats.Publish("TableStats", stats.NewMatrixFunc("Table", "Stats", si.getTableStats))
stats.Publish("TableInvalidations", stats.CountersFunc(si.getTableInvalidations))
stats.Publish("QueryCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryCount))
stats.Publish("QueryTimesNs", stats.NewMatrixFunc("Table", "Plan", si.getQueryTime))
stats.Publish("QueryRowCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryRowCount))
stats.Publish("QueryErrorCounts", stats.NewMatrixFunc("Table", "Plan", si.getQueryErrorCount))
// query_plans cannot be shown in sensitive mode
if !si.sensitiveMode {
http.Handle("/debug/query_plans", si)
}
http.Handle("/debug/query_stats", si)
http.Handle("/debug/table_stats", si)
http.Handle("/debug/schema", si)
return si
}
开发者ID:qman1989,项目名称:vitess,代码行数:34,代码来源:schema_info.go
示例5: NewConnPool
// NewConnPool creates a new ConnPool. The name is used
// to publish stats only.
func NewConnPool(
name string,
capacity int,
idleTimeout time.Duration,
enablePublishStats bool,
queryServiceStats *QueryServiceStats,
checker MySQLChecker) *ConnPool {
cp := &ConnPool{
capacity: capacity,
idleTimeout: idleTimeout,
dbaPool: dbconnpool.NewConnectionPool("", 1, idleTimeout),
queryServiceStats: queryServiceStats,
checker: checker,
}
if name == "" {
return cp
}
if enablePublishStats {
stats.Publish(name+"Capacity", stats.IntFunc(cp.Capacity))
stats.Publish(name+"Available", stats.IntFunc(cp.Available))
stats.Publish(name+"MaxCap", stats.IntFunc(cp.MaxCap))
stats.Publish(name+"WaitCount", stats.IntFunc(cp.WaitCount))
stats.Publish(name+"WaitTime", stats.DurationFunc(cp.WaitTime))
stats.Publish(name+"IdleTimeout", stats.DurationFunc(cp.IdleTimeout))
}
return cp
}
开发者ID:littleyang,项目名称:vitess,代码行数:29,代码来源:connpool.go
示例6: NewRowcacheInvalidator
// NewRowcacheInvalidator creates a new RowcacheInvalidator.
// Just like QueryEngine, this is a singleton class.
// You must call this only once.
func NewRowcacheInvalidator(qe *QueryEngine) *RowcacheInvalidator {
rci := &RowcacheInvalidator{qe: qe}
stats.Publish("RowcacheInvalidatorState", stats.StringFunc(rci.svm.StateName))
stats.Publish("RowcacheInvalidatorPosition", stats.IntFunc(rci.GroupId.Get))
stats.Publish("RowcacheInvalidatorTimestamp", stats.IntFunc(rci.Timestamp.Get))
return rci
}
开发者ID:kingpro,项目名称:vitess,代码行数:10,代码来源:rowcache_invalidator.go
示例7: RegisterBinlogPlayerMap
// RegisterBinlogPlayerMap registers the varz for the players
func RegisterBinlogPlayerMap(blm *BinlogPlayerMap) {
stats.Publish("BinlogPlayerMapSize", stats.IntFunc(blm.size))
stats.Publish("BinlogPlayerSecondsBehindMaster", stats.IntFunc(func() int64 {
sbm := int64(0)
blm.mu.Lock()
for _, bpc := range blm.players {
psbm := bpc.binlogPlayerStats.SecondsBehindMaster.Get()
if psbm > sbm {
sbm = psbm
}
}
blm.mu.Unlock()
return sbm
}))
stats.Publish("BinlogPlayerSecondsBehindMasterMap", stats.CountersFunc(func() map[string]int64 {
blm.mu.Lock()
result := make(map[string]int64, len(blm.players))
for i, bpc := range blm.players {
sbm := bpc.binlogPlayerStats.SecondsBehindMaster.Get()
result[fmt.Sprintf("%v", i)] = sbm
}
blm.mu.Unlock()
return result
}))
stats.Publish("BinlogPlayerGTIDMap", stats.StringMapFunc(func() map[string]string {
blm.mu.Lock()
result := make(map[string]string, len(blm.players))
for i, bpc := range blm.players {
lgtid := bpc.binlogPlayerStats.GetLastGTID()
result[fmt.Sprintf("%v", i)] = myproto.EncodeGTID(lgtid)
}
blm.mu.Unlock()
return result
}))
stats.Publish("BinlogPlayerSourceShardNameMap", stats.StringMapFunc(func() map[string]string {
blm.mu.Lock()
result := make(map[string]string, len(blm.players))
for i, bpc := range blm.players {
name := bpc.sourceShard.Keyspace + "/" + bpc.sourceShard.Shard
result[fmt.Sprintf("%v", i)] = name
}
blm.mu.Unlock()
return result
}))
stats.Publish("BinlogPlayerSourceTabletAliasMap", stats.StringMapFunc(func() map[string]string {
blm.mu.Lock()
result := make(map[string]string, len(blm.players))
for i, bpc := range blm.players {
bpc.playerMutex.Lock()
result[fmt.Sprintf("%v", i)] = bpc.sourceTablet.String()
bpc.playerMutex.Unlock()
}
blm.mu.Unlock()
return result
}))
}
开发者ID:ninqing,项目名称:vitess,代码行数:57,代码来源:binlog.go
示例8: NewCachePool
// NewCachePool creates a new pool for rowcache connections.
func NewCachePool(
name string,
rowCacheConfig RowCacheConfig,
idleTimeout time.Duration,
statsURL string,
enablePublishStats bool,
queryServiceStats *QueryServiceStats) *CachePool {
cp := &CachePool{
name: name,
idleTimeout: idleTimeout,
statsURL: statsURL,
queryServiceStats: queryServiceStats,
}
if name != "" && enablePublishStats {
cp.memcacheStats = NewMemcacheStats(
rowCacheConfig.StatsPrefix+name, 10*time.Second, enableMain,
queryServiceStats,
func(key string) string {
conn := cp.Get(context.Background())
// This is not the same as defer cachePool.Put(conn)
defer func() { cp.Put(conn) }()
stats, err := conn.Stats(key)
if err != nil {
conn.Close()
conn = nil
log.Errorf("Cannot export memcache %v stats: %v", key, err)
queryServiceStats.InternalErrors.Add("MemcacheStats", 1)
return ""
}
return string(stats)
})
stats.Publish(name+"ConnPoolCapacity", stats.IntFunc(cp.Capacity))
stats.Publish(name+"ConnPoolAvailable", stats.IntFunc(cp.Available))
stats.Publish(name+"ConnPoolMaxCap", stats.IntFunc(cp.MaxCap))
stats.Publish(name+"ConnPoolWaitCount", stats.IntFunc(cp.WaitCount))
stats.Publish(name+"ConnPoolWaitTime", stats.DurationFunc(cp.WaitTime))
stats.Publish(name+"ConnPoolIdleTimeout", stats.DurationFunc(cp.IdleTimeout))
}
http.Handle(statsURL, cp)
if rowCacheConfig.Binary == "" {
return cp
}
cp.rowCacheConfig = rowCacheConfig
// Start with memcached defaults
cp.capacity = 1024 - 50
if rowCacheConfig.Connections > 0 {
if rowCacheConfig.Connections <= 50 {
log.Fatalf("insufficient capacity: %d", rowCacheConfig.Connections)
}
cp.capacity = rowCacheConfig.Connections - 50
}
return cp
}
开发者ID:fengshao0907,项目名称:vitess,代码行数:56,代码来源:cache_pool.go
示例9: NewCachePool
func NewCachePool(name string, commandLine []string, queryTimeout time.Duration, idleTimeout time.Duration) *CachePool {
cp := &CachePool{name: name, idleTimeout: idleTimeout}
if name != "" {
cp.memcacheStats = NewMemcacheStats(cp)
stats.Publish(name+"Capacity", stats.IntFunc(cp.Capacity))
stats.Publish(name+"Available", stats.IntFunc(cp.Available))
stats.Publish(name+"MaxCap", stats.IntFunc(cp.MaxCap))
stats.Publish(name+"WaitCount", stats.IntFunc(cp.WaitCount))
stats.Publish(name+"WaitTime", stats.DurationFunc(cp.WaitTime))
stats.Publish(name+"IdleTimeout", stats.DurationFunc(cp.IdleTimeout))
}
http.Handle(statsURL, cp)
if len(commandLine) == 0 {
return cp
}
cp.commandLine = commandLine
// Start with memcached defaults
cp.capacity = 1024 - 50
cp.port = "11211"
for i := 0; i < len(commandLine); i++ {
switch commandLine[i] {
case "-p", "-s":
i++
if i == len(commandLine) {
log.Fatalf("expecting value after -p")
}
cp.port = commandLine[i]
case "-c":
i++
if i == len(commandLine) {
log.Fatalf("expecting value after -c")
}
capacity, err := strconv.Atoi(commandLine[i])
if err != nil {
log.Fatalf("%v", err)
}
if capacity <= 50 {
log.Fatalf("insufficient capacity: %d", capacity)
}
cp.capacity = capacity - 50
}
}
seconds := uint64(queryTimeout / time.Second)
// Add an additional grace period for
// memcache expiry of deleted items
if seconds != 0 {
cp.DeleteExpiry = 2*seconds + 15
}
return cp
}
开发者ID:ZhuoRoger,项目名称:vitess,代码行数:53,代码来源:cache_pool.go
示例10: NewConnectionPool
func NewConnectionPool(name string, capacity int, idleTimeout time.Duration) *ConnectionPool {
cp := &ConnectionPool{capacity: capacity, idleTimeout: idleTimeout}
if name == "" {
return cp
}
stats.Publish(name+"Capacity", stats.IntFunc(cp.Capacity))
stats.Publish(name+"Available", stats.IntFunc(cp.Available))
stats.Publish(name+"MaxCap", stats.IntFunc(cp.MaxCap))
stats.Publish(name+"WaitCount", stats.IntFunc(cp.WaitCount))
stats.Publish(name+"WaitTime", stats.DurationFunc(cp.WaitTime))
stats.Publish(name+"IdleTimeout", stats.DurationFunc(cp.IdleTimeout))
return cp
}
开发者ID:kingpro,项目名称:vitess,代码行数:13,代码来源:conn_pool.go
示例11: NewQueryEngine
// NewQueryEngine creates a new QueryEngine.
// This is a singleton class.
// You must call this only once.
func NewQueryEngine(config Config) *QueryEngine {
qe := &QueryEngine{}
qe.schemaInfo = NewSchemaInfo(config.QueryCacheSize, time.Duration(config.SchemaReloadTime*1e9), time.Duration(config.IdleTimeout*1e9))
mysqlStats = stats.NewTimings("Mysql")
// Pools
qe.cachePool = NewCachePool("Rowcache", config.RowCache, time.Duration(config.QueryTimeout*1e9), time.Duration(config.IdleTimeout*1e9))
qe.connPool = dbconnpool.NewConnectionPool("ConnPool", config.PoolSize, time.Duration(config.IdleTimeout*1e9))
qe.streamConnPool = dbconnpool.NewConnectionPool("StreamConnPool", config.StreamPoolSize, time.Duration(config.IdleTimeout*1e9))
qe.txPool = dbconnpool.NewConnectionPool("TransactionPool", config.TransactionCap, time.Duration(config.IdleTimeout*1e9)) // connections in pool has to be > transactionCap
// Services
qe.activeTxPool = NewActiveTxPool("ActiveTransactionPool", time.Duration(config.TransactionTimeout*1e9))
qe.connKiller = NewConnectionKiller(1, time.Duration(config.IdleTimeout*1e9))
qe.activePool = NewActivePool("ActivePool", time.Duration(config.QueryTimeout*1e9), qe.connKiller)
qe.consolidator = NewConsolidator()
qe.invalidator = NewRowcacheInvalidator(qe)
qe.streamQList = NewQueryList(qe.connKiller)
// Vars
qe.spotCheckFreq = sync2.AtomicInt64(config.SpotCheckRatio * SPOT_CHECK_MULTIPLIER)
if config.StrictMode {
qe.strictMode.Set(1)
}
qe.strictTableAcl = config.StrictTableAcl
qe.maxResultSize = sync2.AtomicInt64(config.MaxResultSize)
qe.streamBufferSize = sync2.AtomicInt64(config.StreamBufferSize)
// loggers
qe.accessCheckerLogger = logutil.NewThrottledLogger("accessChecker", 1*time.Second)
// Stats
stats.Publish("MaxResultSize", stats.IntFunc(qe.maxResultSize.Get))
stats.Publish("StreamBufferSize", stats.IntFunc(qe.streamBufferSize.Get))
queryStats = stats.NewTimings("Queries")
QPSRates = stats.NewRates("QPS", queryStats, 15, 60*time.Second)
waitStats = stats.NewTimings("Waits")
killStats = stats.NewCounters("Kills")
infoErrors = stats.NewCounters("InfoErrors")
errorStats = stats.NewCounters("Errors")
internalErrors = stats.NewCounters("InternalErrors")
resultStats = stats.NewHistogram("Results", resultBuckets)
stats.Publish("RowcacheSpotCheckRatio", stats.FloatFunc(func() float64 {
return float64(qe.spotCheckFreq.Get()) / SPOT_CHECK_MULTIPLIER
}))
spotCheckCount = stats.NewInt("RowcacheSpotCheckCount")
return qe
}
开发者ID:ninqing,项目名称:vitess,代码行数:53,代码来源:query_engine.go
示例12: RegisterBinlogPlayerMap
func RegisterBinlogPlayerMap(blm *BinlogPlayerMap) {
stats.Publish("BinlogPlayerMapSize", stats.IntFunc(blm.size))
stats.Publish("BinlogPlayerSecondsBehindMaster", stats.IntFunc(func() int64 {
sbm := int64(0)
blm.mu.Lock()
for _, bpc := range blm.players {
psbm := bpc.binlogPlayerStats.SecondsBehindMaster.Get()
if psbm > sbm {
sbm = psbm
}
}
blm.mu.Unlock()
return sbm
}))
}
开发者ID:kingpro,项目名称:vitess,代码行数:15,代码来源:binlog.go
示例13: NewRowcacheInvalidator
// NewRowcacheInvalidator creates a new RowcacheInvalidator.
// Just like QueryEngine, this is a singleton class.
// You must call this only once.
func NewRowcacheInvalidator(qe *QueryEngine) *RowcacheInvalidator {
rci := &RowcacheInvalidator{qe: qe}
stats.Publish("RowcacheInvalidatorState", stats.StringFunc(rci.svm.StateName))
stats.Publish("RowcacheInvalidatorPosition", stats.StringFunc(rci.PositionString))
stats.Publish("RowcacheInvalidatorLagSeconds", stats.IntFunc(rci.lagSeconds.Get))
return rci
}
开发者ID:nangong92t,项目名称:go_src,代码行数:10,代码来源:rowcache_invalidator.go
示例14: publishSlabsStats
func (s *MemcacheStats) publishSlabsStats() {
s.slabs.mu.Lock()
defer s.slabs.mu.Unlock()
for key, isSingle := range slabsSingleMetrics {
key := key
s.slabs.stats[key] = make(map[string]int64)
if isSingle {
f := func() int64 {
s.slabs.mu.Lock()
defer s.slabs.mu.Unlock()
s.updateSlabsStats()
return s.slabs.stats[key][""]
}
stats.Publish(s.cachePool.name+"MemcacheSlabs"+formatKey(key), stats.IntFunc(f))
continue
}
f := func() map[string]int64 {
s.slabs.mu.Lock()
defer s.slabs.mu.Unlock()
s.updateSlabsStats()
return copyMap(s.slabs.stats[key])
}
stats.Publish(s.cachePool.name+"MemcacheSlabs"+formatKey(key), stats.CountersFunc(f))
}
}
开发者ID:CERN-Stage-3,项目名称:vitess,代码行数:25,代码来源:memcache_stats.go
示例15: publishMainStats
func (s *MemcacheStats) publishMainStats() {
s.main.mu.Lock()
defer s.main.mu.Unlock()
for key, isstr := range mainStringMetrics {
key := key
if isstr {
s.main.stats[key] = ""
f := func() string {
s.main.mu.Lock()
defer s.main.mu.Unlock()
s.updateMainStats()
return s.main.stats[key]
}
stats.Publish(s.cachePool.name+"Memcache"+formatKey(key), stats.StringFunc(f))
continue
}
s.main.stats[key] = "0"
f := func() int64 {
s.main.mu.Lock()
defer s.main.mu.Unlock()
s.updateMainStats()
ival, err := strconv.ParseInt(s.main.stats[key], 10, 64)
if err != nil {
log.Errorf("value '%v' for key %v is not an int", s.main.stats[key], key)
return -1
}
return ival
}
stats.Publish(s.cachePool.name+"Memcache"+formatKey(key), stats.IntFunc(f))
}
}
开发者ID:CERN-Stage-3,项目名称:vitess,代码行数:31,代码来源:memcache_stats.go
示例16: NewSqlQuery
// NewSqlQuery creates an instance of SqlQuery. Only one instance
// of SqlQuery can be created per process.
func NewSqlQuery(config Config) *SqlQuery {
sq := &SqlQuery{}
sq.qe = NewQueryEngine(config)
stats.Publish("TabletState", stats.IntFunc(sq.state.Get))
stats.Publish("TabletStateName", stats.StringFunc(sq.GetState))
return sq
}
开发者ID:miffa,项目名称:vitess,代码行数:9,代码来源:sqlquery.go
示例17: publishMainStats
func (s *MemcacheStats) publishMainStats() {
s.mu.Lock()
defer s.mu.Unlock()
s.main = make(map[string]string)
for key, isstr := range mainStringMetrics {
key := key
if isstr {
s.main[key] = ""
stats.Publish(s.cachePool.name+"Memcache"+formatKey(key), stats.StringFunc(func() string {
s.mu.Lock()
defer s.mu.Unlock()
return s.main[key]
}))
} else {
s.main[key] = "0"
stats.Publish(s.cachePool.name+"Memcache"+formatKey(key), stats.IntFunc(func() int64 {
s.mu.Lock()
defer s.mu.Unlock()
ival, err := strconv.ParseInt(s.main[key], 10, 64)
if err != nil {
log.Errorf("value '%v' for key %v is not an int", s.main[key], key)
internalErrors.Add("MemcacheStats", 1)
return -1
}
return ival
}))
}
}
}
开发者ID:miffa,项目名称:vitess,代码行数:29,代码来源:memcache_stats.go
示例18: NewTabletServer
// NewTabletServer creates an instance of TabletServer. Only one instance
// of TabletServer can be created per process.
func NewTabletServer(config Config) *TabletServer {
tsv := &TabletServer{
config: config,
QueryTimeout: sync2.NewAtomicDuration(time.Duration(config.QueryTimeout * 1e9)),
BeginTimeout: sync2.NewAtomicDuration(time.Duration(config.TxPoolTimeout * 1e9)),
checkMySQLThrottler: sync2.NewSemaphore(1, 0),
streamHealthMap: make(map[int]chan<- *querypb.StreamHealthResponse),
sessionID: Rand(),
history: history.New(10),
}
tsv.qe = NewQueryEngine(tsv, config)
tsv.invalidator = NewRowcacheInvalidator(config.StatsPrefix, tsv, tsv.qe, config.EnablePublishStats)
if config.EnablePublishStats {
stats.Publish(config.StatsPrefix+"TabletState", stats.IntFunc(func() int64 {
tsv.mu.Lock()
state := tsv.state
tsv.mu.Unlock()
return state
}))
stats.Publish(config.StatsPrefix+"QueryTimeout", stats.DurationFunc(tsv.QueryTimeout.Get))
stats.Publish(config.StatsPrefix+"BeginTimeout", stats.DurationFunc(tsv.BeginTimeout.Get))
stats.Publish(config.StatsPrefix+"TabletStateName", stats.StringFunc(tsv.GetState))
}
return tsv
}
开发者ID:aaijazi,项目名称:vitess,代码行数:27,代码来源:tabletserver.go
示例19: publishMainStats
func (memstats *MemcacheStats) publishMainStats() {
memstats.mu.Lock()
defer memstats.mu.Unlock()
for k, isstr := range mainStringMetrics {
key := k
if isstr {
memstats.main[key] = ""
stats.Publish(memstats.statsPrefix+"Memcache"+formatKey(key), stats.StringFunc(func() string {
memstats.mu.Lock()
defer memstats.mu.Unlock()
return memstats.main[key]
}))
} else {
memstats.main[key] = "0"
stats.Publish(memstats.statsPrefix+"Memcache"+formatKey(key), stats.IntFunc(func() int64 {
memstats.mu.Lock()
defer memstats.mu.Unlock()
ival, err := strconv.ParseInt(memstats.main[key], 10, 64)
if err != nil {
log.Errorf("value '%v' for key %v is not an int", memstats.main[key], key)
memstats.queryServiceStats.InternalErrors.Add("MemcacheStats", 1)
return -1
}
return ival
}))
}
}
}
开发者ID:littleyang,项目名称:vitess,代码行数:28,代码来源:memcache_stats.go
示例20: init
func init() {
CacheInvalidationProcessor = new(InvalidationProcessor)
stats.Publish("RowcacheInvalidationState", stats.StringFunc(func() string {
return rcinvStateNames[CacheInvalidationProcessor.state.Get()]
}))
stats.Publish("RowcacheInvalidationCheckPoint", stats.IntFunc(func() int64 {
return CacheInvalidationProcessor.GroupId.Get()
}))
}
开发者ID:nimishzynga,项目名称:vitess,代码行数:9,代码来源:rowcache_invalidator.go
注:本文中的github.com/youtube/vitess/go/stats.IntFunc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论