From 9cd221cc3313a3414db9e8cfcd274f74ac85611a Mon Sep 17 00:00:00 2001 From: yanyiwu Date: Mon, 20 Apr 2015 14:47:41 +0800 Subject: [PATCH 1/3] More readable peers usage: other master nodes in comma separated ip:port list, example: 127.0.0.1:9333,127.0.0.1:9334 Add example to prompt ip:port list is split by ',' --- go/weed/master.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/weed/master.go b/go/weed/master.go index e667f28e5..fda19429d 100644 --- a/go/weed/master.go +++ b/go/weed/master.go @@ -32,7 +32,7 @@ var ( masterIp = cmdMaster.Flag.String("ip", "localhost", "master | address") masterBindIp = cmdMaster.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to") metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data") - masterPeers = cmdMaster.Flag.String("peers", "", "other master nodes in comma separated ip:port list") + masterPeers = cmdMaster.Flag.String("peers", "", "other master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094") volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.") mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats") confFile = cmdMaster.Flag.String("conf", "/etc/weedfs/weedfs.conf", "Deprecating! xml configuration file") From c65b9588e2b47fba3485998aa7a449af46693bc2 Mon Sep 17 00:00:00 2001 From: yanyiwu Date: Mon, 20 Apr 2015 21:50:07 +0800 Subject: [PATCH 2/3] [ui] BUG FIXED: Concurrent Connections incorrect. --- go/weed/weed_server/master_ui/templates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/weed/weed_server/master_ui/templates.go b/go/weed/weed_server/master_ui/templates.go index 0e65f6a17..e9ee2d8d2 100644 --- a/go/weed/weed_server/master_ui/templates.go +++ b/go/weed/weed_server/master_ui/templates.go @@ -54,7 +54,7 @@ var StatusTpl = template.Must(template.New("status").Parse(` - + {{ range $key, $val := .Stats }} From eaad4fa3c4ec54e0546e2862ed487c29463cf640 Mon Sep 17 00:00:00 2001 From: yanyiwu Date: Mon, 20 Apr 2015 22:05:20 +0800 Subject: [PATCH 3/3] BUG FIXED: RoundRobinCounter.Add will cause a out of range crash when index >= len(rrc.Values) --- go/stats/duration_counter.go | 11 ++++------- go/stats/duration_counter_test.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 go/stats/duration_counter_test.go diff --git a/go/stats/duration_counter.go b/go/stats/duration_counter.go index 50a8bce43..69c8be61d 100644 --- a/go/stats/duration_counter.go +++ b/go/stats/duration_counter.go @@ -23,14 +23,11 @@ func NewRoundRobinCounter(slots int) *RoundRobinCounter { return &RoundRobinCounter{LastIndex: -1, Values: make([]int64, slots), Counts: make([]int64, slots)} } func (rrc *RoundRobinCounter) Add(index int, val int64) { + if index >= len(rrc.Values) { + return + } for rrc.LastIndex != index { - rrc.LastIndex++ - if rrc.LastIndex >= len(rrc.Values) { - if index >= len(rrc.Values) { - break //just avoid endless loop - } - rrc.LastIndex = 0 - } + rrc.LastIndex = (rrc.LastIndex + 1) % len(rrc.Values) rrc.Values[rrc.LastIndex] = 0 rrc.Counts[rrc.LastIndex] = 0 } diff --git a/go/stats/duration_counter_test.go b/go/stats/duration_counter_test.go new file mode 100644 index 000000000..aa9d61c87 --- /dev/null +++ b/go/stats/duration_counter_test.go @@ -0,0 +1,19 @@ +package stats + +import "testing" + +func TestRobinCounter(t *testing.T) { + rrc := NewRoundRobinCounter(60) + rrc.Add(0, 1) + rrc.Add(50, 2) + if rrc.Count() != 2 { + t.Fatal() + } + if rrc.Sum() != 3 { + t.Fatal() + } + /* + index out of range + */ + rrc.Add(61, 1) +}
Concurrent Connections{{ .Counters.Connections.WeekCounter.Count }}{{ .Counters.Connections.WeekCounter.Sum }}