Update Adds and removes regular or compacted blocks from the in-memory blocklist. Changes are temporary and will be preserved only for one poll
(tenantID string, add []*backend.BlockMeta, remove []*backend.BlockMeta, compactedAdd []*backend.CompactedBlockMeta, compactedRemove []*backend.CompactedBlockMeta)
| 102 | // Update Adds and removes regular or compacted blocks from the in-memory blocklist. |
| 103 | // Changes are temporary and will be preserved only for one poll |
| 104 | func (l *List) Update(tenantID string, add []*backend.BlockMeta, remove []*backend.BlockMeta, compactedAdd []*backend.CompactedBlockMeta, compactedRemove []*backend.CompactedBlockMeta) { |
| 105 | if tenantID == "" { |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | l.mtx.Lock() |
| 110 | defer l.mtx.Unlock() |
| 111 | |
| 112 | l.updateInternal(tenantID, add, remove, compactedAdd, compactedRemove) |
| 113 | |
| 114 | // We have updated the current blocklist, but we may be in the middle of a |
| 115 | // polling cycle. When the Apply is called above, we will have lost the |
| 116 | // changes that we have just added. So we keep track of them here and apply |
| 117 | // them again after the Apply to save them for the next polling cycle. On |
| 118 | // the next polling cycle, the changes here will rediscovered. |
| 119 | l.added[tenantID] = append(l.added[tenantID], add...) |
| 120 | l.removed[tenantID] = append(l.removed[tenantID], remove...) |
| 121 | l.compactedAdded[tenantID] = append(l.compactedAdded[tenantID], compactedAdd...) |
| 122 | l.compactedRemoved[tenantID] = append(l.compactedRemoved[tenantID], compactedRemove...) |
| 123 | } |
| 124 | |
| 125 | // updateInternal exists to do the work of applying updates to held PerTenant and PerTenantCompacted maps |
| 126 | // it must be called under lock |