mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
commit
c42d33e800
|
@ -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) {
|
||||
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
|
||||
return
|
||||
}
|
||||
for rrc.LastIndex != index {
|
||||
rrc.LastIndex = (rrc.LastIndex + 1) % len(rrc.Values)
|
||||
rrc.Values[rrc.LastIndex] = 0
|
||||
rrc.Counts[rrc.LastIndex] = 0
|
||||
}
|
||||
|
|
19
go/stats/duration_counter_test.go
Normal file
19
go/stats/duration_counter_test.go
Normal file
|
@ -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)
|
||||
}
|
|
@ -32,7 +32,7 @@ var (
|
|||
masterIp = cmdMaster.Flag.String("ip", "localhost", "master <ip>|<server> 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")
|
||||
|
|
|
@ -54,7 +54,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html>
|
|||
<table class="table table-condensed table-striped">
|
||||
<tr>
|
||||
<th>Concurrent Connections</th>
|
||||
<td>{{ .Counters.Connections.WeekCounter.Count }}</td>
|
||||
<td>{{ .Counters.Connections.WeekCounter.Sum }}</td>
|
||||
</tr>
|
||||
{{ range $key, $val := .Stats }}
|
||||
<tr>
|
||||
|
|
Loading…
Reference in a new issue