mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
Added storage limits (#28270)
This commit is contained in:
@@ -153,10 +153,19 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
|
|||||||
return segments, nil
|
return segments, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSegmentCount := 1
|
// determine how many segments are necessary to store the clients for this month
|
||||||
|
// using the default storage limits
|
||||||
|
numNecessarySegments := len(s.clients) / ActivitySegmentClientCapacity
|
||||||
|
if len(s.clients)%ActivitySegmentClientCapacity != 0 {
|
||||||
|
numNecessarySegments++
|
||||||
|
}
|
||||||
|
totalSegmentCount := numNecessarySegments
|
||||||
|
|
||||||
|
// override the segment count if set by client
|
||||||
if s.generationParameters.GetNumSegments() > 0 {
|
if s.generationParameters.GetNumSegments() > 0 {
|
||||||
totalSegmentCount = int(s.generationParameters.GetNumSegments())
|
totalSegmentCount = int(s.generationParameters.GetNumSegments())
|
||||||
}
|
}
|
||||||
|
|
||||||
numNonUsable := len(skipIndexes) + len(emptyIndexes)
|
numNonUsable := len(skipIndexes) + len(emptyIndexes)
|
||||||
usableSegmentCount := totalSegmentCount - numNonUsable
|
usableSegmentCount := totalSegmentCount - numNonUsable
|
||||||
if usableSegmentCount <= 0 {
|
if usableSegmentCount <= 0 {
|
||||||
@@ -169,6 +178,10 @@ func (s *singleMonthActivityClients) populateSegments() (map[int][]*activity.Ent
|
|||||||
segmentSizes++
|
segmentSizes++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if segmentSizes > ActivitySegmentClientCapacity {
|
||||||
|
return nil, fmt.Errorf("the number of segments is too low, it must be greater than %d in order to meet storage limits", numNecessarySegments)
|
||||||
|
}
|
||||||
|
|
||||||
clientIndex := 0
|
clientIndex := 0
|
||||||
for i := 0; i < totalSegmentCount; i++ {
|
for i := 0; i < totalSegmentCount; i++ {
|
||||||
if clientIndex >= len(s.clients) {
|
if clientIndex >= len(s.clients) {
|
||||||
|
|||||||
Reference in New Issue
Block a user