diff options
Diffstat (limited to 'src/hub')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvForward.go | 1 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go | 18 | ||||
-rwxr-xr-x | src/hub/test-fwd-graphite | 13 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go index eeb2352..0914308 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go @@ -135,7 +135,6 @@ tryResync: } s5l.Printf("fwd: got %d updates", len(updates)) - if len(updates) == 0 { time.Sleep(1 * time.Second) continue nextBatch diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go index 2c0043b..fc825d9 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go @@ -39,16 +39,6 @@ import ( "github.com/equinox0815/graphite-golang" ) -func (srv Server) forwardGraphiteGetLastUpdate(conn *graphite.Graphite) (latestId int, storeId string, err error) { - latestId, err = srv.GetLastUpdateId() - if err != nil { - s5l.Printf("fwd-graphite: failed to get own hubid: %v\n", err) - return - } - - return -} - func (srv Server) forwardGraphiteRun(forwardHost string, basePath string) { tryResync: for { @@ -59,7 +49,7 @@ tryResync: continue tryResync } - lastId, _, err := srv.forwardGraphiteGetLastUpdate(client) + lastId, err := srv.GetLastUpdateId() if err != nil { s5l.Printf("fwd-graphite: lastupdate returned err: %v", err) client.Disconnect() @@ -72,20 +62,18 @@ tryResync: for { updates, err := srv.GetUpdatesAfter(lastId, 5000) if err != nil { - s5l.Printf("fwd-graphite: failed reading updates: %v\n", err) + s5l.Printf("fwd-graphite: failed reading updates: %v", err) time.Sleep(500 * time.Millisecond) continue nextBatch } s5l.Printf("fwd-graphite: got %d updates", len(updates)) - if len(updates) == 0 { time.Sleep(1 * time.Second) continue nextBatch } metrics := make([]graphite.Metric, len(updates)*3) - for i, update := range updates { path := basePath + "." + update.Hostname path = path + "." + update.StreamId.ContentId @@ -99,7 +87,7 @@ tryResync: err = client.SendMetrics(metrics) if err != nil { - s5l.Printf("fwd-graphite: sending metrics failed: %v\n", err) + s5l.Printf("fwd-graphite: sending metrics failed: %v", err) time.Sleep(1 * time.Second) continue tryResync } diff --git a/src/hub/test-fwd-graphite b/src/hub/test-fwd-graphite new file mode 100755 index 0000000..44f1542 --- /dev/null +++ b/src/hub/test-fwd-graphite @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 <db-name>" + exit 1 +fi + +TEST_D="./test" +TEST_DB="$TEST_D/$1.bolt" + +mkdir -p "$TEST_D" +rm -f "$TEST_D/pipe" "$TEST_D/pipegram" +exec ./bin/sfive-hub -db "$TEST_DB" -start-pipe-server -pipe "$TEST_D/pipe" -start-pipegram-server -pipegram "$TEST_D/pipegram" -start-web-server=false -forward-graphite=127.0.0.1:2003 |