Skip to content

Commit

Permalink
removing a few more usages of value methods
Browse files Browse the repository at this point in the history
  • Loading branch information
francoposa committed Jan 23, 2025
1 parent da175ea commit 9b827a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ring/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ func (d *Desc) ClaimTokens(from, to string) Tokens {
// FindIngestersByState returns the list of ingesters in the given state
func (d *Desc) FindIngestersByState(state InstanceState) []InstanceDesc {
var result []InstanceDesc
for _, ing := range d.GetIngesterVals() {
for _, ing := range d.GetIngesters() {
if ing.State == state {
result = append(result, ing)
result = append(result, *ing)
}
}
return result
Expand Down
21 changes: 10 additions & 11 deletions ring/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ func (r *Ring) GetAllHealthy(op Operation) (ReplicationSet, error) {

now := time.Now()
instances := make([]InstanceDesc, 0, len(r.ringDesc.Ingesters))
for _, instance := range r.ringDesc.GetIngesterVals() {
if r.IsHealthy(&instance, op, now) {
instances = append(instances, instance)
for _, instance := range r.ringDesc.GetIngesters() {
if r.IsHealthy(instance, op, now) {
instances = append(instances, *instance)
}
}

Expand All @@ -552,9 +552,9 @@ func (r *Ring) GetReplicationSetForOperation(op Operation) (ReplicationSet, erro
zoneFailures := make(map[string]struct{})
now := time.Now()

for _, instance := range r.ringDesc.GetIngesterVals() {
if r.IsHealthy(&instance, op, now) {
healthyInstances = append(healthyInstances, instance)
for _, instance := range r.ringDesc.GetIngesters() {
if r.IsHealthy(instance, op, now) {
healthyInstances = append(healthyInstances, *instance)
} else {
zoneFailures[instance.Zone] = struct{}{}
}
Expand Down Expand Up @@ -670,9 +670,9 @@ func (r *Ring) updateRingMetrics() {
oldestTimestampByState[s] = 0
}

for _, instance := range r.ringDesc.GetIngesterVals() {
for _, instance := range r.ringDesc.GetIngesters() {
s := instance.State.String()
if !r.IsHealthy(&instance, Reporting, time.Now()) {
if !r.IsHealthy(instance, Reporting, time.Now()) {
s = unhealthy
}
numByState[s]++
Expand Down Expand Up @@ -1130,11 +1130,10 @@ func (r *Ring) getCachedShuffledSubringWithLookback(identifier string, size int,

// Update instance states and timestamps. We know that the topology is the same,
// so zones and tokens are equal.
for name, cachedIng := range cachedSubring.ringDesc.GetIngesterVals() {
ing, _ := r.ringDesc.GetIngesterVal(name)
for name, cachedIng := range cachedSubring.ringDesc.GetIngesters() {
ing := r.ringDesc.GetIngester(name)
cachedIng.State = ing.State
cachedIng.Timestamp = ing.Timestamp
cachedSubring.ringDesc.SetIngesterVal(name, cachedIng)
}

return cachedSubring
Expand Down

0 comments on commit 9b827a7

Please sign in to comment.