(ringDesc *Desc)
| 1000 | } |
| 1001 | |
| 1002 | func (i *Lifecycler) updateCounters(ringDesc *Desc) { |
| 1003 | healthyInstancesCount := 0 |
| 1004 | instancesCount := 0 |
| 1005 | readOnlyInstancesCount := 0 |
| 1006 | zones := map[string]int{} |
| 1007 | healthyInstancesInZone := map[string]int{} |
| 1008 | |
| 1009 | if ringDesc != nil { |
| 1010 | now := time.Now() |
| 1011 | |
| 1012 | for _, ingester := range ringDesc.Ingesters { |
| 1013 | zones[ingester.Zone]++ |
| 1014 | instancesCount++ |
| 1015 | if ingester.ReadOnly { |
| 1016 | readOnlyInstancesCount++ |
| 1017 | } |
| 1018 | |
| 1019 | // Count the number of healthy instances for Write operation. |
| 1020 | if ingester.IsHealthy(Write, i.cfg.RingConfig.HeartbeatTimeout, now) { |
| 1021 | healthyInstancesCount++ |
| 1022 | healthyInstancesInZone[ingester.Zone]++ |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | zoneNames := make([]string, 0, len(zones)) |
| 1028 | for zone := range zones { |
| 1029 | zoneNames = append(zoneNames, zone) |
| 1030 | } |
| 1031 | sort.Strings(zoneNames) |
| 1032 | |
| 1033 | // Update counters |
| 1034 | i.countersLock.Lock() |
| 1035 | i.healthyInstancesCount = healthyInstancesCount |
| 1036 | i.instancesCount = instancesCount |
| 1037 | i.readOnlyInstancesCount = readOnlyInstancesCount |
| 1038 | i.healthyInstancesInZoneCount = healthyInstancesInZone[i.cfg.Zone] |
| 1039 | i.instancesInZoneCount = zones[i.cfg.Zone] |
| 1040 | i.zonesCount = len(zones) |
| 1041 | i.zones = zoneNames |
| 1042 | i.countersLock.Unlock() |
| 1043 | } |
| 1044 | |
| 1045 | // FlushOnShutdown returns if flushing is enabled if transfer fails on a shutdown. |
| 1046 | func (i *Lifecycler) FlushOnShutdown() bool { |
no test coverage detected