From cbfe9de3e75f2475ac96cb3690ce2d39a4e63690 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 4 Oct 2024 04:32:32 -0700 Subject: [PATCH 1/3] do not download binary before verifying the version (#20523) fixes https://github.com/minio/mc/issues/4980 --- cmd/admin-handlers.go | 92 +++++++++++++++++++++++++++-------------- cmd/peer-rest-server.go | 2 +- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 9938cec5e..471705d8b 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -93,11 +93,18 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R return } - if globalInplaceUpdateDisabled || currentReleaseTime.IsZero() { + if globalInplaceUpdateDisabled { writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL) return } + if currentReleaseTime.IsZero() || currentReleaseTime.Equal(timeSentinel) { + apiErr := errorCodes.ToAPIErr(ErrMethodNotAllowed) + apiErr.Description = fmt.Sprintf("unable to perform in-place update, release time is unrecognized: %s", currentReleaseTime) + writeErrorResponseJSON(ctx, w, apiErr, r.URL) + return + } + vars := mux.Vars(r) updateURL := vars["updateURL"] dryRun := r.Form.Get("dry-run") == "true" @@ -110,6 +117,11 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R } } + local := globalLocalNodeName + if local == "" { + local = "127.0.0.1" + } + u, err := url.Parse(updateURL) if err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) @@ -128,6 +140,39 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R return } + updateStatus := madmin.ServerUpdateStatusV2{ + DryRun: dryRun, + Results: make([]madmin.ServerPeerUpdateStatus, 0, len(globalNotificationSys.allPeerClients)), + } + peerResults := make(map[string]madmin.ServerPeerUpdateStatus, len(globalNotificationSys.allPeerClients)) + failedClients := make(map[int]bool, len(globalNotificationSys.allPeerClients)) + + if lrTime.Sub(currentReleaseTime) <= 0 { + updateStatus.Results = append(updateStatus.Results, madmin.ServerPeerUpdateStatus{ + Host: local, + Err: fmt.Sprintf("server is running the latest version: %s", Version), + CurrentVersion: Version, + }) + + for _, client := range globalNotificationSys.peerClients { + updateStatus.Results = append(updateStatus.Results, madmin.ServerPeerUpdateStatus{ + Host: client.String(), + Err: fmt.Sprintf("server is running the latest version: %s", Version), + CurrentVersion: Version, + }) + } + + // Marshal API response + jsonBytes, err := json.Marshal(updateStatus) + if err != nil { + writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) + return + } + + writeSuccessResponseJSON(w, jsonBytes) + return + } + u.Path = path.Dir(u.Path) + SlashSeparator + releaseInfo // Download Binary Once binC, bin, err := downloadBinary(u, mode) @@ -137,16 +182,6 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R return } - updateStatus := madmin.ServerUpdateStatusV2{DryRun: dryRun} - peerResults := make(map[string]madmin.ServerPeerUpdateStatus) - - local := globalLocalNodeName - if local == "" { - local = "127.0.0.1" - } - - failedClients := make(map[int]struct{}) - if globalIsDistErasure { // Push binary to other servers for idx, nerr := range globalNotificationSys.VerifyBinary(ctx, u, sha256Sum, releaseInfo, binC) { @@ -156,7 +191,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R Err: nerr.Err.Error(), CurrentVersion: Version, } - failedClients[idx] = struct{}{} + failedClients[idx] = true } else { peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{ Host: nerr.Host.String(), @@ -167,25 +202,17 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R } } - if lrTime.Sub(currentReleaseTime) > 0 { - if err = verifyBinary(u, sha256Sum, releaseInfo, mode, bytes.NewReader(bin)); err != nil { - peerResults[local] = madmin.ServerPeerUpdateStatus{ - Host: local, - Err: err.Error(), - CurrentVersion: Version, - } - } else { - peerResults[local] = madmin.ServerPeerUpdateStatus{ - Host: local, - CurrentVersion: Version, - UpdatedVersion: lrTime.Format(MinioReleaseTagTimeLayout), - } + if err = verifyBinary(u, sha256Sum, releaseInfo, mode, bytes.NewReader(bin)); err != nil { + peerResults[local] = madmin.ServerPeerUpdateStatus{ + Host: local, + Err: err.Error(), + CurrentVersion: Version, } } else { peerResults[local] = madmin.ServerPeerUpdateStatus{ Host: local, - Err: fmt.Sprintf("server is already running the latest version: %s", Version), CurrentVersion: Version, + UpdatedVersion: lrTime.Format(MinioReleaseTagTimeLayout), } } @@ -193,8 +220,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R if globalIsDistErasure { ng := WithNPeers(len(globalNotificationSys.peerClients)) for idx, client := range globalNotificationSys.peerClients { - _, ok := failedClients[idx] - if ok { + if failedClients[idx] { continue } client := client @@ -240,14 +266,14 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R startTime := time.Now().Add(restartUpdateDelay) ng := WithNPeers(len(globalNotificationSys.peerClients)) for idx, client := range globalNotificationSys.peerClients { - _, ok := failedClients[idx] - if ok { + if failedClients[idx] { continue } client := client ng.Go(ctx, func() error { prs, ok := peerResults[client.String()] - if ok && prs.CurrentVersion != prs.UpdatedVersion && prs.UpdatedVersion != "" { + // We restart only on success, not for any failures. + if ok && prs.Err == "" { return client.SignalService(serviceRestart, "", dryRun, &startTime) } return nil @@ -284,7 +310,9 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R writeSuccessResponseJSON(w, jsonBytes) if !dryRun { - if lrTime.Sub(currentReleaseTime) > 0 { + prs, ok := peerResults[local] + // We restart only on success, not for any failures. + if ok && prs.Err == "" { globalServiceSignalCh <- serviceRestart } } diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index 96a1d90ad..e2700f280 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -636,7 +636,7 @@ func (s *peerRESTServer) VerifyBinaryHandler(w http.ResponseWriter, r *http.Requ } if lrTime.Sub(currentReleaseTime) <= 0 { - s.writeErrorResponse(w, fmt.Errorf("server is already running the latest version: %s", Version)) + s.writeErrorResponse(w, fmt.Errorf("server is running the latest version: %s", Version)) return } From 28322124e21d3738b5b25b6495279d22c8560735 Mon Sep 17 00:00:00 2001 From: Poorna Date: Fri, 4 Oct 2024 15:23:33 -0700 Subject: [PATCH 2/3] remove replication stats from data usage cache (#20524) This is no longer needed since historical stats are not maintained anymore. --- cmd/data-usage-cache.go | 329 ++------ cmd/data-usage-cache_gen.go | 1201 +----------------------------- cmd/data-usage-cache_gen_test.go | 452 ----------- cmd/data-usage_test.go | 11 - cmd/erasure.go | 3 - 5 files changed, 74 insertions(+), 1922 deletions(-) diff --git a/cmd/data-usage-cache.go b/cmd/data-usage-cache.go index 22ee0522f..6dbe7ff06 100644 --- a/cmd/data-usage-cache.go +++ b/cmd/data-usage-cache.go @@ -57,15 +57,14 @@ type versionsHistogram [dataUsageVersionLen]uint64 type dataUsageEntry struct { Children dataUsageHashMap `msg:"ch"` // These fields do no include any children. - Size int64 `msg:"sz"` - Objects uint64 `msg:"os"` - Versions uint64 `msg:"vs"` // Versions that are not delete markers. - DeleteMarkers uint64 `msg:"dms"` - ObjSizes sizeHistogram `msg:"szs"` - ObjVersions versionsHistogram `msg:"vh"` - ReplicationStats *replicationAllStats `msg:"rs,omitempty"` - AllTierStats *allTierStats `msg:"ats,omitempty"` - Compacted bool `msg:"c"` + Size int64 `msg:"sz"` + Objects uint64 `msg:"os"` + Versions uint64 `msg:"vs"` // Versions that are not delete markers. + DeleteMarkers uint64 `msg:"dms"` + ObjSizes sizeHistogram `msg:"szs"` + ObjVersions versionsHistogram `msg:"vh"` + AllTierStats *allTierStats `msg:"ats,omitempty"` + Compacted bool `msg:"c"` } // allTierStats is a collection of per-tier stats across all configured remote @@ -135,93 +134,6 @@ func (ts tierStats) add(u tierStats) tierStats { } } -//msgp:tuple replicationStatsV1 -type replicationStatsV1 struct { - PendingSize uint64 - ReplicatedSize uint64 - FailedSize uint64 - ReplicaSize uint64 - FailedCount uint64 - PendingCount uint64 - MissedThresholdSize uint64 - AfterThresholdSize uint64 - MissedThresholdCount uint64 - AfterThresholdCount uint64 -} - -func (rsv1 replicationStatsV1) Empty() bool { - return rsv1.ReplicatedSize == 0 && - rsv1.FailedSize == 0 && - rsv1.FailedCount == 0 -} - -//msgp:tuple replicationStats -type replicationStats struct { - PendingSize uint64 - ReplicatedSize uint64 - FailedSize uint64 - FailedCount uint64 - PendingCount uint64 - MissedThresholdSize uint64 - AfterThresholdSize uint64 - MissedThresholdCount uint64 - AfterThresholdCount uint64 - ReplicatedCount uint64 -} - -func (rs replicationStats) Empty() bool { - return rs.ReplicatedSize == 0 && - rs.FailedSize == 0 && - rs.FailedCount == 0 -} - -type replicationAllStats struct { - Targets map[string]replicationStats `msg:"t,omitempty"` - ReplicaSize uint64 `msg:"r,omitempty"` - ReplicaCount uint64 `msg:"rc,omitempty"` -} - -//msgp:tuple replicationAllStatsV1 -type replicationAllStatsV1 struct { - Targets map[string]replicationStats - ReplicaSize uint64 `msg:"ReplicaSize,omitempty"` - ReplicaCount uint64 `msg:"ReplicaCount,omitempty"` -} - -// empty returns true if the replicationAllStats is empty (contains no entries). -func (r *replicationAllStats) empty() bool { - if r == nil { - return true - } - if r.ReplicaSize != 0 || r.ReplicaCount != 0 { - return false - } - for _, v := range r.Targets { - if !v.Empty() { - return false - } - } - return true -} - -// clone creates a deep-copy clone. -func (r *replicationAllStats) clone() *replicationAllStats { - if r == nil { - return nil - } - - // Shallow copy - dst := *r - - // Copy individual targets. - dst.Targets = make(map[string]replicationStats, len(r.Targets)) - for k, v := range r.Targets { - dst.Targets[k] = v - } - - return &dst -} - //msgp:encode ignore dataUsageEntryV2 dataUsageEntryV3 dataUsageEntryV4 dataUsageEntryV5 dataUsageEntryV6 dataUsageEntryV7 //msgp:marshal ignore dataUsageEntryV2 dataUsageEntryV3 dataUsageEntryV4 dataUsageEntryV5 dataUsageEntryV6 dataUsageEntryV7 @@ -237,62 +149,54 @@ type dataUsageEntryV2 struct { //msgp:tuple dataUsageEntryV3 type dataUsageEntryV3 struct { // These fields do no include any children. - Size int64 - ReplicatedSize uint64 - ReplicationPendingSize uint64 - ReplicationFailedSize uint64 - ReplicaSize uint64 - Objects uint64 - ObjSizes sizeHistogram - Children dataUsageHashMap + Size int64 + Objects uint64 + ObjSizes sizeHistogram + Children dataUsageHashMap } //msgp:tuple dataUsageEntryV4 type dataUsageEntryV4 struct { Children dataUsageHashMap // These fields do no include any children. - Size int64 - Objects uint64 - ObjSizes sizeHistogram - ReplicationStats replicationStatsV1 + Size int64 + Objects uint64 + ObjSizes sizeHistogram } //msgp:tuple dataUsageEntryV5 type dataUsageEntryV5 struct { Children dataUsageHashMap // These fields do no include any children. - Size int64 - Objects uint64 - Versions uint64 // Versions that are not delete markers. - ObjSizes sizeHistogram - ReplicationStats *replicationStatsV1 - Compacted bool + Size int64 + Objects uint64 + Versions uint64 // Versions that are not delete markers. + ObjSizes sizeHistogram + Compacted bool } //msgp:tuple dataUsageEntryV6 type dataUsageEntryV6 struct { Children dataUsageHashMap // These fields do no include any children. - Size int64 - Objects uint64 - Versions uint64 // Versions that are not delete markers. - ObjSizes sizeHistogram - ReplicationStats *replicationAllStatsV1 - Compacted bool + Size int64 + Objects uint64 + Versions uint64 // Versions that are not delete markers. + ObjSizes sizeHistogram + Compacted bool } type dataUsageEntryV7 struct { Children dataUsageHashMap `msg:"ch"` // These fields do no include any children. - Size int64 `msg:"sz"` - Objects uint64 `msg:"os"` - Versions uint64 `msg:"vs"` // Versions that are not delete markers. - DeleteMarkers uint64 `msg:"dms"` - ObjSizes sizeHistogramV1 `msg:"szs"` - ObjVersions versionsHistogram `msg:"vh"` - ReplicationStats *replicationAllStats `msg:"rs,omitempty"` - AllTierStats *allTierStats `msg:"ats,omitempty"` - Compacted bool `msg:"c"` + Size int64 `msg:"sz"` + Objects uint64 `msg:"os"` + Versions uint64 `msg:"vs"` // Versions that are not delete markers. + DeleteMarkers uint64 `msg:"dms"` + ObjSizes sizeHistogramV1 `msg:"szs"` + ObjVersions versionsHistogram `msg:"vh"` + AllTierStats *allTierStats `msg:"ats,omitempty"` + Compacted bool `msg:"c"` } // dataUsageCache contains a cache of data usage entries latest version. @@ -373,29 +277,6 @@ func (e *dataUsageEntry) addSizes(summary sizeSummary) { e.ObjSizes.add(summary.totalSize) e.ObjVersions.add(summary.versions) - if e.ReplicationStats == nil { - e.ReplicationStats = &replicationAllStats{ - Targets: make(map[string]replicationStats), - } - } else if e.ReplicationStats.Targets == nil { - e.ReplicationStats.Targets = make(map[string]replicationStats) - } - e.ReplicationStats.ReplicaSize += uint64(summary.replicaSize) - e.ReplicationStats.ReplicaCount += uint64(summary.replicaCount) - - for arn, st := range summary.replTargetStats { - tgtStat, ok := e.ReplicationStats.Targets[arn] - if !ok { - tgtStat = replicationStats{} - } - tgtStat.PendingSize += uint64(st.pendingSize) - tgtStat.FailedSize += uint64(st.failedSize) - tgtStat.ReplicatedSize += uint64(st.replicatedSize) - tgtStat.ReplicatedCount += uint64(st.replicatedCount) - tgtStat.FailedCount += st.failedCount - tgtStat.PendingCount += st.pendingCount - e.ReplicationStats.Targets[arn] = tgtStat - } if len(summary.tiers) != 0 { if e.AllTierStats == nil { e.AllTierStats = newAllTierStats() @@ -410,26 +291,6 @@ func (e *dataUsageEntry) merge(other dataUsageEntry) { e.Versions += other.Versions e.DeleteMarkers += other.DeleteMarkers e.Size += other.Size - if other.ReplicationStats != nil { - if e.ReplicationStats == nil { - e.ReplicationStats = &replicationAllStats{Targets: make(map[string]replicationStats)} - } else if e.ReplicationStats.Targets == nil { - e.ReplicationStats.Targets = make(map[string]replicationStats) - } - e.ReplicationStats.ReplicaSize += other.ReplicationStats.ReplicaSize - e.ReplicationStats.ReplicaCount += other.ReplicationStats.ReplicaCount - for arn, stat := range other.ReplicationStats.Targets { - st := e.ReplicationStats.Targets[arn] - e.ReplicationStats.Targets[arn] = replicationStats{ - PendingSize: stat.PendingSize + st.PendingSize, - FailedSize: stat.FailedSize + st.FailedSize, - ReplicatedSize: stat.ReplicatedSize + st.ReplicatedSize, - PendingCount: stat.PendingCount + st.PendingCount, - FailedCount: stat.FailedCount + st.FailedCount, - ReplicatedCount: stat.ReplicatedCount + st.ReplicatedCount, - } - } - } for i, v := range other.ObjSizes[:] { e.ObjSizes[i] += v @@ -490,10 +351,7 @@ func (e dataUsageEntry) clone() dataUsageEntry { } e.Children = ch } - if e.ReplicationStats != nil { - // Clone ReplicationStats - e.ReplicationStats = e.ReplicationStats.clone() - } + if e.AllTierStats != nil { e.AllTierStats = e.AllTierStats.clone() } @@ -931,22 +789,6 @@ func (d *dataUsageCache) bucketsUsageInfo(buckets []BucketInfo) map[string]Bucke ObjectSizesHistogram: flat.ObjSizes.toMap(), ObjectVersionsHistogram: flat.ObjVersions.toMap(), } - if flat.ReplicationStats != nil { - bui.ReplicaSize = flat.ReplicationStats.ReplicaSize - bui.ReplicaCount = flat.ReplicationStats.ReplicaCount - - bui.ReplicationInfo = make(map[string]BucketTargetUsageInfo, len(flat.ReplicationStats.Targets)) - for arn, stat := range flat.ReplicationStats.Targets { - bui.ReplicationInfo[arn] = BucketTargetUsageInfo{ - ReplicationPendingSize: stat.PendingSize, - ReplicatedSize: stat.ReplicatedSize, - ReplicationFailedSize: stat.FailedSize, - ReplicationPendingCount: stat.PendingCount, - ReplicationFailedCount: stat.FailedCount, - ReplicatedCount: stat.ReplicatedCount, - } - } - } dst[bucket.Name] = bui } return dst @@ -959,9 +801,6 @@ func (d *dataUsageCache) sizeRecursive(path string) *dataUsageEntry { return root } flat := d.flatten(*root) - if flat.ReplicationStats.empty() { - flat.ReplicationStats = nil - } return &flat } @@ -1238,20 +1077,6 @@ func (d *dataUsageCache) deserialize(r io.Reader) error { ObjSizes: v.ObjSizes, Children: v.Children, } - if v.ReplicatedSize > 0 || v.ReplicaSize > 0 || v.ReplicationFailedSize > 0 || v.ReplicationPendingSize > 0 { - cfg, _ := getReplicationConfig(GlobalContext, d.Info.Name) - if cfg != nil && cfg.RoleArn != "" { - due.ReplicationStats = &replicationAllStats{ - Targets: make(map[string]replicationStats), - } - due.ReplicationStats.ReplicaSize = v.ReplicaSize - due.ReplicationStats.Targets[cfg.RoleArn] = replicationStats{ - ReplicatedSize: v.ReplicatedSize, - FailedSize: v.ReplicationFailedSize, - PendingSize: v.ReplicationPendingSize, - } - } - } due.Compacted = len(due.Children) == 0 && k != d.Info.Name d.Cache[k] = due @@ -1277,36 +1102,10 @@ func (d *dataUsageCache) deserialize(r io.Reader) error { ObjSizes: v.ObjSizes, Children: v.Children, } - empty := replicationStatsV1{} - - if v.ReplicationStats != empty { - cfg, _ := getReplicationConfig(GlobalContext, d.Info.Name) - if cfg != nil && cfg.RoleArn != "" { - due.ReplicationStats = &replicationAllStats{ - Targets: make(map[string]replicationStats), - } - due.ReplicationStats.Targets[cfg.RoleArn] = replicationStats{ - ReplicatedSize: v.ReplicationStats.ReplicatedSize, - FailedSize: v.ReplicationStats.FailedSize, - FailedCount: v.ReplicationStats.FailedCount, - PendingSize: v.ReplicationStats.PendingSize, - PendingCount: v.ReplicationStats.PendingCount, - } - due.ReplicationStats.ReplicaSize = v.ReplicationStats.ReplicaSize - } - } due.Compacted = len(due.Children) == 0 && k != d.Info.Name d.Cache[k] = due } - - // Populate compacted value and remove unneeded replica stats. - for k, e := range d.Cache { - if e.ReplicationStats != nil && len(e.ReplicationStats.Targets) == 0 { - e.ReplicationStats = nil - } - d.Cache[k] = e - } return nil case dataUsageCacheVerV5: // Zstd compressed. @@ -1328,36 +1127,10 @@ func (d *dataUsageCache) deserialize(r io.Reader) error { ObjSizes: v.ObjSizes, Children: v.Children, } - if v.ReplicationStats != nil && !v.ReplicationStats.Empty() { - cfg, _ := getReplicationConfig(GlobalContext, d.Info.Name) - if cfg != nil && cfg.RoleArn != "" { - due.ReplicationStats = &replicationAllStats{ - Targets: make(map[string]replicationStats), - } - d.Info.replication = replicationConfig{Config: cfg} - - due.ReplicationStats.Targets[cfg.RoleArn] = replicationStats{ - ReplicatedSize: v.ReplicationStats.ReplicatedSize, - FailedSize: v.ReplicationStats.FailedSize, - FailedCount: v.ReplicationStats.FailedCount, - PendingSize: v.ReplicationStats.PendingSize, - PendingCount: v.ReplicationStats.PendingCount, - } - due.ReplicationStats.ReplicaSize = v.ReplicationStats.ReplicaSize - } - } due.Compacted = len(due.Children) == 0 && k != d.Info.Name d.Cache[k] = due } - - // Populate compacted value and remove unneeded replica stats. - for k, e := range d.Cache { - if e.ReplicationStats != nil && len(e.ReplicationStats.Targets) == 0 { - e.ReplicationStats = nil - } - d.Cache[k] = e - } return nil case dataUsageCacheVerV6: // Zstd compressed. @@ -1373,22 +1146,13 @@ func (d *dataUsageCache) deserialize(r io.Reader) error { d.Info = dold.Info d.Cache = make(map[string]dataUsageEntry, len(dold.Cache)) for k, v := range dold.Cache { - var replicationStats *replicationAllStats - if v.ReplicationStats != nil { - replicationStats = &replicationAllStats{ - Targets: v.ReplicationStats.Targets, - ReplicaSize: v.ReplicationStats.ReplicaSize, - ReplicaCount: v.ReplicationStats.ReplicaCount, - } - } due := dataUsageEntry{ - Children: v.Children, - Size: v.Size, - Objects: v.Objects, - Versions: v.Versions, - ObjSizes: v.ObjSizes, - ReplicationStats: replicationStats, - Compacted: v.Compacted, + Children: v.Children, + Size: v.Size, + Objects: v.Objects, + Versions: v.Versions, + ObjSizes: v.ObjSizes, + Compacted: v.Compacted, } d.Cache[k] = due } @@ -1410,13 +1174,12 @@ func (d *dataUsageCache) deserialize(r io.Reader) error { var szHist sizeHistogram szHist.mergeV1(v.ObjSizes) d.Cache[k] = dataUsageEntry{ - Children: v.Children, - Size: v.Size, - Objects: v.Objects, - Versions: v.Versions, - ObjSizes: szHist, - ReplicationStats: v.ReplicationStats, - Compacted: v.Compacted, + Children: v.Children, + Size: v.Size, + Objects: v.Objects, + Versions: v.Versions, + ObjSizes: szHist, + Compacted: v.Compacted, } } diff --git a/cmd/data-usage-cache_gen.go b/cmd/data-usage-cache_gen.go index 69e0cc6c8..67204a27a 100644 --- a/cmd/data-usage-cache_gen.go +++ b/cmd/data-usage-cache_gen.go @@ -1707,24 +1707,6 @@ func (z *dataUsageEntry) DecodeMsg(dc *msgp.Reader) (err error) { return } } - case "rs": - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStats) - } - err = z.ReplicationStats.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } case "ats": if dc.IsNil() { err = dc.ReadNil() @@ -1763,16 +1745,12 @@ func (z *dataUsageEntry) DecodeMsg(dc *msgp.Reader) (err error) { // EncodeMsg implements msgp.Encodable func (z *dataUsageEntry) EncodeMsg(en *msgp.Writer) (err error) { // check for omitted fields - zb0001Len := uint32(10) - var zb0001Mask uint16 /* 10 bits */ + zb0001Len := uint32(9) + var zb0001Mask uint16 /* 9 bits */ _ = zb0001Mask - if z.ReplicationStats == nil { - zb0001Len-- - zb0001Mask |= 0x80 - } if z.AllTierStats == nil { zb0001Len-- - zb0001Mask |= 0x100 + zb0001Mask |= 0x80 } // variable map header, size zb0001Len err = en.Append(0x80 | uint8(zb0001Len)) @@ -1867,25 +1845,6 @@ func (z *dataUsageEntry) EncodeMsg(en *msgp.Writer) (err error) { } } if (zb0001Mask & 0x80) == 0 { // if not omitted - // write "rs" - err = en.Append(0xa2, 0x72, 0x73) - if err != nil { - return - } - if z.ReplicationStats == nil { - err = en.WriteNil() - if err != nil { - return - } - } else { - err = z.ReplicationStats.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } - } - if (zb0001Mask & 0x100) == 0 { // if not omitted // write "ats" err = en.Append(0xa3, 0x61, 0x74, 0x73) if err != nil { @@ -1921,16 +1880,12 @@ func (z *dataUsageEntry) EncodeMsg(en *msgp.Writer) (err error) { func (z *dataUsageEntry) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.Require(b, z.Msgsize()) // check for omitted fields - zb0001Len := uint32(10) - var zb0001Mask uint16 /* 10 bits */ + zb0001Len := uint32(9) + var zb0001Mask uint16 /* 9 bits */ _ = zb0001Mask - if z.ReplicationStats == nil { - zb0001Len-- - zb0001Mask |= 0x80 - } if z.AllTierStats == nil { zb0001Len-- - zb0001Mask |= 0x100 + zb0001Mask |= 0x80 } // variable map header, size zb0001Len o = append(o, 0x80|uint8(zb0001Len)) @@ -1969,19 +1924,6 @@ func (z *dataUsageEntry) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.AppendUint64(o, z.ObjVersions[za0002]) } if (zb0001Mask & 0x80) == 0 { // if not omitted - // string "rs" - o = append(o, 0xa2, 0x72, 0x73) - if z.ReplicationStats == nil { - o = msgp.AppendNil(o) - } else { - o, err = z.ReplicationStats.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } - } - if (zb0001Mask & 0x100) == 0 { // if not omitted // string "ats" o = append(o, 0xa3, 0x61, 0x74, 0x73) if z.AllTierStats == nil { @@ -2084,23 +2026,6 @@ func (z *dataUsageEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - case "rs": - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStats) - } - bts, err = z.ReplicationStats.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } case "ats": if msgp.IsNil(bts) { bts, err = msgp.ReadNilBytes(bts) @@ -2138,13 +2063,7 @@ func (z *dataUsageEntry) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntry) Msgsize() (s int) { - s = 1 + 3 + z.Children.Msgsize() + 3 + msgp.Int64Size + 3 + msgp.Uint64Size + 3 + msgp.Uint64Size + 4 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + 3 + msgp.ArrayHeaderSize + (dataUsageVersionLen * (msgp.Uint64Size)) + 3 - if z.ReplicationStats == nil { - s += msgp.NilSize - } else { - s += z.ReplicationStats.Msgsize() - } - s += 4 + s = 1 + 3 + z.Children.Msgsize() + 3 + msgp.Int64Size + 3 + msgp.Uint64Size + 3 + msgp.Uint64Size + 4 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + 3 + msgp.ArrayHeaderSize + (dataUsageVersionLen * (msgp.Uint64Size)) + 4 if z.AllTierStats == nil { s += msgp.NilSize } else { @@ -2263,8 +2182,8 @@ func (z *dataUsageEntryV3) DecodeMsg(dc *msgp.Reader) (err error) { err = msgp.WrapError(err) return } - if zb0001 != 8 { - err = msgp.ArrayError{Wanted: 8, Got: zb0001} + if zb0001 != 4 { + err = msgp.ArrayError{Wanted: 4, Got: zb0001} return } z.Size, err = dc.ReadInt64() @@ -2272,26 +2191,6 @@ func (z *dataUsageEntryV3) DecodeMsg(dc *msgp.Reader) (err error) { err = msgp.WrapError(err, "Size") return } - z.ReplicatedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.ReplicationPendingSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicationPendingSize") - return - } - z.ReplicationFailedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicationFailedSize") - return - } - z.ReplicaSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } z.Objects, err = dc.ReadUint64() if err != nil { err = msgp.WrapError(err, "Objects") @@ -2330,8 +2229,8 @@ func (z *dataUsageEntryV3) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - if zb0001 != 8 { - err = msgp.ArrayError{Wanted: 8, Got: zb0001} + if zb0001 != 4 { + err = msgp.ArrayError{Wanted: 4, Got: zb0001} return } z.Size, bts, err = msgp.ReadInt64Bytes(bts) @@ -2339,26 +2238,6 @@ func (z *dataUsageEntryV3) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err, "Size") return } - z.ReplicatedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.ReplicationPendingSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationPendingSize") - return - } - z.ReplicationFailedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationFailedSize") - return - } - z.ReplicaSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } z.Objects, bts, err = msgp.ReadUint64Bytes(bts) if err != nil { err = msgp.WrapError(err, "Objects") @@ -2392,7 +2271,7 @@ func (z *dataUsageEntryV3) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntryV3) Msgsize() (s int) { - s = 1 + msgp.Int64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + z.Children.Msgsize() + s = 1 + msgp.Int64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + z.Children.Msgsize() return } @@ -2404,8 +2283,8 @@ func (z *dataUsageEntryV4) DecodeMsg(dc *msgp.Reader) (err error) { err = msgp.WrapError(err) return } - if zb0001 != 5 { - err = msgp.ArrayError{Wanted: 5, Got: zb0001} + if zb0001 != 4 { + err = msgp.ArrayError{Wanted: 4, Got: zb0001} return } err = z.Children.DecodeMsg(dc) @@ -2440,11 +2319,6 @@ func (z *dataUsageEntryV4) DecodeMsg(dc *msgp.Reader) (err error) { return } } - err = z.ReplicationStats.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } return } @@ -2456,8 +2330,8 @@ func (z *dataUsageEntryV4) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - if zb0001 != 5 { - err = msgp.ArrayError{Wanted: 5, Got: zb0001} + if zb0001 != 4 { + err = msgp.ArrayError{Wanted: 4, Got: zb0001} return } bts, err = z.Children.UnmarshalMsg(bts) @@ -2492,18 +2366,13 @@ func (z *dataUsageEntryV4) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - bts, err = z.ReplicationStats.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } o = bts return } // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntryV4) Msgsize() (s int) { - s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + z.ReplicationStats.Msgsize() + s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) return } @@ -2515,8 +2384,8 @@ func (z *dataUsageEntryV5) DecodeMsg(dc *msgp.Reader) (err error) { err = msgp.WrapError(err) return } - if zb0001 != 7 { - err = msgp.ArrayError{Wanted: 7, Got: zb0001} + if zb0001 != 6 { + err = msgp.ArrayError{Wanted: 6, Got: zb0001} return } err = z.Children.DecodeMsg(dc) @@ -2556,23 +2425,6 @@ func (z *dataUsageEntryV5) DecodeMsg(dc *msgp.Reader) (err error) { return } } - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationStatsV1) - } - err = z.ReplicationStats.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } z.Compacted, err = dc.ReadBool() if err != nil { err = msgp.WrapError(err, "Compacted") @@ -2589,8 +2441,8 @@ func (z *dataUsageEntryV5) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - if zb0001 != 7 { - err = msgp.ArrayError{Wanted: 7, Got: zb0001} + if zb0001 != 6 { + err = msgp.ArrayError{Wanted: 6, Got: zb0001} return } bts, err = z.Children.UnmarshalMsg(bts) @@ -2630,22 +2482,6 @@ func (z *dataUsageEntryV5) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationStatsV1) - } - bts, err = z.ReplicationStats.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } z.Compacted, bts, err = msgp.ReadBoolBytes(bts) if err != nil { err = msgp.WrapError(err, "Compacted") @@ -2657,13 +2493,7 @@ func (z *dataUsageEntryV5) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntryV5) Msgsize() (s int) { - s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) - if z.ReplicationStats == nil { - s += msgp.NilSize - } else { - s += z.ReplicationStats.Msgsize() - } - s += msgp.BoolSize + s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + msgp.BoolSize return } @@ -2675,8 +2505,8 @@ func (z *dataUsageEntryV6) DecodeMsg(dc *msgp.Reader) (err error) { err = msgp.WrapError(err) return } - if zb0001 != 7 { - err = msgp.ArrayError{Wanted: 7, Got: zb0001} + if zb0001 != 6 { + err = msgp.ArrayError{Wanted: 6, Got: zb0001} return } err = z.Children.DecodeMsg(dc) @@ -2716,23 +2546,6 @@ func (z *dataUsageEntryV6) DecodeMsg(dc *msgp.Reader) (err error) { return } } - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStatsV1) - } - err = z.ReplicationStats.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } z.Compacted, err = dc.ReadBool() if err != nil { err = msgp.WrapError(err, "Compacted") @@ -2749,8 +2562,8 @@ func (z *dataUsageEntryV6) UnmarshalMsg(bts []byte) (o []byte, err error) { err = msgp.WrapError(err) return } - if zb0001 != 7 { - err = msgp.ArrayError{Wanted: 7, Got: zb0001} + if zb0001 != 6 { + err = msgp.ArrayError{Wanted: 6, Got: zb0001} return } bts, err = z.Children.UnmarshalMsg(bts) @@ -2790,22 +2603,6 @@ func (z *dataUsageEntryV6) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStatsV1) - } - bts, err = z.ReplicationStats.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } z.Compacted, bts, err = msgp.ReadBoolBytes(bts) if err != nil { err = msgp.WrapError(err, "Compacted") @@ -2817,13 +2614,7 @@ func (z *dataUsageEntryV6) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntryV6) Msgsize() (s int) { - s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) - if z.ReplicationStats == nil { - s += msgp.NilSize - } else { - s += z.ReplicationStats.Msgsize() - } - s += msgp.BoolSize + s = 1 + z.Children.Msgsize() + msgp.Int64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.ArrayHeaderSize + (dataUsageBucketLen * (msgp.Uint64Size)) + msgp.BoolSize return } @@ -2911,24 +2702,6 @@ func (z *dataUsageEntryV7) DecodeMsg(dc *msgp.Reader) (err error) { return } } - case "rs": - if dc.IsNil() { - err = dc.ReadNil() - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStats) - } - err = z.ReplicationStats.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } case "ats": if dc.IsNil() { err = dc.ReadNil() @@ -3048,23 +2821,6 @@ func (z *dataUsageEntryV7) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - case "rs": - if msgp.IsNil(bts) { - bts, err = msgp.ReadNilBytes(bts) - if err != nil { - return - } - z.ReplicationStats = nil - } else { - if z.ReplicationStats == nil { - z.ReplicationStats = new(replicationAllStats) - } - bts, err = z.ReplicationStats.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicationStats") - return - } - } case "ats": if msgp.IsNil(bts) { bts, err = msgp.ReadNilBytes(bts) @@ -3102,13 +2858,7 @@ func (z *dataUsageEntryV7) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *dataUsageEntryV7) Msgsize() (s int) { - s = 1 + 3 + z.Children.Msgsize() + 3 + msgp.Int64Size + 3 + msgp.Uint64Size + 3 + msgp.Uint64Size + 4 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + (dataUsageBucketLenV1 * (msgp.Uint64Size)) + 3 + msgp.ArrayHeaderSize + (dataUsageVersionLen * (msgp.Uint64Size)) + 3 - if z.ReplicationStats == nil { - s += msgp.NilSize - } else { - s += z.ReplicationStats.Msgsize() - } - s += 4 + s = 1 + 3 + z.Children.Msgsize() + 3 + msgp.Int64Size + 3 + msgp.Uint64Size + 3 + msgp.Uint64Size + 4 + msgp.Uint64Size + 4 + msgp.ArrayHeaderSize + (dataUsageBucketLenV1 * (msgp.Uint64Size)) + 3 + msgp.ArrayHeaderSize + (dataUsageVersionLen * (msgp.Uint64Size)) + 4 if z.AllTierStats == nil { s += msgp.NilSize } else { @@ -3170,901 +2920,6 @@ func (z dataUsageHash) Msgsize() (s int) { return } -// DecodeMsg implements msgp.Decodable -func (z *replicationAllStats) DecodeMsg(dc *msgp.Reader) (err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, err = dc.ReadMapKeyPtr() - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "t": - var zb0002 uint32 - zb0002, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - if z.Targets == nil { - z.Targets = make(map[string]replicationStats, zb0002) - } else if len(z.Targets) > 0 { - for key := range z.Targets { - delete(z.Targets, key) - } - } - for zb0002 > 0 { - zb0002-- - var za0001 string - var za0002 replicationStats - za0001, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - err = za0002.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - z.Targets[za0001] = za0002 - } - case "r": - z.ReplicaSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - case "rc": - z.ReplicaCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - default: - err = dc.Skip() - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *replicationAllStats) EncodeMsg(en *msgp.Writer) (err error) { - // check for omitted fields - zb0001Len := uint32(3) - var zb0001Mask uint8 /* 3 bits */ - _ = zb0001Mask - if z.Targets == nil { - zb0001Len-- - zb0001Mask |= 0x1 - } - if z.ReplicaSize == 0 { - zb0001Len-- - zb0001Mask |= 0x2 - } - if z.ReplicaCount == 0 { - zb0001Len-- - zb0001Mask |= 0x4 - } - // variable map header, size zb0001Len - err = en.Append(0x80 | uint8(zb0001Len)) - if err != nil { - return - } - if zb0001Len == 0 { - return - } - if (zb0001Mask & 0x1) == 0 { // if not omitted - // write "t" - err = en.Append(0xa1, 0x74) - if err != nil { - return - } - err = en.WriteMapHeader(uint32(len(z.Targets))) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - for za0001, za0002 := range z.Targets { - err = en.WriteString(za0001) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - err = za0002.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - } - } - if (zb0001Mask & 0x2) == 0 { // if not omitted - // write "r" - err = en.Append(0xa1, 0x72) - if err != nil { - return - } - err = en.WriteUint64(z.ReplicaSize) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - } - if (zb0001Mask & 0x4) == 0 { // if not omitted - // write "rc" - err = en.Append(0xa2, 0x72, 0x63) - if err != nil { - return - } - err = en.WriteUint64(z.ReplicaCount) - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *replicationAllStats) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // check for omitted fields - zb0001Len := uint32(3) - var zb0001Mask uint8 /* 3 bits */ - _ = zb0001Mask - if z.Targets == nil { - zb0001Len-- - zb0001Mask |= 0x1 - } - if z.ReplicaSize == 0 { - zb0001Len-- - zb0001Mask |= 0x2 - } - if z.ReplicaCount == 0 { - zb0001Len-- - zb0001Mask |= 0x4 - } - // variable map header, size zb0001Len - o = append(o, 0x80|uint8(zb0001Len)) - if zb0001Len == 0 { - return - } - if (zb0001Mask & 0x1) == 0 { // if not omitted - // string "t" - o = append(o, 0xa1, 0x74) - o = msgp.AppendMapHeader(o, uint32(len(z.Targets))) - for za0001, za0002 := range z.Targets { - o = msgp.AppendString(o, za0001) - o, err = za0002.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - } - } - if (zb0001Mask & 0x2) == 0 { // if not omitted - // string "r" - o = append(o, 0xa1, 0x72) - o = msgp.AppendUint64(o, z.ReplicaSize) - } - if (zb0001Mask & 0x4) == 0 { // if not omitted - // string "rc" - o = append(o, 0xa2, 0x72, 0x63) - o = msgp.AppendUint64(o, z.ReplicaCount) - } - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *replicationAllStats) UnmarshalMsg(bts []byte) (o []byte, err error) { - var field []byte - _ = field - var zb0001 uint32 - zb0001, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - for zb0001 > 0 { - zb0001-- - field, bts, err = msgp.ReadMapKeyZC(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - switch msgp.UnsafeString(field) { - case "t": - var zb0002 uint32 - zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - if z.Targets == nil { - z.Targets = make(map[string]replicationStats, zb0002) - } else if len(z.Targets) > 0 { - for key := range z.Targets { - delete(z.Targets, key) - } - } - for zb0002 > 0 { - var za0001 string - var za0002 replicationStats - zb0002-- - za0001, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - bts, err = za0002.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - z.Targets[za0001] = za0002 - } - case "r": - z.ReplicaSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - case "rc": - z.ReplicaCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - default: - bts, err = msgp.Skip(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - } - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *replicationAllStats) Msgsize() (s int) { - s = 1 + 2 + msgp.MapHeaderSize - if z.Targets != nil { - for za0001, za0002 := range z.Targets { - _ = za0002 - s += msgp.StringPrefixSize + len(za0001) + za0002.Msgsize() - } - } - s += 2 + msgp.Uint64Size + 3 + msgp.Uint64Size - return -} - -// DecodeMsg implements msgp.Decodable -func (z *replicationAllStatsV1) DecodeMsg(dc *msgp.Reader) (err error) { - var zb0001 uint32 - zb0001, err = dc.ReadArrayHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 3 { - err = msgp.ArrayError{Wanted: 3, Got: zb0001} - return - } - var zb0002 uint32 - zb0002, err = dc.ReadMapHeader() - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - if z.Targets == nil { - z.Targets = make(map[string]replicationStats, zb0002) - } else if len(z.Targets) > 0 { - for key := range z.Targets { - delete(z.Targets, key) - } - } - var field []byte - _ = field - for zb0002 > 0 { - zb0002-- - var za0001 string - var za0002 replicationStats - za0001, err = dc.ReadString() - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - err = za0002.DecodeMsg(dc) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - z.Targets[za0001] = za0002 - } - z.ReplicaSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - z.ReplicaCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *replicationAllStatsV1) EncodeMsg(en *msgp.Writer) (err error) { - // array header, size 3 - err = en.Append(0x93) - if err != nil { - return - } - err = en.WriteMapHeader(uint32(len(z.Targets))) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - for za0001, za0002 := range z.Targets { - err = en.WriteString(za0001) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - err = za0002.EncodeMsg(en) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - } - err = en.WriteUint64(z.ReplicaSize) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - err = en.WriteUint64(z.ReplicaCount) - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *replicationAllStatsV1) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // array header, size 3 - o = append(o, 0x93) - o = msgp.AppendMapHeader(o, uint32(len(z.Targets))) - for za0001, za0002 := range z.Targets { - o = msgp.AppendString(o, za0001) - o, err = za0002.MarshalMsg(o) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - } - o = msgp.AppendUint64(o, z.ReplicaSize) - o = msgp.AppendUint64(o, z.ReplicaCount) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *replicationAllStatsV1) UnmarshalMsg(bts []byte) (o []byte, err error) { - var zb0001 uint32 - zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 3 { - err = msgp.ArrayError{Wanted: 3, Got: zb0001} - return - } - var zb0002 uint32 - zb0002, bts, err = msgp.ReadMapHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - if z.Targets == nil { - z.Targets = make(map[string]replicationStats, zb0002) - } else if len(z.Targets) > 0 { - for key := range z.Targets { - delete(z.Targets, key) - } - } - var field []byte - _ = field - for zb0002 > 0 { - var za0001 string - var za0002 replicationStats - zb0002-- - za0001, bts, err = msgp.ReadStringBytes(bts) - if err != nil { - err = msgp.WrapError(err, "Targets") - return - } - bts, err = za0002.UnmarshalMsg(bts) - if err != nil { - err = msgp.WrapError(err, "Targets", za0001) - return - } - z.Targets[za0001] = za0002 - } - z.ReplicaSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - z.ReplicaCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaCount") - return - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *replicationAllStatsV1) Msgsize() (s int) { - s = 1 + msgp.MapHeaderSize - if z.Targets != nil { - for za0001, za0002 := range z.Targets { - _ = za0002 - s += msgp.StringPrefixSize + len(za0001) + za0002.Msgsize() - } - } - s += msgp.Uint64Size + msgp.Uint64Size - return -} - -// DecodeMsg implements msgp.Decodable -func (z *replicationStats) DecodeMsg(dc *msgp.Reader) (err error) { - var zb0001 uint32 - zb0001, err = dc.ReadArrayHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 10 { - err = msgp.ArrayError{Wanted: 10, Got: zb0001} - return - } - z.PendingSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - z.ReplicatedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.FailedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - z.FailedCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - z.PendingCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - z.MissedThresholdSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - z.AfterThresholdSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - z.MissedThresholdCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - z.AfterThresholdCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - z.ReplicatedCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicatedCount") - return - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *replicationStats) EncodeMsg(en *msgp.Writer) (err error) { - // array header, size 10 - err = en.Append(0x9a) - if err != nil { - return - } - err = en.WriteUint64(z.PendingSize) - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - err = en.WriteUint64(z.ReplicatedSize) - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - err = en.WriteUint64(z.FailedSize) - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - err = en.WriteUint64(z.FailedCount) - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - err = en.WriteUint64(z.PendingCount) - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - err = en.WriteUint64(z.MissedThresholdSize) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - err = en.WriteUint64(z.AfterThresholdSize) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - err = en.WriteUint64(z.MissedThresholdCount) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - err = en.WriteUint64(z.AfterThresholdCount) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - err = en.WriteUint64(z.ReplicatedCount) - if err != nil { - err = msgp.WrapError(err, "ReplicatedCount") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *replicationStats) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // array header, size 10 - o = append(o, 0x9a) - o = msgp.AppendUint64(o, z.PendingSize) - o = msgp.AppendUint64(o, z.ReplicatedSize) - o = msgp.AppendUint64(o, z.FailedSize) - o = msgp.AppendUint64(o, z.FailedCount) - o = msgp.AppendUint64(o, z.PendingCount) - o = msgp.AppendUint64(o, z.MissedThresholdSize) - o = msgp.AppendUint64(o, z.AfterThresholdSize) - o = msgp.AppendUint64(o, z.MissedThresholdCount) - o = msgp.AppendUint64(o, z.AfterThresholdCount) - o = msgp.AppendUint64(o, z.ReplicatedCount) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *replicationStats) UnmarshalMsg(bts []byte) (o []byte, err error) { - var zb0001 uint32 - zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 10 { - err = msgp.ArrayError{Wanted: 10, Got: zb0001} - return - } - z.PendingSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - z.ReplicatedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.FailedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - z.FailedCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - z.PendingCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - z.MissedThresholdSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - z.AfterThresholdSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - z.MissedThresholdCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - z.AfterThresholdCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - z.ReplicatedCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicatedCount") - return - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *replicationStats) Msgsize() (s int) { - s = 1 + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size - return -} - -// DecodeMsg implements msgp.Decodable -func (z *replicationStatsV1) DecodeMsg(dc *msgp.Reader) (err error) { - var zb0001 uint32 - zb0001, err = dc.ReadArrayHeader() - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 10 { - err = msgp.ArrayError{Wanted: 10, Got: zb0001} - return - } - z.PendingSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - z.ReplicatedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.FailedSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - z.ReplicaSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - z.FailedCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - z.PendingCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - z.MissedThresholdSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - z.AfterThresholdSize, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - z.MissedThresholdCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - z.AfterThresholdCount, err = dc.ReadUint64() - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - return -} - -// EncodeMsg implements msgp.Encodable -func (z *replicationStatsV1) EncodeMsg(en *msgp.Writer) (err error) { - // array header, size 10 - err = en.Append(0x9a) - if err != nil { - return - } - err = en.WriteUint64(z.PendingSize) - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - err = en.WriteUint64(z.ReplicatedSize) - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - err = en.WriteUint64(z.FailedSize) - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - err = en.WriteUint64(z.ReplicaSize) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - err = en.WriteUint64(z.FailedCount) - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - err = en.WriteUint64(z.PendingCount) - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - err = en.WriteUint64(z.MissedThresholdSize) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - err = en.WriteUint64(z.AfterThresholdSize) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - err = en.WriteUint64(z.MissedThresholdCount) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - err = en.WriteUint64(z.AfterThresholdCount) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - return -} - -// MarshalMsg implements msgp.Marshaler -func (z *replicationStatsV1) MarshalMsg(b []byte) (o []byte, err error) { - o = msgp.Require(b, z.Msgsize()) - // array header, size 10 - o = append(o, 0x9a) - o = msgp.AppendUint64(o, z.PendingSize) - o = msgp.AppendUint64(o, z.ReplicatedSize) - o = msgp.AppendUint64(o, z.FailedSize) - o = msgp.AppendUint64(o, z.ReplicaSize) - o = msgp.AppendUint64(o, z.FailedCount) - o = msgp.AppendUint64(o, z.PendingCount) - o = msgp.AppendUint64(o, z.MissedThresholdSize) - o = msgp.AppendUint64(o, z.AfterThresholdSize) - o = msgp.AppendUint64(o, z.MissedThresholdCount) - o = msgp.AppendUint64(o, z.AfterThresholdCount) - return -} - -// UnmarshalMsg implements msgp.Unmarshaler -func (z *replicationStatsV1) UnmarshalMsg(bts []byte) (o []byte, err error) { - var zb0001 uint32 - zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) - if err != nil { - err = msgp.WrapError(err) - return - } - if zb0001 != 10 { - err = msgp.ArrayError{Wanted: 10, Got: zb0001} - return - } - z.PendingSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "PendingSize") - return - } - z.ReplicatedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicatedSize") - return - } - z.FailedSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "FailedSize") - return - } - z.ReplicaSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "ReplicaSize") - return - } - z.FailedCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "FailedCount") - return - } - z.PendingCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "PendingCount") - return - } - z.MissedThresholdSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdSize") - return - } - z.AfterThresholdSize, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdSize") - return - } - z.MissedThresholdCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "MissedThresholdCount") - return - } - z.AfterThresholdCount, bts, err = msgp.ReadUint64Bytes(bts) - if err != nil { - err = msgp.WrapError(err, "AfterThresholdCount") - return - } - o = bts - return -} - -// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message -func (z *replicationStatsV1) Msgsize() (s int) { - s = 1 + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size + msgp.Uint64Size - return -} - // DecodeMsg implements msgp.Decodable func (z *sizeHistogram) DecodeMsg(dc *msgp.Reader) (err error) { var zb0001 uint32 diff --git a/cmd/data-usage-cache_gen_test.go b/cmd/data-usage-cache_gen_test.go index 9b726e077..d17134717 100644 --- a/cmd/data-usage-cache_gen_test.go +++ b/cmd/data-usage-cache_gen_test.go @@ -519,458 +519,6 @@ func BenchmarkDecodedataUsageEntry(b *testing.B) { } } -func TestMarshalUnmarshalreplicationAllStats(t *testing.T) { - v := replicationAllStats{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgreplicationAllStats(b *testing.B) { - v := replicationAllStats{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgreplicationAllStats(b *testing.B) { - v := replicationAllStats{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalreplicationAllStats(b *testing.B) { - v := replicationAllStats{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodereplicationAllStats(t *testing.T) { - v := replicationAllStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodereplicationAllStats Msgsize() is inaccurate") - } - - vn := replicationAllStats{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodereplicationAllStats(b *testing.B) { - v := replicationAllStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodereplicationAllStats(b *testing.B) { - v := replicationAllStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalreplicationAllStatsV1(t *testing.T) { - v := replicationAllStatsV1{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgreplicationAllStatsV1(b *testing.B) { - v := replicationAllStatsV1{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgreplicationAllStatsV1(b *testing.B) { - v := replicationAllStatsV1{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalreplicationAllStatsV1(b *testing.B) { - v := replicationAllStatsV1{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodereplicationAllStatsV1(t *testing.T) { - v := replicationAllStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodereplicationAllStatsV1 Msgsize() is inaccurate") - } - - vn := replicationAllStatsV1{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodereplicationAllStatsV1(b *testing.B) { - v := replicationAllStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodereplicationAllStatsV1(b *testing.B) { - v := replicationAllStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalreplicationStats(t *testing.T) { - v := replicationStats{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgreplicationStats(b *testing.B) { - v := replicationStats{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgreplicationStats(b *testing.B) { - v := replicationStats{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalreplicationStats(b *testing.B) { - v := replicationStats{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodereplicationStats(t *testing.T) { - v := replicationStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodereplicationStats Msgsize() is inaccurate") - } - - vn := replicationStats{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodereplicationStats(b *testing.B) { - v := replicationStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodereplicationStats(b *testing.B) { - v := replicationStats{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalUnmarshalreplicationStatsV1(t *testing.T) { - v := replicationStatsV1{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsgreplicationStatsV1(b *testing.B) { - v := replicationStatsV1{} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.MarshalMsg(nil) - } -} - -func BenchmarkAppendMsgreplicationStatsV1(b *testing.B) { - v := replicationStatsV1{} - bts := make([]byte, 0, v.Msgsize()) - bts, _ = v.MarshalMsg(bts[0:0]) - b.SetBytes(int64(len(bts))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - bts, _ = v.MarshalMsg(bts[0:0]) - } -} - -func BenchmarkUnmarshalreplicationStatsV1(b *testing.B) { - v := replicationStatsV1{} - bts, _ := v.MarshalMsg(nil) - b.ReportAllocs() - b.SetBytes(int64(len(bts))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := v.UnmarshalMsg(bts) - if err != nil { - b.Fatal(err) - } - } -} - -func TestEncodeDecodereplicationStatsV1(t *testing.T) { - v := replicationStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - - m := v.Msgsize() - if buf.Len() > m { - t.Log("WARNING: TestEncodeDecodereplicationStatsV1 Msgsize() is inaccurate") - } - - vn := replicationStatsV1{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncodereplicationStatsV1(b *testing.B) { - v := replicationStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - v.EncodeMsg(en) - } - en.Flush() -} - -func BenchmarkDecodereplicationStatsV1(b *testing.B) { - v := replicationStatsV1{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - rd := msgp.NewEndlessReader(buf.Bytes(), b) - dc := msgp.NewReader(rd) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := v.DecodeMsg(dc) - if err != nil { - b.Fatal(err) - } - } -} - func TestMarshalUnmarshalsizeHistogram(t *testing.T) { v := sizeHistogram{} bts, err := v.MarshalMsg(nil) diff --git a/cmd/data-usage_test.go b/cmd/data-usage_test.go index 792c4293f..981e99490 100644 --- a/cmd/data-usage_test.go +++ b/cmd/data-usage_test.go @@ -587,17 +587,6 @@ func TestDataUsageCacheSerialize(t *testing.T) { t.Fatal(err) } e := want.find("abucket/dir2") - e.ReplicationStats = &replicationAllStats{ - Targets: map[string]replicationStats{ - "arn": { - PendingSize: 1, - ReplicatedSize: 2, - FailedSize: 3, - FailedCount: 5, - PendingCount: 6, - }, - }, - } want.replace("abucket/dir2", "", *e) var buf bytes.Buffer err = want.serializeTo(&buf) diff --git a/cmd/erasure.go b/cmd/erasure.go index 1c20d010f..cb8662e0d 100644 --- a/cmd/erasure.go +++ b/cmd/erasure.go @@ -551,9 +551,6 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, wa var root dataUsageEntry if r := cache.root(); r != nil { root = cache.flatten(*r) - if root.ReplicationStats.empty() { - root.ReplicationStats = nil - } } select { case <-ctx.Done(): From 1bc6681176257bdd7a831b053a448412a3589a3c Mon Sep 17 00:00:00 2001 From: Poorna Date: Fri, 4 Oct 2024 22:16:15 -0700 Subject: [PATCH 3/3] fix tagging overwrite during resync (#20525) --- cmd/object-handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 3443ecd41..cf0377fa7 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -1522,7 +1522,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re if !srcTimestamp.IsZero() { ondiskTimestamp, err := time.Parse(time.RFC3339Nano, lastTaggingTimestamp) // update tagging metadata only if replica timestamp is newer than what's on disk - if err != nil || (err == nil && ondiskTimestamp.Before(srcTimestamp)) { + if err != nil || (err == nil && !ondiskTimestamp.After(srcTimestamp)) { srcInfo.UserDefined[ReservedMetadataPrefixLower+TaggingTimestamp] = srcTimestamp.UTC().Format(time.RFC3339Nano) srcInfo.UserDefined[xhttp.AmzObjectTagging] = objTags }