mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #189 from philips/cleanup-stats-further
cleanup the stats json a bit
This commit is contained in:
commit
21f6b50607
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ src/
|
||||
pkg/
|
||||
/etcd
|
||||
release_version.go
|
||||
/machine*
|
||||
|
@ -172,7 +172,8 @@ func (c *JoinCommand) Apply(raftServer *raft.Server) (interface{}, error) {
|
||||
|
||||
// add peer stats
|
||||
if c.Name != r.Name() {
|
||||
r.peersStats.Peers[c.Name] = &raftPeerStats{MinLatency: 1 << 63}
|
||||
r.peersStats.Peers[c.Name] = &raftPeerStats{}
|
||||
r.peersStats.Peers[c.Name].Latency.Minimum = 1 << 63
|
||||
}
|
||||
|
||||
return b, err
|
||||
|
@ -85,43 +85,48 @@ type raftPeersStats struct {
|
||||
}
|
||||
|
||||
type raftPeerStats struct {
|
||||
Latency float64 `json:"latency"`
|
||||
AvgLatency float64 `json:"averageLatency"`
|
||||
avgLatencySquare float64
|
||||
SdvLatency float64 `json:"sdvLatency"`
|
||||
MinLatency float64 `json:"minLatency"`
|
||||
MaxLatency float64 `json:"maxLatency"`
|
||||
FailCnt uint64 `json:"failsCount"`
|
||||
SuccCnt uint64 `json:"successCount"`
|
||||
Latency struct {
|
||||
Current float64 `json:"current"`
|
||||
Average float64 `json:"average"`
|
||||
averageSquare float64
|
||||
StandardDeviation float64 `json:"standardDeviation"`
|
||||
Minimum float64 `json:"minimum"`
|
||||
Maximum float64 `json:"maximum"`
|
||||
} `json:"latency"`
|
||||
|
||||
Counts struct {
|
||||
Fail uint64 `json:"fail"`
|
||||
Success uint64 `json:"success"`
|
||||
} `json:"counts"`
|
||||
}
|
||||
|
||||
// Succ function update the raftPeerStats with a successful send
|
||||
func (ps *raftPeerStats) Succ(d time.Duration) {
|
||||
total := float64(ps.SuccCnt) * ps.AvgLatency
|
||||
totalSquare := float64(ps.SuccCnt) * ps.avgLatencySquare
|
||||
total := float64(ps.Counts.Success) * ps.Latency.Average
|
||||
totalSquare := float64(ps.Counts.Success) * ps.Latency.averageSquare
|
||||
|
||||
ps.SuccCnt++
|
||||
ps.Counts.Success++
|
||||
|
||||
ps.Latency = float64(d) / (1000000.0)
|
||||
ps.Latency.Current = float64(d) / (1000000.0)
|
||||
|
||||
if ps.Latency > ps.MaxLatency {
|
||||
ps.MaxLatency = ps.Latency
|
||||
if ps.Latency.Current > ps.Latency.Maximum {
|
||||
ps.Latency.Maximum = ps.Latency.Current
|
||||
}
|
||||
|
||||
if ps.Latency < ps.MinLatency {
|
||||
ps.MinLatency = ps.Latency
|
||||
if ps.Latency.Current < ps.Latency.Minimum {
|
||||
ps.Latency.Minimum = ps.Latency.Current
|
||||
}
|
||||
|
||||
ps.AvgLatency = (total + ps.Latency) / float64(ps.SuccCnt)
|
||||
ps.avgLatencySquare = (totalSquare + ps.Latency*ps.Latency) / float64(ps.SuccCnt)
|
||||
ps.Latency.Average = (total + ps.Latency.Current) / float64(ps.Counts.Success)
|
||||
ps.Latency.averageSquare = (totalSquare + ps.Latency.Current * ps.Latency.Current) / float64(ps.Counts.Success)
|
||||
|
||||
// sdv = sqrt(avg(x^2) - avg(x)^2)
|
||||
ps.SdvLatency = math.Sqrt(ps.avgLatencySquare - ps.AvgLatency*ps.AvgLatency)
|
||||
ps.Latency.StandardDeviation = math.Sqrt(ps.Latency.averageSquare - ps.Latency.Average*ps.Latency.Average)
|
||||
}
|
||||
|
||||
// Fail function update the raftPeerStats with a unsuccessful send
|
||||
func (ps *raftPeerStats) Fail() {
|
||||
ps.FailCnt++
|
||||
ps.Counts.Fail++
|
||||
}
|
||||
|
||||
type statsQueue struct {
|
||||
|
19
scripts/test-cluster
Executable file
19
scripts/test-cluster
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
SESSION=etcd-cluster
|
||||
|
||||
tmux new-session -d -s $SESSION
|
||||
|
||||
# Setup a window for tailing log files
|
||||
tmux new-window -t $SESSION:1 -n 'machines'
|
||||
tmux split-window -h
|
||||
tmux select-pane -t 0
|
||||
tmux send-keys "./etcd -s 127.0.0.1:7001 -c 127.0.0.1:4001 -d machine1 -n machine1" C-m
|
||||
|
||||
for i in 2 3; do
|
||||
tmux select-pane -t 0
|
||||
tmux split-window -v
|
||||
tmux send-keys "./etcd -cors='*' -s 127.0.0.1:700${i} -c 127.0.0.1:400${i} -C 127.0.0.1:7001 -d machine${i} -n machine${i}" C-m
|
||||
done
|
||||
|
||||
# Attach to session
|
||||
tmux attach-session -t $SESSION
|
Loading…
x
Reference in New Issue
Block a user