Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
poornas committed May 30, 2023
1 parent e7bd6d1 commit 53930ab
Showing 1 changed file with 56 additions and 49 deletions.
105 changes: 56 additions & 49 deletions pkg/replication/replication.go
Expand Up @@ -755,28 +755,34 @@ 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"`
}
type ReplQNodeStats struct {

Check failure on line 770 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.19.x and ubuntu-latest

exported: exported type ReplQNodeStats should have comment or be unexported (revive)

Check failure on line 770 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.20.x and ubuntu-latest

exported: exported type ReplQNodeStats should have comment or be unexported (revive)
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"`
}
type ReplQueueStats struct {

Check failure on line 784 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.19.x and ubuntu-latest

exported: exported type ReplQueueStats should have comment or be unexported (revive)

Check failure on line 784 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.20.x and ubuntu-latest

exported: exported type ReplQueueStats should have comment or be unexported (revive)
Nodes []ReplQNodeStats `json:"nodes"`
Uptime int64 `json:"uptime"`
Nodes []ReplQNodeStats `json:"nodes"`
}

func (q ReplQueueStats) Workers() int64 {

Check failure on line 788 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.19.x and ubuntu-latest

exported: exported method ReplQueueStats.Workers should have comment or be unexported (revive)

Check failure on line 788 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.20.x and ubuntu-latest

exported: exported method ReplQueueStats.Workers should have comment or be unexported (revive)
Expand All @@ -788,47 +794,48 @@ func (q ReplQueueStats) Workers() int64 {
}

type ReplQStats struct {

Check failure on line 796 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.19.x and ubuntu-latest

exported: exported type ReplQStats should have comment or be unexported (revive)

Check failure on line 796 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.20.x and ubuntu-latest

exported: exported type ReplQStats should have comment or be unexported (revive)
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"`
}

func (q ReplQueueStats) QStats() (r ReplQStats) {

Check failure on line 808 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.19.x and ubuntu-latest

exported: exported method ReplQueueStats.QStats should have comment or be unexported (revive)

Check failure on line 808 in pkg/replication/replication.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.20.x and ubuntu-latest

exported: exported method ReplQueueStats.QStats should have comment or be unexported (revive)
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
Expand Down

0 comments on commit 53930ab

Please sign in to comment.