diff --git a/pkg/replication/replication.go b/pkg/replication/replication.go index 054602205..db5d1a99a 100644 --- a/pkg/replication/replication.go +++ b/pkg/replication/replication.go @@ -755,30 +755,41 @@ type ResyncTarget struct { Object string `json:"object,omitempty"` } -// ReplicationXferRate holds transfer rate info for uploads -type ReplicationXferRate struct { - Avg float64 `json:"avg"` - Peak float64 `json:"peak"` - Curr float64 `json:"curr"` +// XferStats holds transfer rate info for uploads/sec +type XferStats struct { + AvgRate float64 `json:"avgRate"` + PeakRate float64 `json:"peakRate"` + CurrRate float64 `json:"currRate"` } +// InQueueStats holds stats for objects in replication queue +type InQueueStats struct { + Count int32 `json:"count"` + Bytes int64 `json:"bytes"` +} + +// ReplQNodeStats holds stats for a node in replication queue type ReplQNodeStats struct { - NodeName string `json:"nodename"` - ActiveWorkers int32 `json:"activeworkers"` - Lrg ReplicationXferRate `json:"lrg"` - Sml ReplicationXferRate `json:"sml"` - QueuedCount int32 `json:"totQueuedCount"` - QueuedBytes int64 `json:"totQueuedBytes"` - TotQueuedLrgCount int32 `json:"totQueuedLrgCount"` - TotQueuedLrgBytes int64 `json:"totQueuedLrgBytes"` - TotQueuedSmlCount int32 `json:"totQueuedSmlCount"` - TotQueuedSmlBytes int64 `json:"totQueuedSmlBytes"` + NodeName string `json:"nodeName"` + Uptime int64 `json:"uptime"` + ActiveWorkers int32 `json:"activeWorkers"` + + // transfer stats for objects larger/smaller than 128 MiB + Large XferStats `json:"Large"` + Small XferStats `json:"Small"` + + // queue stats for objects currently in replciation queue + QTotals InQueueStats `json:"queueTotals"` + QLarge InQueueStats `json:"queuedLarge"` + QSmall InQueueStats `json:"queuedSmall"` } + +// ReplQueueStats holds stats for replication queue across nodes type ReplQueueStats struct { - Nodes []ReplQNodeStats `json:"nodes"` - Uptime int64 `json:"uptime"` + Nodes []ReplQNodeStats `json:"nodes"` } +// Workers returns number of workers across all nodes func (q ReplQueueStats) Workers() int64 { var workers int64 for _, node := range q.Nodes { @@ -787,53 +798,57 @@ func (q ReplQueueStats) Workers() int64 { return workers } +// ReplQStats holds stats for objects in replication queue type ReplQStats struct { - Uptime int64 `json:"int64"` - Workers int64 `json:"workers"` - Lrg ReplicationXferRate `json:"lrg"` - Sml ReplicationXferRate `json:"sml"` - QueuedCount int32 `json:"totQueuedCount"` - QueuedBytes int64 `json:"totQueuedBytes"` - TotQueuedLrgCount int32 `json:"totQueuedLrgCount"` - TotQueuedLrgBytes int64 `json:"totQueuedLrgBytes"` - TotQueuedSmlCount int32 `json:"totQueuedSmlCount"` - TotQueuedSmlBytes int64 `json:"totQueuedSmlBytes"` -} - + Uptime int64 `json:"uptime"` + Workers int64 `json:"workers"` + // transfer stats for objects larger/smaller than 128 MiB + Large XferStats `json:"large"` + Small XferStats `json:"small"` + // queue stats for objects currently in replication queue + QTotals InQueueStats `json:"queueTotals"` + QLarge InQueueStats `json:"queuedLarge"` + QSmall InQueueStats `json:"queuedSmall"` +} + +// QStats returns cluster level stats for objects in replication queue func (q ReplQueueStats) QStats() (r ReplQStats) { - r.Uptime = q.Uptime var lavg, lcurr, lpeak, savg, scurr, speak float64 for _, node := range q.Nodes { r.Workers += int64(node.ActiveWorkers) - r.QueuedCount += node.QueuedCount - r.QueuedBytes += node.QueuedBytes - r.TotQueuedLrgCount += node.TotQueuedLrgCount - r.TotQueuedLrgBytes += node.TotQueuedLrgBytes - r.TotQueuedSmlCount += node.TotQueuedSmlCount - r.TotQueuedSmlBytes += node.TotQueuedSmlBytes - lavg += node.Lrg.Avg - lcurr += node.Lrg.Curr - if node.Lrg.Peak > lpeak { - lpeak = node.Lrg.Peak - } - savg += node.Sml.Avg - scurr += node.Sml.Curr - if node.Sml.Peak > speak { - speak = node.Sml.Peak + r.QTotals.Count += node.QTotals.Count + r.QTotals.Bytes += node.QTotals.Bytes + r.Uptime += node.Uptime + + r.QLarge.Count += node.QLarge.Count + r.QLarge.Bytes += node.QLarge.Bytes + r.QSmall.Count += node.QSmall.Count + r.QSmall.Bytes += node.QSmall.Bytes + lavg += node.Large.AvgRate + lcurr += node.Large.CurrRate + if node.Large.PeakRate > lpeak { + lpeak = node.Large.PeakRate + } + savg += node.Small.AvgRate + scurr += node.Small.CurrRate + if node.Small.PeakRate > speak { + speak = node.Small.PeakRate } } if len(q.Nodes) > 0 { - r.Lrg.Avg = lavg / float64(len(q.Nodes)) - r.Lrg.Curr = lcurr / float64(len(q.Nodes)) - r.Lrg.Peak = lpeak - r.Sml.Avg = savg / float64(len(q.Nodes)) - r.Sml.Curr = scurr / float64(len(q.Nodes)) - r.Sml.Peak = speak + r.Large.AvgRate = lavg / float64(len(q.Nodes)) + r.Large.CurrRate = lcurr / float64(len(q.Nodes)) + r.Large.PeakRate = lpeak + r.Small.AvgRate = savg / float64(len(q.Nodes)) + r.Small.CurrRate = scurr / float64(len(q.Nodes)) + r.Small.PeakRate = speak + r.Uptime /= int64(len(q.Nodes)) // average uptime } return } +// MetricsV2 represents replication metrics for a bucket. type MetricsV2 struct { History Metrics `json:"history"` CurrentStats Metrics `json:"currStats"`