mirror of
https://github.com/minio/minio.git
synced 2025-04-06 04:40:38 -04:00
serialize replication stats() only when needed (#16280)
This commit is contained in:
parent
5a218f38a1
commit
a5f8af4efb
@ -254,11 +254,10 @@ func (r *ReplicationStats) serializeStats() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
r.mostRecentStatsMu.Lock()
|
r.mostRecentStatsMu.Lock()
|
||||||
defer r.mostRecentStatsMu.Unlock()
|
defer r.mostRecentStatsMu.Unlock()
|
||||||
bsm := r.mostRecentStats
|
if len(r.mostRecentStats.Stats) == 0 {
|
||||||
if len(bsm.Stats) == 0 {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
data := make([]byte, 4, 4+bsm.Msgsize())
|
data := make([]byte, 4, 4+r.mostRecentStats.Msgsize())
|
||||||
// Add the replication stats meta header.
|
// Add the replication stats meta header.
|
||||||
binary.LittleEndian.PutUint16(data[0:2], replStatsMetaFormat)
|
binary.LittleEndian.PutUint16(data[0:2], replStatsMetaFormat)
|
||||||
binary.LittleEndian.PutUint16(data[2:4], replStatsVersion)
|
binary.LittleEndian.PutUint16(data[2:4], replStatsVersion)
|
||||||
@ -333,6 +332,7 @@ func (r *ReplicationStats) calculateBucketReplicationStats(bucket string, u Buck
|
|||||||
s = BucketReplicationStats{
|
s = BucketReplicationStats{
|
||||||
Stats: make(map[string]*BucketReplicationStat, len(stats)),
|
Stats: make(map[string]*BucketReplicationStat, len(stats)),
|
||||||
}
|
}
|
||||||
|
|
||||||
var latestTotReplicatedSize int64
|
var latestTotReplicatedSize int64
|
||||||
for _, st := range u.ReplicationInfo {
|
for _, st := range u.ReplicationInfo {
|
||||||
latestTotReplicatedSize += int64(st.ReplicatedSize)
|
latestTotReplicatedSize += int64(st.ReplicatedSize)
|
||||||
@ -372,7 +372,9 @@ func (r *ReplicationStats) calculateBucketReplicationStats(bucket string, u Buck
|
|||||||
if len(r.mostRecentStats.Stats) == 0 {
|
if len(r.mostRecentStats.Stats) == 0 {
|
||||||
r.mostRecentStats = BucketStatsMap{Stats: make(map[string]BucketStats, 1), Timestamp: UTCNow()}
|
r.mostRecentStats = BucketStatsMap{Stats: make(map[string]BucketStats, 1), Timestamp: UTCNow()}
|
||||||
}
|
}
|
||||||
|
if len(s.Stats) > 0 {
|
||||||
r.mostRecentStats.Stats[bucket] = BucketStats{ReplicationStats: s}
|
r.mostRecentStats.Stats[bucket] = BucketStats{ReplicationStats: s}
|
||||||
|
}
|
||||||
r.mostRecentStats.Timestamp = UTCNow()
|
r.mostRecentStats.Timestamp = UTCNow()
|
||||||
r.mostRecentStatsMu.Unlock()
|
r.mostRecentStatsMu.Unlock()
|
||||||
return s
|
return s
|
||||||
|
@ -638,7 +638,7 @@ type replicationResyncer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
replicationDir = "replication"
|
replicationDir = ".replication"
|
||||||
resyncFileName = "resync.bin"
|
resyncFileName = "resync.bin"
|
||||||
resyncMetaFormat = 1
|
resyncMetaFormat = 1
|
||||||
resyncMetaVersionV1 = 1
|
resyncMetaVersionV1 = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user