File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,6 +424,7 @@ func TestFullProcess(t *testing.T) {
424424 t .Fatalf ("wait for chain service failed: %v" , err )
425425 }
426426
427+ time .Sleep (time .Hour )
427428 _ , dsn , err := client .Create (meta )
428429 So (err , ShouldBeNil )
429430 dsnCfg , err := client .ParseDSN (dsn )
Original file line number Diff line number Diff line change @@ -34,10 +34,13 @@ package consistent
3434
3535import (
3636 "errors"
37+ "expvar"
3738 "sort"
3839 "strconv"
3940 "sync"
4041
42+ mw "github.com/zserge/metric"
43+
4144 "github.com/CovenantSQL/CovenantSQL/conf"
4245 "github.com/CovenantSQL/CovenantSQL/crypto/hash"
4346 "github.com/CovenantSQL/CovenantSQL/proto"
6366 ErrKeyNotFound = errors .New ("node key not found" )
6467)
6568
69+ const (
70+ mwKeyDHTNodeCount = "service:DHT:NodeCount"
71+ )
72+
73+ func init () {
74+ expvar .Publish (mwKeyDHTNodeCount , mw .NewGauge ("1M1d" ))
75+ }
76+
6677// Consistent holds the information about the members of the consistent hash circle.
6778type Consistent struct {
6879 // TODO(auxten): do not store node info on circle, just put node id as value
@@ -180,7 +191,6 @@ func (c *Consistent) add(node proto.Node) (err error) {
180191 log .WithField ("node" , node ).WithError (err ).Error ("set node info failed" )
181192 return
182193 }
183-
184194 c .AddCache (node )
185195 return
186196}
@@ -195,6 +205,7 @@ func (c *Consistent) AddCache(node proto.Node) {
195205 }
196206 c .updateSortedHashes ()
197207 c .count ++
208+ expvar .Get (mwKeyDHTNodeCount ).(mw.Metric ).Add (float64 (c .count ))
198209 return
199210}
200211
You can’t perform that action at this time.
0 commit comments